pkg: allow overriding internal IP

This addresses the request for enhancement in
https://github.com/squat/kilo/issues/7.
This commit is contained in:
Lucas Servén Marín
2019-07-15 17:24:21 +02:00
parent 82fe418f89
commit 8e755cf52e
4 changed files with 34 additions and 8 deletions

View File

@@ -505,17 +505,20 @@ func (m *Mesh) checkIn() {
}
func (m *Mesh) handleLocal(n *Node) {
// Allow the external IP to be overridden.
// Allow the IPs to be overridden.
if n.ExternalIP == nil {
n.ExternalIP = m.externalIP
}
if n.InternalIP == nil {
n.InternalIP = m.internalIP
}
// Compare the given node to the calculated local node.
// Take leader, location, and subnet from the argument, as these
// are not determined by kilo.
local := &Node{
ExternalIP: n.ExternalIP,
Key: m.pub,
InternalIP: m.internalIP,
InternalIP: n.InternalIP,
LastSeen: time.Now().Unix(),
Leader: n.Leader,
Location: n.Location,