@@ -336,7 +336,7 @@ func (l *links) add(u *url.URL, sintf string, linkType linkType) error {
336336
337337				// Give the connection to the handler. The handler will block 
338338				// for the lifetime of the connection. 
339- 				if  err  =  l .handler (linkType , options , lc , resetBackoff ); err  !=  nil  &&  err  !=  io .EOF  {
339+ 				if  err  =  l .handler (linkType , options , lc , resetBackoff ,  false ); err  !=  nil  &&  err  !=  io .EOF  {
340340					l .core .log .Debugf ("Link %s error: %s\n " , info .uri , err )
341341				}
342342
@@ -395,7 +395,7 @@ func (l *links) remove(u *url.URL, sintf string, _ linkType) error {
395395	return  retErr 
396396}
397397
398- func  (l  * links ) listen (u  * url.URL , sintf  string ) (* Listener , error ) {
398+ func  (l  * links ) listen (u  * url.URL , sintf  string ,  local   bool ) (* Listener , error ) {
399399	ctx , cancel  :=  context .WithCancel (l .core .ctx )
400400	var  protocol  linkProtocol 
401401	switch  strings .ToLower (u .Scheme ) {
@@ -522,7 +522,7 @@ func (l *links) listen(u *url.URL, sintf string) (*Listener, error) {
522522
523523				// Give the connection to the handler. The handler will block 
524524				// for the lifetime of the connection. 
525- 				switch  err  =  l .handler (linkTypeIncoming , options , lc , nil ); {
525+ 				switch  err  =  l .handler (linkTypeIncoming , options , lc , nil ,  local ); {
526526				case  err  ==  nil :
527527				case  errors .Is (err , io .EOF ):
528528				case  errors .Is (err , net .ErrClosed ):
@@ -563,7 +563,7 @@ func (l *links) connect(ctx context.Context, u *url.URL, info linkInfo, options
563563	return  dialer .dial (ctx , u , info , options )
564564}
565565
566- func  (l  * links ) handler (linkType  linkType , options  linkOptions , conn  net.Conn , success  func ()) error  {
566+ func  (l  * links ) handler (linkType  linkType , options  linkOptions , conn  net.Conn , success  func (),  local   bool ) error  {
567567	meta  :=  version_getBaseMetadata ()
568568	meta .publicKey  =  l .core .public 
569569	meta .priority  =  options .priority 
@@ -606,19 +606,21 @@ func (l *links) handler(linkType linkType, options linkOptions, conn net.Conn, s
606606		}
607607	}
608608	// Check if we're authorized to connect to this key / IP 
609- 	var  allowed  map [[32 ]byte ]struct {}
610- 	phony .Block (l .core , func () {
611- 		allowed  =  l .core .config ._allowedPublicKeys 
612- 	})
613- 	isallowed  :=  len (allowed ) ==  0 
614- 	for  k  :=  range  allowed  {
615- 		if  bytes .Equal (k [:], meta .publicKey ) {
616- 			isallowed  =  true 
617- 			break 
609+ 	if  ! local  {
610+ 		var  allowed  map [[32 ]byte ]struct {}
611+ 		phony .Block (l .core , func () {
612+ 			allowed  =  l .core .config ._allowedPublicKeys 
613+ 		})
614+ 		isallowed  :=  len (allowed ) ==  0 
615+ 		for  k  :=  range  allowed  {
616+ 			if  bytes .Equal (k [:], meta .publicKey ) {
617+ 				isallowed  =  true 
618+ 				break 
619+ 			}
620+ 		}
621+ 		if  linkType  ==  linkTypeIncoming  &&  ! isallowed  {
622+ 			return  fmt .Errorf ("node public key %q is not in AllowedPublicKeys" , hex .EncodeToString (meta .publicKey ))
618623		}
619- 	}
620- 	if  linkType  ==  linkTypeIncoming  &&  ! isallowed  {
621- 		return  fmt .Errorf ("node public key %q is not in AllowedPublicKeys" , hex .EncodeToString (meta .publicKey ))
622624	}
623625
624626	dir  :=  "outbound" 
0 commit comments