mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-17 14:38:41 +08:00
append local addresses
This commit is contained in:
parent
f651e65eff
commit
c11ba7c44b
2 changed files with 26 additions and 21 deletions
|
|
@ -274,10 +274,11 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
|
||||
peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
|
||||
hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()][peer.ID.String()] = models.IDandAddr{
|
||||
ID: peer.ID.String(),
|
||||
Address: peer.PrimaryAddress(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
ID: peer.ID.String(),
|
||||
Address: peer.PrimaryAddress(),
|
||||
LocalAddress: peer.LocalAddress.String(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
}
|
||||
nodePeer = peerConfig
|
||||
} else {
|
||||
|
|
@ -285,20 +286,22 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
peerAllowedIPs = append(peerAllowedIPs, allowedips...)
|
||||
hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]].AllowedIPs = peerAllowedIPs
|
||||
hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()][peer.ID.String()] = models.IDandAddr{
|
||||
ID: peer.ID.String(),
|
||||
Address: peer.PrimaryAddress(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
ID: peer.ID.String(),
|
||||
Address: peer.PrimaryAddress(),
|
||||
LocalAddress: peer.LocalAddress.String(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
}
|
||||
nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
|
||||
}
|
||||
|
||||
if node.Network == network { // add to peers map for metrics
|
||||
hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()] = models.IDandAddr{
|
||||
ID: peer.ID.String(),
|
||||
Address: peer.PrimaryAddress(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
ID: peer.ID.String(),
|
||||
Address: peer.PrimaryAddress(),
|
||||
LocalAddress: peer.LocalAddress.String(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
}
|
||||
hostPeerUpdate.NodePeers = append(hostPeerUpdate.NodePeers, nodePeer)
|
||||
}
|
||||
|
|
@ -324,10 +327,11 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
extPeerIdAndAddr := extPeerIdAndAddr
|
||||
hostPeerUpdate.HostPeerIDs[extPeerIdAndAddr.ID] = make(map[string]models.IDandAddr)
|
||||
hostPeerUpdate.HostPeerIDs[extPeerIdAndAddr.ID][extPeerIdAndAddr.ID] = models.IDandAddr{
|
||||
ID: extPeerIdAndAddr.ID,
|
||||
Address: extPeerIdAndAddr.Address,
|
||||
Name: extPeerIdAndAddr.Name,
|
||||
Network: node.Network,
|
||||
ID: extPeerIdAndAddr.ID,
|
||||
Address: extPeerIdAndAddr.Address,
|
||||
LocalAddress: extPeerIdAndAddr.LocalAddress,
|
||||
Name: extPeerIdAndAddr.Name,
|
||||
Network: node.Network,
|
||||
}
|
||||
hostPeerUpdate.IngressInfo.ExtPeers[extPeerIdAndAddr.ID] = models.ExtClientInfo{
|
||||
Masquerade: true,
|
||||
|
|
|
|||
|
|
@ -28,11 +28,12 @@ type Metric struct {
|
|||
|
||||
// IDandAddr - struct to hold ID and primary Address
|
||||
type IDandAddr struct {
|
||||
ID string `json:"id" bson:"id" yaml:"id"`
|
||||
Address string `json:"address" bson:"address" yaml:"address"`
|
||||
Name string `json:"name" bson:"name" yaml:"name"`
|
||||
IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
|
||||
Network string `json:"network" bson:"network" yaml:"network" validate:"network"`
|
||||
ID string `json:"id" bson:"id" yaml:"id"`
|
||||
Address string `json:"address" bson:"address" yaml:"address"`
|
||||
LocalAddress string `json:"localaddress" bson:"localaddress" yaml:"localaddress"`
|
||||
Name string `json:"name" bson:"name" yaml:"name"`
|
||||
IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
|
||||
Network string `json:"network" bson:"network" yaml:"network" validate:"network"`
|
||||
}
|
||||
|
||||
// PeerMap - peer map for ids and addresses in metrics
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue