@@ -63,7 +63,7 @@ type LocalNode struct {
63
63
type lnEndpoint struct {
64
64
track * netutil.IPTracker
65
65
staticIP , fallbackIP net.IP
66
- fallbackUDP int
66
+ fallbackUDP uint16 // port
67
67
}
68
68
69
69
// NewLocalNode creates a local node.
@@ -208,8 +208,8 @@ func (ln *LocalNode) SetFallbackUDP(port int) {
208
208
ln .mu .Lock ()
209
209
defer ln .mu .Unlock ()
210
210
211
- ln .endpoint4 .fallbackUDP = port
212
- ln .endpoint6 .fallbackUDP = port
211
+ ln .endpoint4 .fallbackUDP = uint16 ( port )
212
+ ln .endpoint6 .fallbackUDP = uint16 ( port )
213
213
ln .updateEndpoints ()
214
214
}
215
215
@@ -261,7 +261,7 @@ func (ln *LocalNode) updateEndpoints() {
261
261
}
262
262
263
263
// get returns the endpoint with highest precedence.
264
- func (e * lnEndpoint ) get () (newIP net.IP , newPort int ) {
264
+ func (e * lnEndpoint ) get () (newIP net.IP , newPort uint16 ) {
265
265
newPort = e .fallbackUDP
266
266
if e .fallbackIP != nil {
267
267
newIP = e .fallbackIP
@@ -277,15 +277,18 @@ func (e *lnEndpoint) get() (newIP net.IP, newPort int) {
277
277
278
278
// predictAddr wraps IPTracker.PredictEndpoint, converting from its string-based
279
279
// endpoint representation to IP and port types.
280
- func predictAddr (t * netutil.IPTracker ) (net.IP , int ) {
280
+ func predictAddr (t * netutil.IPTracker ) (net.IP , uint16 ) {
281
281
ep := t .PredictEndpoint ()
282
282
if ep == "" {
283
283
return nil , 0
284
284
}
285
285
ipString , portString , _ := net .SplitHostPort (ep )
286
286
ip := net .ParseIP (ipString )
287
- port , _ := strconv .Atoi (portString )
288
- return ip , port
287
+ port , err := strconv .ParseUint (portString , 10 , 16 )
288
+ if err != nil {
289
+ return nil , 0
290
+ }
291
+ return ip , uint16 (port )
289
292
}
290
293
291
294
func (ln * LocalNode ) invalidate () {
0 commit comments