5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 20:00:27 +00:00

Make AddPeer remember added peer (as opposed to CallPeer which does not)

This commit is contained in:
Neil Alexander 2019-03-29 08:58:30 +00:00
parent a830521078
commit 399e1a2ffe
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -309,7 +309,17 @@ func (c *Core) SetLogger(log *log.Logger) {
// 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)
if err := c.CallPeer(addr, sintf); err != nil {
return err
}
c.config.Mutex.Lock()
if sintf == "" {
c.config.Current.Peers = append(c.config.Current.Peers, addr)
} else {
c.config.Current.InterfacePeers[sintf] = append(c.config.Current.InterfacePeers[sintf], addr)
}
c.config.Mutex.Unlock()
return nil
}
// Calls a peer. This should be specified in the peer URI format, i.e.