27
27
// TailnetIP is a static IPv6 address with the Tailscale prefix that is used to route
28
28
// connections from clients to this node. A dynamic address is not required because a Tailnet
29
29
// 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 (
31
34
TailnetSSHPort = 1
32
35
TailnetReconnectingPTYPort = 2
33
36
TailnetSpeedtestPort = 3
@@ -171,7 +174,7 @@ func (c *AgentConn) ReconnectingPTY(ctx context.Context, id uuid.UUID, height, w
171
174
ctx , span := tracing .StartSpan (ctx )
172
175
defer span .End ()
173
176
174
- conn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , uint16 ( TailnetReconnectingPTYPort ) ))
177
+ conn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , TailnetReconnectingPTYPort ))
175
178
if err != nil {
176
179
return nil , err
177
180
}
@@ -199,7 +202,7 @@ func (c *AgentConn) ReconnectingPTY(ctx context.Context, id uuid.UUID, height, w
199
202
func (c * AgentConn ) SSH (ctx context.Context ) (net.Conn , error ) {
200
203
ctx , span := tracing .StartSpan (ctx )
201
204
defer span .End ()
202
- return c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , uint16 ( TailnetSSHPort ) ))
205
+ return c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , TailnetSSHPort ))
203
206
}
204
207
205
208
// 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) {
226
229
func (c * AgentConn ) Speedtest (ctx context.Context , direction speedtest.Direction , duration time.Duration ) ([]speedtest.Result , error ) {
227
230
ctx , span := tracing .StartSpan (ctx )
228
231
defer span .End ()
229
- speedConn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , uint16 ( TailnetSpeedtestPort ) ))
232
+ speedConn , err := c .DialContextTCP (ctx , netip .AddrPortFrom (TailnetIP , TailnetSpeedtestPort ))
230
233
if err != nil {
231
234
return nil , xerrors .Errorf ("dial speedtest: %w" , err )
232
235
}
@@ -244,7 +247,7 @@ func (c *AgentConn) DialContext(ctx context.Context, network string, addr string
244
247
return nil , xerrors .New ("network must be tcp or udp" )
245
248
}
246
249
_ , rawPort , _ := net .SplitHostPort (addr )
247
- port , _ := strconv .Atoi (rawPort )
250
+ port , _ := strconv .ParseUint (rawPort , 10 , 16 )
248
251
ipp := netip .AddrPortFrom (TailnetIP , uint16 (port ))
249
252
if network == "udp" {
250
253
return c .Conn .DialContextUDP (ctx , ipp )
@@ -272,7 +275,7 @@ func (c *AgentConn) statisticsClient() *http.Client {
272
275
return nil , xerrors .Errorf ("request %q does not appear to be for statistics server" , addr )
273
276
}
274
277
275
- conn , err := c .DialContextTCP (context .Background (), netip .AddrPortFrom (TailnetIP , uint16 ( TailnetStatisticsPort ) ))
278
+ conn , err := c .DialContextTCP (context .Background (), netip .AddrPortFrom (TailnetIP , TailnetStatisticsPort ))
276
279
if err != nil {
277
280
return nil , xerrors .Errorf ("dial statistics: %w" , err )
278
281
}
0 commit comments