mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	panic if tcp startup fails, since otherwise a nil pointer occurs in multicast. make udp do the same thing.
This commit is contained in:
		
							parent
							
								
									e62cfa8c84
								
							
						
					
					
						commit
						7b12493417
					
				
					 2 changed files with 12 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -284,9 +284,10 @@ func (c *Core) DEBUG_init(bpub []byte,
 | 
			
		|||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
func (c *Core) DEBUG_setupAndStartGlobalUDPInterface(addrport string) {
 | 
			
		||||
	iface := udpInterface{}
 | 
			
		||||
	iface.init(c, addrport)
 | 
			
		||||
	c.udp = &iface
 | 
			
		||||
	if err := c.udp.init(c, addrport); err != nil {
 | 
			
		||||
		c.log.Println("Failed to start UDP interface:", err)
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Core) DEBUG_getGlobalUDPAddr() *net.UDPAddr {
 | 
			
		||||
| 
						 | 
				
			
			@ -337,9 +338,10 @@ func (c *Core) DEBUG_addSOCKSConn(socksaddr, peeraddr string) {
 | 
			
		|||
 | 
			
		||||
//*
 | 
			
		||||
func (c *Core) DEBUG_setupAndStartGlobalTCPInterface(addrport string) {
 | 
			
		||||
	iface := tcpInterface{}
 | 
			
		||||
	iface.init(c, addrport)
 | 
			
		||||
	c.tcp = &iface
 | 
			
		||||
	if err := c.tcp.init(c, addrport); err != nil {
 | 
			
		||||
		c.log.Println("Failed to start TCP interface:", err)
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Core) DEBUG_getGlobalTCPAddr() *net.TCPAddr {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,18 +65,19 @@ type udpKeys struct {
 | 
			
		|||
	sig sigPubKey
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *udpInterface) init(core *Core, addr string) {
 | 
			
		||||
func (iface *udpInterface) init(core *Core, addr string) (err error) {
 | 
			
		||||
	iface.core = core
 | 
			
		||||
	udpAddr, err := net.ResolveUDPAddr("udp", addr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	iface.sock, err = net.ListenUDP("udp", udpAddr)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	iface.conns = make(map[connAddr]*connInfo)
 | 
			
		||||
	go iface.reader()
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (iface *udpInterface) sendKeys(addr connAddr) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue