mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-23 00:35:39 +00:00
Fix RetryPeersNow
, move startup logging, don't set TUN address if not available
This commit is contained in:
parent
955aa4af79
commit
094f80f39c
@ -205,6 +205,10 @@ func main() {
|
|||||||
if n.core, err = core.New(cfg.Certificate, logger, options...); err != nil {
|
if n.core, err = core.New(cfg.Certificate, logger, options...); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
address, subnet := n.core.Address(), n.core.Subnet()
|
||||||
|
logger.Infof("Your public key is %s", hex.EncodeToString(n.core.PublicKey()))
|
||||||
|
logger.Infof("Your IPv6 address is %s", address.String())
|
||||||
|
logger.Infof("Your IPv6 subnet is %s", subnet.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the admin socket.
|
// Setup the admin socket.
|
||||||
|
@ -78,6 +78,10 @@ func (m *Yggdrasil) StartJSON(configjson []byte) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
address, subnet := m.core.Address(), m.core.Subnet()
|
||||||
|
logger.Infof("Your public key is %s", hex.EncodeToString(m.core.PublicKey()))
|
||||||
|
logger.Infof("Your IPv6 address is %s", address.String())
|
||||||
|
logger.Infof("Your IPv6 subnet is %s", subnet.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the multicast module.
|
// Setup the multicast module.
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -104,10 +103,6 @@ func New(cert *tls.Certificate, logger Logger, opts ...SetupOption) (*Core, erro
|
|||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, fmt.Errorf("error creating encryption: %w", err)
|
return nil, fmt.Errorf("error creating encryption: %w", err)
|
||||||
}
|
}
|
||||||
address, subnet := c.Address(), c.Subnet()
|
|
||||||
c.log.Infof("Your public key is %s", hex.EncodeToString(c.public))
|
|
||||||
c.log.Infof("Your IPv6 address is %s", address.String())
|
|
||||||
c.log.Infof("Your IPv6 subnet is %s", subnet.String())
|
|
||||||
c.proto.init(c)
|
c.proto.init(c)
|
||||||
if err := c.links.init(c); err != nil {
|
if err := c.links.init(c); err != nil {
|
||||||
return nil, fmt.Errorf("error initialising links: %w", err)
|
return nil, fmt.Errorf("error initialising links: %w", err)
|
||||||
@ -140,7 +135,14 @@ func New(cert *tls.Certificate, logger Logger, opts ...SetupOption) (*Core, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) RetryPeersNow() {
|
func (c *Core) RetryPeersNow() {
|
||||||
// TODO: figure out a way to retrigger peer connections.
|
phony.Block(&c.links, func() {
|
||||||
|
for _, l := range c.links._links {
|
||||||
|
select {
|
||||||
|
case l.kick <- struct{}{}:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop shuts down the Yggdrasil node.
|
// Stop shuts down the Yggdrasil node.
|
||||||
|
@ -116,7 +116,10 @@ func (tun *TunAdapter) _start() error {
|
|||||||
tun.addr = tun.rwc.Address()
|
tun.addr = tun.rwc.Address()
|
||||||
tun.subnet = tun.rwc.Subnet()
|
tun.subnet = tun.rwc.Subnet()
|
||||||
prefix := address.GetPrefix()
|
prefix := address.GetPrefix()
|
||||||
addr := fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(prefix[:])-1)
|
var addr string
|
||||||
|
if tun.addr.IsValid() {
|
||||||
|
addr = fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(prefix[:])-1)
|
||||||
|
}
|
||||||
if tun.config.name == "none" || tun.config.name == "dummy" {
|
if tun.config.name == "none" || tun.config.name == "dummy" {
|
||||||
tun.log.Debugln("Not starting TUN as ifname is none or dummy")
|
tun.log.Debugln("Not starting TUN as ifname is none or dummy")
|
||||||
tun.isEnabled = false
|
tun.isEnabled = false
|
||||||
|
@ -86,8 +86,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
|||||||
} else {
|
} else {
|
||||||
tun.mtu = 0
|
tun.mtu = 0
|
||||||
}
|
}
|
||||||
|
if addr != "" {
|
||||||
return tun.setupAddress(addr)
|
return tun.setupAddress(addr)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Configures the "utun" adapter from an existing file descriptor.
|
// Configures the "utun" adapter from an existing file descriptor.
|
||||||
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
||||||
|
@ -32,8 +32,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
|||||||
} else {
|
} else {
|
||||||
tun.mtu = 0
|
tun.mtu = 0
|
||||||
}
|
}
|
||||||
|
if addr != "" {
|
||||||
return tun.setupAddress(addr)
|
return tun.setupAddress(addr)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Configures the "utun" adapter from an existing file descriptor.
|
// Configures the "utun" adapter from an existing file descriptor.
|
||||||
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
||||||
|
@ -27,8 +27,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
|||||||
} else {
|
} else {
|
||||||
tun.mtu = 0
|
tun.mtu = 0
|
||||||
}
|
}
|
||||||
|
if addr != "" {
|
||||||
return tun.setupAddress(addr)
|
return tun.setupAddress(addr)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Configures the "utun" adapter from an existing file descriptor.
|
// Configures the "utun" adapter from an existing file descriptor.
|
||||||
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
||||||
|
@ -24,8 +24,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
|||||||
} else {
|
} else {
|
||||||
tun.mtu = 0
|
tun.mtu = 0
|
||||||
}
|
}
|
||||||
|
if addr != "" {
|
||||||
return tun.setupAddress(addr)
|
return tun.setupAddress(addr)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Configures the "utun" adapter from an existing file descriptor.
|
// Configures the "utun" adapter from an existing file descriptor.
|
||||||
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error {
|
||||||
|
@ -35,10 +35,12 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tun.iface = iface
|
tun.iface = iface
|
||||||
|
if addr != "" {
|
||||||
if err = tun.setupAddress(addr); err != nil {
|
if err = tun.setupAddress(addr); err != nil {
|
||||||
tun.log.Errorln("Failed to set up TUN address:", err)
|
tun.log.Errorln("Failed to set up TUN address:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err = tun.setupMTU(getSupportedMTU(mtu)); err != nil {
|
if err = tun.setupMTU(getSupportedMTU(mtu)); err != nil {
|
||||||
tun.log.Errorln("Failed to set up TUN MTU:", err)
|
tun.log.Errorln("Failed to set up TUN MTU:", err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user