@@ -63,7 +63,7 @@ type LocalNode struct {
6363type lnEndpoint struct {
6464 track * netutil.IPTracker
6565 staticIP , fallbackIP net.IP
66- fallbackUDP int
66+ fallbackUDP uint16 // port
6767}
6868
6969// NewLocalNode creates a local node.
@@ -208,8 +208,8 @@ func (ln *LocalNode) SetFallbackUDP(port int) {
208208 ln .mu .Lock ()
209209 defer ln .mu .Unlock ()
210210
211- ln .endpoint4 .fallbackUDP = port
212- ln .endpoint6 .fallbackUDP = port
211+ ln .endpoint4 .fallbackUDP = uint16 ( port )
212+ ln .endpoint6 .fallbackUDP = uint16 ( port )
213213 ln .updateEndpoints ()
214214}
215215
@@ -261,7 +261,7 @@ func (ln *LocalNode) updateEndpoints() {
261261}
262262
263263// 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 ) {
265265 newPort = e .fallbackUDP
266266 if e .fallbackIP != nil {
267267 newIP = e .fallbackIP
@@ -277,15 +277,18 @@ func (e *lnEndpoint) get() (newIP net.IP, newPort int) {
277277
278278// predictAddr wraps IPTracker.PredictEndpoint, converting from its string-based
279279// 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 ) {
281281 ep := t .PredictEndpoint ()
282282 if ep == "" {
283283 return nil , 0
284284 }
285285 ipString , portString , _ := net .SplitHostPort (ep )
286286 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 )
289292}
290293
291294func (ln * LocalNode ) invalidate () {
0 commit comments