5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-26 07:11:40 +00: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:
Arceliar 2018-05-27 12:56:33 -05:00
parent e62cfa8c84
commit 7b12493417
2 changed files with 12 additions and 9 deletions

View File

@ -284,9 +284,10 @@ func (c *Core) DEBUG_init(bpub []byte,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
func (c *Core) DEBUG_setupAndStartGlobalUDPInterface(addrport string) { func (c *Core) DEBUG_setupAndStartGlobalUDPInterface(addrport string) {
iface := udpInterface{} if err := c.udp.init(c, addrport); err != nil {
iface.init(c, addrport) c.log.Println("Failed to start UDP interface:", err)
c.udp = &iface panic(err)
}
} }
func (c *Core) DEBUG_getGlobalUDPAddr() *net.UDPAddr { 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) { func (c *Core) DEBUG_setupAndStartGlobalTCPInterface(addrport string) {
iface := tcpInterface{} if err := c.tcp.init(c, addrport); err != nil {
iface.init(c, addrport) c.log.Println("Failed to start TCP interface:", err)
c.tcp = &iface panic(err)
}
} }
func (c *Core) DEBUG_getGlobalTCPAddr() *net.TCPAddr { func (c *Core) DEBUG_getGlobalTCPAddr() *net.TCPAddr {

View File

@ -65,18 +65,19 @@ type udpKeys struct {
sig sigPubKey sig sigPubKey
} }
func (iface *udpInterface) init(core *Core, addr string) { func (iface *udpInterface) init(core *Core, addr string) (err error) {
iface.core = core iface.core = core
udpAddr, err := net.ResolveUDPAddr("udp", addr) udpAddr, err := net.ResolveUDPAddr("udp", addr)
if err != nil { if err != nil {
panic(err) return
} }
iface.sock, err = net.ListenUDP("udp", udpAddr) iface.sock, err = net.ListenUDP("udp", udpAddr)
if err != nil { if err != nil {
panic(err) return
} }
iface.conns = make(map[connAddr]*connInfo) iface.conns = make(map[connAddr]*connInfo)
go iface.reader() go iface.reader()
return
} }
func (iface *udpInterface) sendKeys(addr connAddr) { func (iface *udpInterface) sendKeys(addr connAddr) {