mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Break out multicast into a separate package
This commit is contained in:
parent
03bc7bbcd6
commit
7ea4e9575e
10 changed files with 103 additions and 71 deletions
|
@ -40,9 +40,9 @@ type Core struct {
|
|||
dht dht
|
||||
admin admin
|
||||
searches searches
|
||||
multicast multicast
|
||||
link link
|
||||
log *log.Logger
|
||||
//multicast multicast
|
||||
link link
|
||||
log *log.Logger
|
||||
}
|
||||
|
||||
func (c *Core) init() error {
|
||||
|
@ -82,7 +82,7 @@ func (c *Core) init() error {
|
|||
c.searches.init(c)
|
||||
c.dht.init(c)
|
||||
c.sessions.init(c)
|
||||
c.multicast.init(c)
|
||||
//c.multicast.init(c)
|
||||
c.peers.init(c)
|
||||
c.router.init(c)
|
||||
c.switchTable.init(c) // TODO move before peers? before router?
|
||||
|
@ -137,7 +137,7 @@ func (c *Core) UpdateConfig(config *config.NodeConfig) {
|
|||
c.router.cryptokey.reconfigure,
|
||||
c.switchTable.reconfigure,
|
||||
c.link.reconfigure,
|
||||
c.multicast.reconfigure,
|
||||
//c.multicast.reconfigure,
|
||||
}
|
||||
|
||||
for _, component := range components {
|
||||
|
@ -228,10 +228,10 @@ func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := c.multicast.start(); err != nil {
|
||||
/*if err := c.multicast.start(); err != nil {
|
||||
c.log.Errorln("Failed to start multicast interface")
|
||||
return err
|
||||
}
|
||||
}*/
|
||||
|
||||
if err := c.router.tun.Start(c.router.addr, c.router.subnet); err != nil {
|
||||
c.log.Errorln("Failed to start TUN/TAP")
|
||||
|
@ -251,6 +251,11 @@ func (c *Core) Stop() {
|
|||
c.admin.close()
|
||||
}
|
||||
|
||||
// ListenOn starts a new listener
|
||||
func (c *Core) ListenTCP(uri string) (*TcpListener, error) {
|
||||
return c.link.tcp.listen(uri)
|
||||
}
|
||||
|
||||
// Generates a new encryption keypair. The encryption keys are used to
|
||||
// encrypt traffic and to derive the IPv6 address/subnet of the node.
|
||||
func (c *Core) NewEncryptionKeys() (*crypto.BoxPubKey, *crypto.BoxPrivKey) {
|
||||
|
@ -303,11 +308,20 @@ func (c *Core) SetLogger(log *log.Logger) {
|
|||
}
|
||||
|
||||
// Adds a peer. This should be specified in the peer URI format, i.e.
|
||||
// tcp://a.b.c.d:e, udp://a.b.c.d:e, socks://a.b.c.d:e/f.g.h.i:j
|
||||
// tcp://a.b.c.d:e, udp://a.b.c.d:e, socks://a.b.c.d:e/f.g.h.i:j. This adds the
|
||||
// peer to the peer list, so that they will be called again if the connection
|
||||
// drops.
|
||||
func (c *Core) AddPeer(addr string, sintf string) error {
|
||||
return c.admin.addPeer(addr, sintf)
|
||||
}
|
||||
|
||||
// Calls a peer. This should be specified in the peer URI format, i.e.
|
||||
// tcp://a.b.c.d:e, udp://a.b.c.d:e, socks://a.b.c.d:e/f.g.h.i:j. This calls the
|
||||
// peer once, and if the connection drops, it won't be called again.
|
||||
func (c *Core) CallPeer(addr string, sintf string) error {
|
||||
return c.link.call(addr, sintf)
|
||||
}
|
||||
|
||||
// Adds an allowed public key. This allow peerings to be restricted only to
|
||||
// keys that you have selected.
|
||||
func (c *Core) AddAllowedEncryptionPublicKey(boxStr string) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue