FEATURE: allow disabling private IPs
When forcing the internal IP to "" or "-", private IPs won't be used.
This commit is contained in:
@@ -51,9 +51,10 @@ const (
|
||||
|
||||
// Node represents a node in the network.
|
||||
type Node struct {
|
||||
Endpoint *wireguard.Endpoint
|
||||
Key []byte
|
||||
InternalIP *net.IPNet
|
||||
Endpoint *wireguard.Endpoint
|
||||
Key []byte
|
||||
NoInternalIP bool
|
||||
InternalIP *net.IPNet
|
||||
// LastSeen is a Unix time for the last time
|
||||
// the node confirmed it was live.
|
||||
LastSeen int64
|
||||
|
@@ -371,7 +371,7 @@ func (m *Mesh) handleLocal(n *Node) {
|
||||
if n.Endpoint == nil || (n.Endpoint.DNS == "" && n.Endpoint.IP == nil) {
|
||||
n.Endpoint = &wireguard.Endpoint{DNSOrIP: wireguard.DNSOrIP{IP: m.externalIP.IP}, Port: m.port}
|
||||
}
|
||||
if n.InternalIP == nil {
|
||||
if n.InternalIP == nil && !n.NoInternalIP {
|
||||
n.InternalIP = m.internalIP
|
||||
}
|
||||
// Compare the given node to the calculated local node.
|
||||
@@ -380,6 +380,7 @@ func (m *Mesh) handleLocal(n *Node) {
|
||||
local := &Node{
|
||||
Endpoint: n.Endpoint,
|
||||
Key: m.pub,
|
||||
NoInternalIP: n.NoInternalIP,
|
||||
InternalIP: n.InternalIP,
|
||||
LastSeen: time.Now().Unix(),
|
||||
Leader: n.Leader,
|
||||
|
@@ -83,6 +83,8 @@ func NewTopology(nodes map[string]*Node, peers map[string]*Peer, granularity Gra
|
||||
switch granularity {
|
||||
case LogicalGranularity:
|
||||
location = logicalLocationPrefix + node.Location
|
||||
// Put node in a different location, if no private
|
||||
// IP was found.
|
||||
if node.InternalIP == nil {
|
||||
location = nodeLocationPrefix + node.Name
|
||||
}
|
||||
|
Reference in New Issue
Block a user