mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-27 14:37:27 +08:00
add peer keys
This commit is contained in:
parent
be741c1b44
commit
5e9798bb05
2 changed files with 16 additions and 11 deletions
|
|
@ -393,13 +393,17 @@ func GetPeerUpdateForHost(host *models.Host) (models.HostPeerUpdate, error) {
|
|||
allowedips = append(allowedips, getEgressIPs(&node, &peer)...)
|
||||
}
|
||||
peerConfig.AllowedIPs = allowedips
|
||||
extClientPeerMap[peerHost.PublicKey.String()] = models.PeerExtInfo{
|
||||
PeerAddr: net.IPNet{
|
||||
IP: net.ParseIP(peer.PrimaryAddress()),
|
||||
Mask: net.CIDRMask(32, 32),
|
||||
},
|
||||
Allow: true,
|
||||
if node.IsIngressGateway {
|
||||
extClientPeerMap[peerHost.PublicKey.String()] = models.PeerExtInfo{
|
||||
PeerAddr: net.IPNet{
|
||||
IP: net.ParseIP(peer.PrimaryAddress()),
|
||||
Mask: net.CIDRMask(32, 32),
|
||||
},
|
||||
PeerKey: peerHost.PublicKey.String(),
|
||||
Allow: true,
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()]; !ok {
|
||||
hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()] = make(map[string]models.IDandAddr)
|
||||
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
|
||||
|
|
@ -441,7 +445,8 @@ func GetPeerUpdateForHost(host *models.Host) (models.HostPeerUpdate, error) {
|
|||
IP: net.ParseIP(extPeerIdAndAddr.Address),
|
||||
Mask: net.CIDRMask(32, 32),
|
||||
},
|
||||
Peers: extClientPeerMap,
|
||||
ExtPeerKey: extPeerIdAndAddr.ID,
|
||||
Peers: extClientPeerMap,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ type IngressInfo struct {
|
|||
}
|
||||
|
||||
type PeerExtInfo struct {
|
||||
PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
|
||||
PeerKey wgtypes.Key `json:"peer_key" yaml:"peer_key"`
|
||||
Allow bool `json:"allow" yaml:"allow"`
|
||||
PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
|
||||
PeerKey string `json:"peer_key" yaml:"peer_key"`
|
||||
Allow bool `json:"allow" yaml:"allow"`
|
||||
}
|
||||
|
||||
type ExtClientInfo struct {
|
||||
Masquerade bool `json:"masquerade" yaml:"masquerade"`
|
||||
ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
|
||||
ExtPeerKey wgtypes.Key `json:"ext_peer_key" yaml:"ext_peer_key"`
|
||||
ExtPeerKey string `json:"ext_peer_key" yaml:"ext_peer_key"`
|
||||
Peers map[string]PeerExtInfo `json:"peers" yaml:"peers"`
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue