mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-29 15:36:28 +08:00
adjust peer updates to send ifaces with peer
This commit is contained in:
parent
495a07a81b
commit
ac6363dda6
3 changed files with 40 additions and 22 deletions
|
|
@ -163,6 +163,7 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
PeerIDs: make(models.PeerMap, 0),
|
||||
Peers: []wgtypes.PeerConfig{},
|
||||
NodePeers: []wgtypes.PeerConfig{},
|
||||
HostNetworkInfo: models.HostInfoMap{},
|
||||
}
|
||||
|
||||
logger.Log(1, "peer update for host", host.ID.String())
|
||||
|
|
@ -277,6 +278,7 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
}
|
||||
}
|
||||
|
||||
peerProxyPort := GetProxyListenPort(peerHost)
|
||||
var nodePeer wgtypes.PeerConfig
|
||||
if _, ok := hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()]; !ok {
|
||||
hostPeerUpdate.HostPeerIDs[peerHost.PublicKey.String()] = make(map[string]models.IDandAddr)
|
||||
|
|
@ -287,7 +289,11 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
Address: peer.PrimaryAddress(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
ProxyListenPort: GetProxyListenPort(peerHost),
|
||||
ProxyListenPort: peerProxyPort,
|
||||
}
|
||||
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ProxyListenPort: peerProxyPort,
|
||||
}
|
||||
nodePeer = peerConfig
|
||||
} else {
|
||||
|
|
@ -301,6 +307,10 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
Network: peer.Network,
|
||||
ProxyListenPort: GetProxyListenPort(peerHost),
|
||||
}
|
||||
hostPeerUpdate.HostNetworkInfo[peerHost.PublicKey.String()] = models.HostNetworkInfo{
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ProxyListenPort: peerProxyPort,
|
||||
}
|
||||
nodePeer = hostPeerUpdate.Peers[peerIndexMap[peerHost.PublicKey.String()]]
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +320,6 @@ func GetPeerUpdateForHost(ctx context.Context, network string, host *models.Host
|
|||
Address: peer.PrimaryAddress(),
|
||||
Name: peerHost.Name,
|
||||
Network: peer.Network,
|
||||
Interfaces: peerHost.Interfaces,
|
||||
ProxyListenPort: peerHost.ProxyListenPort,
|
||||
}
|
||||
hostPeerUpdate.NodePeers = append(hostPeerUpdate.NodePeers, nodePeer)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ type IDandAddr struct {
|
|||
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"`
|
||||
ProxyListenPort int `json:"proxy_listen_port" yaml:"proxy_listen_port"`
|
||||
}
|
||||
|
||||
// HostInfoMap - map of host public keys to host networking info
|
||||
type HostInfoMap map[string]HostNetworkInfo
|
||||
|
||||
// HostNetworkInfo - holds info related to host networking (used for client side peer calculations)
|
||||
type HostNetworkInfo struct {
|
||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||
ProxyListenPort int `json:"proxy_listen_port" yaml:"proxy_listen_port"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ type HostPeerUpdate struct {
|
|||
EgressInfo map[string]EgressInfo `json:"egress_info" bson:"egress_info" yaml:"egress_info"` // map key is node ID
|
||||
IngressInfo IngressInfo `json:"ingress_info" bson:"ext_peers" yaml:"ext_peers"`
|
||||
PeerIDs PeerMap `json:"peerids" bson:"peerids" yaml:"peerids"`
|
||||
HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
|
||||
}
|
||||
|
||||
// IngressInfo - struct for ingress info
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue