mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Correctly classify link-local addresses in the TCP handler, fix AllowedPublicEncryptionKeys warning
This commit is contained in:
		
							parent
							
								
									c388885a92
								
							
						
					
					
						commit
						dc3a05f13a
					
				
					 2 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -176,7 +176,7 @@ func (intf *linkInterface) handler() error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Check if we're authorized to connect to this key / IP
 | 
						// Check if we're authorized to connect to this key / IP
 | 
				
			||||||
	if intf.incoming && !intf.force && !intf.link.core.peers.isAllowedEncryptionPublicKey(&meta.box) {
 | 
						if intf.incoming && !intf.force && !intf.link.core.peers.isAllowedEncryptionPublicKey(&meta.box) {
 | 
				
			||||||
		intf.link.core.log.Warnf("%s connection to %s forbidden: AllowedEncryptionPublicKeys does not contain key %s",
 | 
							intf.link.core.log.Warnf("%s connection from %s forbidden: AllowedEncryptionPublicKeys does not contain key %s",
 | 
				
			||||||
			strings.ToUpper(intf.info.linkType), intf.info.remote, hex.EncodeToString(meta.box[:]))
 | 
								strings.ToUpper(intf.info.linkType), intf.info.remote, hex.EncodeToString(meta.box[:]))
 | 
				
			||||||
		intf.msgIO.close()
 | 
							intf.msgIO.close()
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -332,7 +333,7 @@ func (t *tcp) handler(sock net.Conn, incoming bool, options interface{}) {
 | 
				
			||||||
	stream.init(sock)
 | 
						stream.init(sock)
 | 
				
			||||||
	local, _, _ := net.SplitHostPort(sock.LocalAddr().String())
 | 
						local, _, _ := net.SplitHostPort(sock.LocalAddr().String())
 | 
				
			||||||
	remote, _, _ := net.SplitHostPort(sock.RemoteAddr().String())
 | 
						remote, _, _ := net.SplitHostPort(sock.RemoteAddr().String())
 | 
				
			||||||
	remotelinklocal := net.ParseIP(remote).IsLinkLocalUnicast()
 | 
						force := net.ParseIP(strings.Split(remote, "%")[0]).IsLinkLocalUnicast()
 | 
				
			||||||
	var name string
 | 
						var name string
 | 
				
			||||||
	var proto string
 | 
						var proto string
 | 
				
			||||||
	if socksaddr, issocks := options.(string); issocks {
 | 
						if socksaddr, issocks := options.(string); issocks {
 | 
				
			||||||
| 
						 | 
					@ -342,7 +343,7 @@ func (t *tcp) handler(sock net.Conn, incoming bool, options interface{}) {
 | 
				
			||||||
		name = "tcp://" + sock.RemoteAddr().String()
 | 
							name = "tcp://" + sock.RemoteAddr().String()
 | 
				
			||||||
		proto = "tcp"
 | 
							proto = "tcp"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	link, err := t.link.core.link.create(&stream, name, proto, local, remote, incoming, remotelinklocal)
 | 
						link, err := t.link.core.link.create(&stream, name, proto, local, remote, incoming, force)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.link.core.log.Println(err)
 | 
							t.link.core.log.Println(err)
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue