mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 14:45:07 +03:00
Connect first peer from config on demand.
This commit is contained in:
parent
0da871f528
commit
30c83f5ec3
2 changed files with 26 additions and 0 deletions
|
@ -169,6 +169,11 @@ func GenerateConfigJSON() []byte {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connects first peer from config, just to reconnect fast after network switch
|
||||||
|
func (m *Yggdrasil) ConnectFirstPeer() {
|
||||||
|
m.core.ConnectFirstPeer()
|
||||||
|
}
|
||||||
|
|
||||||
// GetAddressString gets the node's IPv6 address
|
// GetAddressString gets the node's IPv6 address
|
||||||
func (m *Yggdrasil) GetAddressString() string {
|
func (m *Yggdrasil) GetAddressString() string {
|
||||||
ip := m.core.Address()
|
ip := m.core.Address()
|
||||||
|
|
|
@ -121,6 +121,27 @@ func (c *Core) _addPeerLoop() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connects first peer from config, just to reconnect fast after network switch
|
||||||
|
// Used in mobile
|
||||||
|
func (c *Core) ConnectFirstPeer() {
|
||||||
|
select {
|
||||||
|
case <-c.ctx.Done():
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
// Add peers from the Peers section
|
||||||
|
for peer := range c.config._peers {
|
||||||
|
u, err := url.Parse(peer.URI)
|
||||||
|
if err != nil {
|
||||||
|
c.log.Errorln("Failed to parse peer url:", peer, err)
|
||||||
|
}
|
||||||
|
if err := c.CallPeer(u, peer.SourceInterface); err != nil {
|
||||||
|
c.log.Errorln("Failed to add peer:", err)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Stop shuts down the Yggdrasil node.
|
// Stop shuts down the Yggdrasil node.
|
||||||
func (c *Core) Stop() {
|
func (c *Core) Stop() {
|
||||||
phony.Block(c, func() {
|
phony.Block(c, func() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue