mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	No DEBUG_ calls from src/yggdrasil
This commit is contained in:
		
							parent
							
								
									eac1c85a62
								
							
						
					
					
						commit
						196a14d8d2
					
				
					 5 changed files with 47 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -360,11 +360,11 @@ func (a *admin) addPeer(addr string) error {
 | 
			
		|||
	if err == nil {
 | 
			
		||||
		switch strings.ToLower(u.Scheme) {
 | 
			
		||||
		case "tcp":
 | 
			
		||||
			a.core.DEBUG_addTCPConn(u.Host)
 | 
			
		||||
			a.core.tcp.connect(u.Host)
 | 
			
		||||
		case "udp":
 | 
			
		||||
			a.core.DEBUG_maybeSendUDPKeys(u.Host)
 | 
			
		||||
			a.core.udp.connect(u.Host)
 | 
			
		||||
		case "socks":
 | 
			
		||||
			a.core.DEBUG_addSOCKSConn(u.Host, u.Path[1:])
 | 
			
		||||
			a.core.tcp.connectSOCKS(u.Host, u.Path[1:])
 | 
			
		||||
		default:
 | 
			
		||||
			return errors.New("invalid peer: " + addr)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -372,13 +372,13 @@ func (a *admin) addPeer(addr string) error {
 | 
			
		|||
		// no url scheme provided
 | 
			
		||||
		addr = strings.ToLower(addr)
 | 
			
		||||
		if strings.HasPrefix(addr, "udp:") {
 | 
			
		||||
			a.core.DEBUG_maybeSendUDPKeys(addr[4:])
 | 
			
		||||
			a.core.udp.connect(addr[4:])
 | 
			
		||||
			return nil
 | 
			
		||||
		} else {
 | 
			
		||||
			if strings.HasPrefix(addr, "tcp:") {
 | 
			
		||||
				addr = addr[4:]
 | 
			
		||||
			}
 | 
			
		||||
			a.core.DEBUG_addTCPConn(addr)
 | 
			
		||||
			a.core.tcp.connect(addr)
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
		return errors.New("invalid peer: " + addr)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,5 @@
 | 
			
		|||
// +build !linux,!darwin,!windows,!openbsd,!freebsd,!netbsd
 | 
			
		||||
 | 
			
		||||
package yggdrasil
 | 
			
		||||
 | 
			
		||||
// These are functions that should not exist
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ func (m *multicast) start() error {
 | 
			
		|||
		go m.listen()
 | 
			
		||||
		go m.announce()
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
  return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *multicast) announce() {
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +152,7 @@ func (m *multicast) listen() {
 | 
			
		|||
		saddr := addr.String()
 | 
			
		||||
		//if _, isIn := n.peers[saddr]; isIn { continue }
 | 
			
		||||
		//n.peers[saddr] = struct{}{}
 | 
			
		||||
		m.core.DEBUG_addTCPConn(saddr)
 | 
			
		||||
		m.core.tcp.connect(saddr)
 | 
			
		||||
		//fmt.Println("DEBUG:", "added multicast peer:", saddr)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ import "errors"
 | 
			
		|||
import "sync"
 | 
			
		||||
import "fmt"
 | 
			
		||||
import "bufio"
 | 
			
		||||
import "golang.org/x/net/proxy"
 | 
			
		||||
 | 
			
		||||
const tcp_msgSize = 2048 + 65535 // TODO figure out what makes sense
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +47,28 @@ func (iface *tcpInterface) getAddr() *net.TCPAddr {
 | 
			
		|||
	return iface.serv.Addr().(*net.TCPAddr)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *tcpInterface) connect(addr string) {
 | 
			
		||||
	iface.call(addr)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *tcpInterface) connectSOCKS(socksaddr, peeraddr string) {
 | 
			
		||||
	go func() {
 | 
			
		||||
		dialer, err := proxy.SOCKS5("tcp", socksaddr, nil, proxy.Direct)
 | 
			
		||||
		if err == nil {
 | 
			
		||||
			conn, err := dialer.Dial("tcp", peeraddr)
 | 
			
		||||
			if err == nil {
 | 
			
		||||
				iface.callWithConn(&wrappedConn{
 | 
			
		||||
					c: conn,
 | 
			
		||||
					raddr: &wrappedAddr{
 | 
			
		||||
						network: "tcp",
 | 
			
		||||
						addr:    peeraddr,
 | 
			
		||||
					},
 | 
			
		||||
				})
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *tcpInterface) init(core *Core, addr string) (err error) {
 | 
			
		||||
	iface.core = core
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,21 @@ func (iface *udpInterface) getAddr() *net.UDPAddr {
 | 
			
		|||
	return iface.sock.LocalAddr().(*net.UDPAddr)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *udpInterface) connect(saddr string) {
 | 
			
		||||
	udpAddr, err := net.ResolveUDPAddr("udp", saddr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
	var addr connAddr
 | 
			
		||||
	addr.fromUDPAddr(udpAddr)
 | 
			
		||||
	iface.mutex.RLock()
 | 
			
		||||
	_, isIn := iface.conns[addr]
 | 
			
		||||
	iface.mutex.RUnlock()
 | 
			
		||||
	if !isIn {
 | 
			
		||||
		iface.sendKeys(addr)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *udpInterface) init(core *Core, addr string) error {
 | 
			
		||||
	iface.core = core
 | 
			
		||||
	udpAddr, err := net.ResolveUDPAddr("udp", addr)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue