2727 // TailnetIP is a static IPv6 address with the Tailscale prefix that is used to route
2828 // connections from clients to this node. A dynamic address is not required because a Tailnet
2929 // client only dials a single agent at a time.
30- TailnetIP = netip .MustParseAddr ("fd7a:115c:a1e0:49d6:b259:b7ac:b1b2:48f4" )
30+ TailnetIP = netip .MustParseAddr ("fd7a:115c:a1e0:49d6:b259:b7ac:b1b2:48f4" )
31+ )
32+
33+ const (
3134 TailnetSSHPort = 1
3235 TailnetReconnectingPTYPort = 2
3336 TailnetSpeedtestPort = 3
@@ -171,7 +174,7 @@ func (c *AgentConn) ReconnectingPTY(ctx context.Context, id uuid.UUID, height, w
171174 ctx , span := tracing .StartSpan (ctx )
172175 defer span .End ()
173176
174- conn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , uint16 ( TailnetReconnectingPTYPort ) ))
177+ conn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , TailnetReconnectingPTYPort ))
175178 if err != nil {
176179 return nil , err
177180 }
@@ -199,7 +202,7 @@ func (c *AgentConn) ReconnectingPTY(ctx context.Context, id uuid.UUID, height, w
199202func (c * AgentConn ) SSH (ctx context.Context ) (net.Conn , error ) {
200203 ctx , span := tracing .StartSpan (ctx )
201204 defer span .End ()
202- return c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , uint16 ( TailnetSSHPort ) ))
205+ return c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , TailnetSSHPort ))
203206}
204207
205208// SSHClient calls SSH to create a client that uses a weak cipher
@@ -226,7 +229,7 @@ func (c *AgentConn) SSHClient(ctx context.Context) (*ssh.Client, error) {
226229func (c * AgentConn ) Speedtest (ctx context.Context , direction speedtest.Direction , duration time.Duration ) ([]speedtest.Result , error ) {
227230 ctx , span := tracing .StartSpan (ctx )
228231 defer span .End ()
229- speedConn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , uint16 ( TailnetSpeedtestPort ) ))
232+ speedConn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , TailnetSpeedtestPort ))
230233 if err != nil {
231234 return nil , xerrors .Errorf ("dial speedtest: %w" , err )
232235 }
@@ -244,7 +247,7 @@ func (c *AgentConn) DialContext(ctx context.Context, network string, addr string
244247 return nil , xerrors .New ("network must be tcp or udp" )
245248 }
246249 _ , rawPort , _ := net .SplitHostPort (addr )
247- port , _ := strconv .Atoi (rawPort )
250+ port , _ := strconv .ParseUint (rawPort , 10 , 16 )
248251 ipp := netip .AddrPortFrom (TailnetIP , uint16 (port ))
249252 if network == "udp" {
250253 return c .Conn .DialContextUDP (ctx , ipp )
@@ -272,7 +275,7 @@ func (c *AgentConn) statisticsClient() *http.Client {
272275 return nil , xerrors .Errorf ("request %q does not appear to be for statistics server" , addr )
273276 }
274277
275- conn , err := c .DialContextTCP (context .Background (), netip .AddrPortFrom (TailnetIP , uint16 ( TailnetStatisticsPort ) ))
278+ conn , err := c .DialContextTCP (context .Background (), netip .AddrPortFrom (TailnetIP , TailnetStatisticsPort ))
276279 if err != nil {
277280 return nil , xerrors .Errorf ("dial statistics: %w" , err )
278281 }
0 commit comments