From 3c4fee0492b870362b150a9cef4586c92dc6c535 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 19 Apr 2018 10:30:40 -0400 Subject: [PATCH 1/8] tor auto config --- src/yggdrasil/config/config.go | 29 ++++++++++ src/yggdrasil/config/i2p.go | 7 +++ src/yggdrasil/config/tor.go | 11 ++++ src/yggdrasil/core.go | 1 + src/yggdrasil/dial.go | 99 ++++++++++++++++++++++++++++++++++ src/yggdrasil/tcp.go | 62 ++++++++++----------- yggdrasil.go | 33 ++++-------- 7 files changed, 186 insertions(+), 56 deletions(-) create mode 100644 src/yggdrasil/config/config.go create mode 100644 src/yggdrasil/config/i2p.go create mode 100644 src/yggdrasil/config/tor.go create mode 100644 src/yggdrasil/dial.go diff --git a/src/yggdrasil/config/config.go b/src/yggdrasil/config/config.go new file mode 100644 index 0000000..0861f61 --- /dev/null +++ b/src/yggdrasil/config/config.go @@ -0,0 +1,29 @@ +package config + +/** +* This is a very crude wrapper around src/yggdrasil +* It can generate a new config (--genconf) +* It can read a config from stdin (--useconf) +* It can run with an automatic config (--autoconf) + */ + +type NodeConfig struct { + Listen string + AdminListen string + Peers []string + BoxPub string + BoxPriv string + SigPub string + SigPriv string + Multicast bool + LinkLocal string + IfName string + IfTAPMode bool + IfMTU int + Net NetConfig +} + +type NetConfig struct { + Tor TorConfig + I2P I2PConfig +} diff --git a/src/yggdrasil/config/i2p.go b/src/yggdrasil/config/i2p.go new file mode 100644 index 0000000..375d413 --- /dev/null +++ b/src/yggdrasil/config/i2p.go @@ -0,0 +1,7 @@ +package config + +type I2PConfig struct { + Keyfile string + Addr string + Enabled bool +} diff --git a/src/yggdrasil/config/tor.go b/src/yggdrasil/config/tor.go new file mode 100644 index 0000000..aceb885 --- /dev/null +++ b/src/yggdrasil/config/tor.go @@ -0,0 +1,11 @@ +package config + +/** +*tor specific configuration + */ +type TorConfig struct { + OnionKeyfile string + SocksAddr string + UseForAll bool + Enabled bool +} diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index be0c6ae..d68a601 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -19,6 +19,7 @@ type Core struct { tun tunDevice admin admin searches searches + Dialer Dialer tcp *tcpInterface udp *udpInterface log *log.Logger diff --git a/src/yggdrasil/dial.go b/src/yggdrasil/dial.go new file mode 100644 index 0000000..d9249a6 --- /dev/null +++ b/src/yggdrasil/dial.go @@ -0,0 +1,99 @@ +package yggdrasil + +import ( + "errors" + "golang.org/x/net/proxy" + "net" + "strings" + "time" + "yggdrasil/config" +) + +type Dialer = proxy.Dialer + +type muxedDialer struct { + conf config.NetConfig + tor Dialer + direct Dialer +} + +type wrappedConn struct { + c net.Conn + raddr net.Addr +} + +type wrappedAddr struct { + network string + addr string +} + +func (a *wrappedAddr) Network() string { + return a.network +} + +func (a *wrappedAddr) String() string { + return a.addr +} + +func (c *wrappedConn) Write(data []byte) (int, error) { + return c.c.Write(data) +} + +func (c *wrappedConn) Read(data []byte) (int, error) { + return c.c.Read(data) +} + +func (c *wrappedConn) SetDeadline(t time.Time) error { + return c.c.SetDeadline(t) +} + +func (c *wrappedConn) SetReadDeadline(t time.Time) error { + return c.c.SetReadDeadline(t) +} + +func (c *wrappedConn) SetWriteDeadline(t time.Time) error { + return c.c.SetWriteDeadline(t) +} + +func (c *wrappedConn) Close() error { + return c.c.Close() +} + +func (c *wrappedConn) LocalAddr() net.Addr { + return c.c.LocalAddr() +} + +func (c *wrappedConn) RemoteAddr() net.Addr { + return c.raddr +} + +func (d *muxedDialer) Dial(network, addr string) (net.Conn, error) { + host, _, _ := net.SplitHostPort(addr) + if d.conf.Tor.UseForAll || strings.HasSuffix(host, ".onion") { + if !d.conf.Tor.Enabled { + return nil, errors.New("tor not enabled") + } + c, err := d.tor.Dial(network, addr) + if err == nil { + c = &wrappedConn{ + c: c, + raddr: &wrappedAddr{ + network: network, + addr: addr, + }, + } + } + return c, err + } else { + return d.direct.Dial(network, addr) + } +} + +func NewDialer(c config.NetConfig) Dialer { + tor, _ := proxy.SOCKS5("tcp", c.Tor.SocksAddr, nil, proxy.Direct) + return &muxedDialer{ + conf: c, + tor: tor, + direct: proxy.Direct, + } +} diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 972d1ca..23fa712 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -19,9 +19,17 @@ import "bufio" const tcp_msgSize = 2048 + 65535 // TODO figure out what makes sense +// wrapper function for non tcp/ip connections +func setNoDelay(c net.Conn, delay bool) { + tcp, ok := c.(*net.TCPConn) + if ok { + tcp.SetNoDelay(delay) + } +} + type tcpInterface struct { core *Core - serv *net.TCPListener + serv net.Listener mutex sync.Mutex // Protecting the below calls map[string]struct{} conns map[tcpInfo](chan struct{}) @@ -30,30 +38,27 @@ type tcpInterface struct { type tcpInfo struct { box boxPubKey sig sigPubKey - localAddr string // net.IPAddr.String(), not TCPAddr, don't care about port - remoteAddr string + localAddr net.Addr + remoteAddr net.Addr } -func (iface *tcpInterface) init(core *Core, addr string) { +func (iface *tcpInterface) init(core *Core, addr string) (err error) { iface.core = core - tcpAddr, err := net.ResolveTCPAddr("tcp", addr) - if err != nil { - panic(err) + + iface.serv, err = net.Listen("tcp", addr) + if err == nil { + iface.calls = make(map[string]struct{}) + iface.conns = make(map[tcpInfo](chan struct{})) + go iface.listener() } - iface.serv, err = net.ListenTCP("tcp", tcpAddr) - if err != nil { - panic(err) - } - iface.calls = make(map[string]struct{}) - iface.conns = make(map[tcpInfo](chan struct{})) - go iface.listener() + return } func (iface *tcpInterface) listener() { defer iface.serv.Close() iface.core.log.Println("Listening for TCP on:", iface.serv.Addr().String()) for { - sock, err := iface.serv.AcceptTCP() + sock, err := iface.serv.Accept() if err != nil { panic(err) } @@ -77,17 +82,16 @@ func (iface *tcpInterface) call(saddr string) { } iface.mutex.Unlock() if !quit { - conn, err := net.DialTimeout("tcp", saddr, 6*time.Second) + conn, err := iface.core.Dialer.Dial("tcp", saddr) if err != nil { return } - sock := conn.(*net.TCPConn) - iface.handler(sock) + iface.handler(conn) } }() } -func (iface *tcpInterface) handler(sock *net.TCPConn) { +func (iface *tcpInterface) handler(sock net.Conn) { defer sock.Close() // Get our keys keys := []byte{} @@ -127,18 +131,8 @@ func (iface *tcpInterface) handler(sock *net.TCPConn) { return } // Check if we already have a connection to this node, close and block if yes - local := sock.LocalAddr().(*net.TCPAddr) - laddr := net.IPAddr{ - IP: local.IP, - Zone: local.Zone, - } - info.localAddr = laddr.String() - remote := sock.RemoteAddr().(*net.TCPAddr) - raddr := net.IPAddr{ - IP: remote.IP, - Zone: remote.Zone, - } - info.remoteAddr = raddr.String() + info.localAddr = sock.LocalAddr() + info.remoteAddr = sock.RemoteAddr() iface.mutex.Lock() if blockChan, isIn := iface.conns[info]; isIn { iface.mutex.Unlock() @@ -224,7 +218,7 @@ func (iface *tcpInterface) handler(sock *net.TCPConn) { util_putBytes(msg) } } - sock.SetNoDelay(true) + setNoDelay(sock, true) go p.linkLoop(linkIn) defer func() { // Put all of our cleanup here... @@ -239,7 +233,7 @@ func (iface *tcpInterface) handler(sock *net.TCPConn) { p.core.peers.mutex.Unlock() close(linkIn) }() - them := sock.RemoteAddr().(*net.TCPAddr) + them := sock.RemoteAddr() themNodeID := getNodeID(&info.box) themAddr := address_addrForNodeID(themNodeID) themAddrString := net.IP(themAddr[:]).String() @@ -250,7 +244,7 @@ func (iface *tcpInterface) handler(sock *net.TCPConn) { return } -func (iface *tcpInterface) reader(sock *net.TCPConn, in func([]byte)) { +func (iface *tcpInterface) reader(sock net.Conn, in func([]byte)) { bs := make([]byte, 2*tcp_msgSize) frag := bs[:0] for { diff --git a/yggdrasil.go b/yggdrasil.go index c52964f..85328fc 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -21,31 +21,13 @@ import "runtime" import "golang.org/x/net/ipv6" -import . "yggdrasil" +import "yggdrasil" +import "yggdrasil/config" import "github.com/kardianos/minwinsvc" -/** -* This is a very crude wrapper around src/yggdrasil -* It can generate a new config (--genconf) -* It can read a config from stdin (--useconf) -* It can run with an automatic config (--autoconf) - */ - -type nodeConfig struct { - Listen string - AdminListen string - Peers []string - BoxPub string - BoxPriv string - SigPub string - SigPriv string - Multicast bool - LinkLocal string - IfName string - IfTAPMode bool - IfMTU int -} +type nodeConfig = config.NodeConfig +type Core = yggdrasil.Core type node struct { core Core @@ -76,6 +58,9 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) { panic(err) } n.core.DEBUG_setIfceExpr(ifceExpr) + + n.core.Dialer = yggdrasil.NewDialer(cfg.Net) + logger.Println("Starting interface...") n.core.DEBUG_setupAndStartGlobalTCPInterface(cfg.Listen) // Listen for peers on TCP n.core.DEBUG_setupAndStartGlobalUDPInterface(cfg.Listen) // Also listen on UDP, TODO allow separate configuration for ip/port to listen on each of these @@ -126,6 +111,10 @@ func generateConfig(isAutoconf bool) *nodeConfig { cfg.IfName = core.DEBUG_GetTUNDefaultIfName() cfg.IfMTU = core.DEBUG_GetTUNDefaultIfMTU() cfg.IfTAPMode = core.DEBUG_GetTUNDefaultIfTAPMode() + + cfg.Net.Tor.SocksAddr = "127.0.0.1:9050" + cfg.Net.Tor.UseForAll = false + cfg.Net.Tor.Enabled = true return &cfg } From 5e23185ddcbb6f7ecdfde05853a690040bb64b85 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 20 Apr 2018 08:41:09 -0400 Subject: [PATCH 2/8] use address only not port --- src/yggdrasil/tcp.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 23fa712..563178f 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -38,8 +38,8 @@ type tcpInterface struct { type tcpInfo struct { box boxPubKey sig sigPubKey - localAddr net.Addr - remoteAddr net.Addr + localAddr string + remoteAddr string } func (iface *tcpInterface) init(core *Core, addr string) (err error) { @@ -131,8 +131,8 @@ func (iface *tcpInterface) handler(sock net.Conn) { return } // Check if we already have a connection to this node, close and block if yes - info.localAddr = sock.LocalAddr() - info.remoteAddr = sock.RemoteAddr() + info.localAddr, _, _ = net.SplitHostPort(sock.LocalAddr().String()) + info.remoteAddr, _, _ = net.SplitHostPort(sock.RemoteAddr().String()) iface.mutex.Lock() if blockChan, isIn := iface.conns[info]; isIn { iface.mutex.Unlock() @@ -233,7 +233,7 @@ func (iface *tcpInterface) handler(sock net.Conn) { p.core.peers.mutex.Unlock() close(linkIn) }() - them := sock.RemoteAddr() + them, _, _ := net.SplitHostPort(sock.RemoteAddr().String()) themNodeID := getNodeID(&info.box) themAddr := address_addrForNodeID(themNodeID) themAddrString := net.IP(themAddr[:]).String() From de69860e9bb1a5e9a6fd65b5a55e7cf2a381a081 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 25 Apr 2018 10:06:13 -0400 Subject: [PATCH 3/8] * only enable tor proxy dialer when tor is enabled * add docstrings --- src/yggdrasil/dial.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/yggdrasil/dial.go b/src/yggdrasil/dial.go index d9249a6..5269c16 100644 --- a/src/yggdrasil/dial.go +++ b/src/yggdrasil/dial.go @@ -11,17 +11,20 @@ import ( type Dialer = proxy.Dialer +// muxedDialer implements proxy.Dialer (aka Dialer) type muxedDialer struct { conf config.NetConfig tor Dialer direct Dialer } +// wrappedConn implements net.Conn type wrappedConn struct { c net.Conn raddr net.Addr } +// wrappedAddr implements net.Addr type wrappedAddr struct { network string addr string @@ -89,11 +92,16 @@ func (d *muxedDialer) Dial(network, addr string) (net.Conn, error) { } } +// NewDialer creates a Dialer from a NetConfig func NewDialer(c config.NetConfig) Dialer { - tor, _ := proxy.SOCKS5("tcp", c.Tor.SocksAddr, nil, proxy.Direct) - return &muxedDialer{ - conf: c, - tor: tor, - direct: proxy.Direct, + if c.Tor.Enabled { + tor, _ := proxy.SOCKS5("tcp", c.Tor.SocksAddr, nil, proxy.Direct) + return &muxedDialer{ + conf: c, + tor: tor, + direct: proxy.Direct, + } + } else { + return proxy.Direct } } From 1be8bbed1c8f1682f0d433c9cf1113ffc486ffb6 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 25 Apr 2018 10:09:09 -0400 Subject: [PATCH 4/8] more docs --- src/yggdrasil/config/i2p.go | 5 +++-- src/yggdrasil/config/tor.go | 12 +++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/yggdrasil/config/i2p.go b/src/yggdrasil/config/i2p.go index 375d413..0ee4a2b 100644 --- a/src/yggdrasil/config/i2p.go +++ b/src/yggdrasil/config/i2p.go @@ -1,7 +1,8 @@ package config +// I2PConfig is the configuration structure for i2p related configuration type I2PConfig struct { - Keyfile string - Addr string + Keyfile string // private key file or empty string for ephemeral keys + Addr string // address of i2p api connector Enabled bool } diff --git a/src/yggdrasil/config/tor.go b/src/yggdrasil/config/tor.go index aceb885..19f612d 100644 --- a/src/yggdrasil/config/tor.go +++ b/src/yggdrasil/config/tor.go @@ -1,11 +1,9 @@ package config -/** -*tor specific configuration - */ +// TorConfig is the configuration structure for Tor Proxy related values type TorConfig struct { - OnionKeyfile string - SocksAddr string - UseForAll bool - Enabled bool + OnionKeyfile string // hidden service private key for ADD_ONION (currently unimplemented) + SocksAddr string // tor socks address + UseForAll bool // use tor proxy for all connections? + Enabled bool // use tor at all ? } From 769b058004f7b59a9d0cb97897760443afa55eeb Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 25 Apr 2018 10:11:11 -0400 Subject: [PATCH 5/8] more docs --- src/yggdrasil/config/config.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/yggdrasil/config/config.go b/src/yggdrasil/config/config.go index 0861f61..30c8d23 100644 --- a/src/yggdrasil/config/config.go +++ b/src/yggdrasil/config/config.go @@ -1,12 +1,6 @@ package config -/** -* This is a very crude wrapper around src/yggdrasil -* It can generate a new config (--genconf) -* It can read a config from stdin (--useconf) -* It can run with an automatic config (--autoconf) - */ - +// NodeConfig defines all configuration values needed to run a signle yggdrasil node type NodeConfig struct { Listen string AdminListen string @@ -23,6 +17,7 @@ type NodeConfig struct { Net NetConfig } +// NetConfig defines network/proxy related configuration values type NetConfig struct { Tor TorConfig I2P I2PConfig From 77568915102c01fa69078764359421b19c7e0764 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 26 Apr 2018 10:23:21 -0400 Subject: [PATCH 6/8] support socks proxy in peer url and decouple explicit tor/i2p routing --- src/yggdrasil/core.go | 1 - src/yggdrasil/debug.go | 52 ++++++++++++++++++++++++++++++++++++++++++ src/yggdrasil/dial.go | 49 --------------------------------------- src/yggdrasil/tcp.go | 22 +++++++++++++++++- yggdrasil.go | 11 +-------- 5 files changed, 74 insertions(+), 61 deletions(-) diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index d68a601..be0c6ae 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -19,7 +19,6 @@ type Core struct { tun tunDevice admin admin searches searches - Dialer Dialer tcp *tcpInterface udp *udpInterface log *log.Logger diff --git a/src/yggdrasil/debug.go b/src/yggdrasil/debug.go index d358bc6..dcc2581 100644 --- a/src/yggdrasil/debug.go +++ b/src/yggdrasil/debug.go @@ -8,9 +8,13 @@ package yggdrasil import _ "golang.org/x/net/ipv6" // TODO put this somewhere better +import "golang.org/x/net/proxy" + import "fmt" import "net" +import "net/url" import "log" +import "strings" import "regexp" // Core @@ -307,6 +311,54 @@ func (c *Core) DEBUG_maybeSendUDPKeys(saddr string) { //////////////////////////////////////////////////////////////////////////////// +func (c *Core) DEBUG_addPeer(addr string) { + u, err := url.Parse(addr) + if err != nil { + panic(err) + } + if len(u.Opaque) == 0 { + switch strings.ToLower(u.Scheme) { + case "tcp": + c.DEBUG_addTCPConn(u.Host) + case "udp": + c.DEBUG_maybeSendUDPKeys(u.Host) + case "socks": + c.DEBUG_addSOCKSConn(u.Host, u.Path[1:]) + default: + panic("invalid peer: " + addr) + } + } else { + // no url scheme provided + addr = strings.ToLower(addr) + if strings.HasPrefix(addr, "udp:") { + c.DEBUG_maybeSendUDPKeys(addr[4:]) + } else { + if strings.HasPrefix(addr, "tcp:") { + addr = addr[4:] + } + c.DEBUG_addTCPConn(addr) + } + } +} + +func (c *Core) DEBUG_addSOCKSConn(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 { + c.tcp.callWithConn(&wrappedConn{ + c: conn, + raddr: &wrappedAddr{ + network: "tcp", + addr: peeraddr, + }, + }) + } + } + }() +} + //* func (c *Core) DEBUG_setupAndStartGlobalTCPInterface(addrport string) { iface := tcpInterface{} diff --git a/src/yggdrasil/dial.go b/src/yggdrasil/dial.go index 5269c16..7aec419 100644 --- a/src/yggdrasil/dial.go +++ b/src/yggdrasil/dial.go @@ -1,23 +1,10 @@ package yggdrasil import ( - "errors" - "golang.org/x/net/proxy" "net" - "strings" "time" - "yggdrasil/config" ) -type Dialer = proxy.Dialer - -// muxedDialer implements proxy.Dialer (aka Dialer) -type muxedDialer struct { - conf config.NetConfig - tor Dialer - direct Dialer -} - // wrappedConn implements net.Conn type wrappedConn struct { c net.Conn @@ -69,39 +56,3 @@ func (c *wrappedConn) LocalAddr() net.Addr { func (c *wrappedConn) RemoteAddr() net.Addr { return c.raddr } - -func (d *muxedDialer) Dial(network, addr string) (net.Conn, error) { - host, _, _ := net.SplitHostPort(addr) - if d.conf.Tor.UseForAll || strings.HasSuffix(host, ".onion") { - if !d.conf.Tor.Enabled { - return nil, errors.New("tor not enabled") - } - c, err := d.tor.Dial(network, addr) - if err == nil { - c = &wrappedConn{ - c: c, - raddr: &wrappedAddr{ - network: network, - addr: addr, - }, - } - } - return c, err - } else { - return d.direct.Dial(network, addr) - } -} - -// NewDialer creates a Dialer from a NetConfig -func NewDialer(c config.NetConfig) Dialer { - if c.Tor.Enabled { - tor, _ := proxy.SOCKS5("tcp", c.Tor.SocksAddr, nil, proxy.Direct) - return &muxedDialer{ - conf: c, - tor: tor, - direct: proxy.Direct, - } - } else { - return proxy.Direct - } -} diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 563178f..d84dd34 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -66,6 +66,26 @@ func (iface *tcpInterface) listener() { } } +func (iface *tcpInterface) callWithConn(conn net.Conn) { + go func() { + raddr := conn.RemoteAddr().String() + iface.mutex.Lock() + _, isIn := iface.calls[raddr] + iface.mutex.Unlock() + if !isIn { + iface.mutex.Lock() + iface.calls[raddr] = struct{}{} + iface.mutex.Unlock() + defer func() { + iface.mutex.Lock() + delete(iface.calls, raddr) + iface.mutex.Unlock() + }() + iface.handler(conn) + } + }() +} + func (iface *tcpInterface) call(saddr string) { go func() { quit := false @@ -82,7 +102,7 @@ func (iface *tcpInterface) call(saddr string) { } iface.mutex.Unlock() if !quit { - conn, err := iface.core.Dialer.Dial("tcp", saddr) + conn, err := net.Dial("tcp", saddr) if err != nil { return } diff --git a/yggdrasil.go b/yggdrasil.go index 85328fc..15f60ac 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -59,8 +59,6 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) { } n.core.DEBUG_setIfceExpr(ifceExpr) - n.core.Dialer = yggdrasil.NewDialer(cfg.Net) - logger.Println("Starting interface...") n.core.DEBUG_setupAndStartGlobalTCPInterface(cfg.Listen) // Listen for peers on TCP n.core.DEBUG_setupAndStartGlobalUDPInterface(cfg.Listen) // Also listen on UDP, TODO allow separate configuration for ip/port to listen on each of these @@ -74,14 +72,7 @@ func (n *node) init(cfg *nodeConfig, logger *log.Logger) { } for { for _, p := range cfg.Peers { - switch { - case len(p) >= 4 && p[:4] == "udp:": - n.core.DEBUG_maybeSendUDPKeys(p[4:]) - case len(p) >= 4 && p[:4] == "tcp:": - n.core.DEBUG_addTCPConn(p[4:]) - default: - n.core.DEBUG_addTCPConn(p) - } + n.core.DEBUG_addPeer(p) time.Sleep(time.Second) } time.Sleep(time.Minute) From fe13fea1e53c15aa0cf0630ba874cb4b7e5c5ba0 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 26 Apr 2018 10:26:10 -0400 Subject: [PATCH 7/8] remove hard coded tor config options --- src/yggdrasil/config/tor.go | 5 ++--- yggdrasil.go | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/yggdrasil/config/tor.go b/src/yggdrasil/config/tor.go index 19f612d..c169cbb 100644 --- a/src/yggdrasil/config/tor.go +++ b/src/yggdrasil/config/tor.go @@ -3,7 +3,6 @@ package config // TorConfig is the configuration structure for Tor Proxy related values type TorConfig struct { OnionKeyfile string // hidden service private key for ADD_ONION (currently unimplemented) - SocksAddr string // tor socks address - UseForAll bool // use tor proxy for all connections? - Enabled bool // use tor at all ? + ControlAddr string // tor control port address + Enabled bool } diff --git a/yggdrasil.go b/yggdrasil.go index 15f60ac..30c6a79 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -103,9 +103,6 @@ func generateConfig(isAutoconf bool) *nodeConfig { cfg.IfMTU = core.DEBUG_GetTUNDefaultIfMTU() cfg.IfTAPMode = core.DEBUG_GetTUNDefaultIfTAPMode() - cfg.Net.Tor.SocksAddr = "127.0.0.1:9050" - cfg.Net.Tor.UseForAll = false - cfg.Net.Tor.Enabled = true return &cfg } From bdf9e4508211e547bd09196c20d971375cca39e9 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 27 Apr 2018 09:53:31 +0100 Subject: [PATCH 8/8] Default to previous scheme when url.Parse returns an error In response to: ``` panic: parse x.x.x.x:xxx: first path segment in URL cannot contain colon goroutine 33 [running]: yggdrasil.(*Core).DEBUG_addPeer(0x8e58000, 0x8e34080, 0x12) /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}/src/yggdrasil/debug.go:317 +0x420 main.(*node).init.func1(0x8e48000, 0x8e58000) /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}/yggdrasil.go:75 +0x70 created by main.(*node).init /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}/yggdrasil.go:69 +0x410 ``` --- src/yggdrasil/debug.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/yggdrasil/debug.go b/src/yggdrasil/debug.go index dcc2581..faa7471 100644 --- a/src/yggdrasil/debug.go +++ b/src/yggdrasil/debug.go @@ -313,10 +313,7 @@ func (c *Core) DEBUG_maybeSendUDPKeys(saddr string) { func (c *Core) DEBUG_addPeer(addr string) { u, err := url.Parse(addr) - if err != nil { - panic(err) - } - if len(u.Opaque) == 0 { + if err == nil { switch strings.ToLower(u.Scheme) { case "tcp": c.DEBUG_addTCPConn(u.Host)