mirror of
https://github.com/gravitl/netmaker.git
synced 2025-12-17 16:18:34 +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)...)
|
allowedips = append(allowedips, getEgressIPs(&node, &peer)...)
|
||||||
}
|
}
|
||||||
peerConfig.AllowedIPs = allowedips
|
peerConfig.AllowedIPs = allowedips
|
||||||
extClientPeerMap[peerHost.PublicKey.String()] = models.PeerExtInfo{
|
if node.IsIngressGateway {
|
||||||
PeerAddr: net.IPNet{
|
extClientPeerMap[peerHost.PublicKey.String()] = models.PeerExtInfo{
|
||||||
IP: net.ParseIP(peer.PrimaryAddress()),
|
PeerAddr: net.IPNet{
|
||||||
Mask: net.CIDRMask(32, 32),
|
IP: net.ParseIP(peer.PrimaryAddress()),
|
||||||
},
|
Mask: net.CIDRMask(32, 32),
|
||||||
Allow: true,
|
},
|
||||||
|
PeerKey: peerHost.PublicKey.String(),
|
||||||
|
Allow: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()]; !ok {
|
if _, ok := hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()]; !ok {
|
||||||
hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()] = make(map[string]models.IDandAddr)
|
hostPeerUpdate.PeerIDs[peerHost.PublicKey.String()] = make(map[string]models.IDandAddr)
|
||||||
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
|
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
|
||||||
|
|
@ -441,7 +445,8 @@ func GetPeerUpdateForHost(host *models.Host) (models.HostPeerUpdate, error) {
|
||||||
IP: net.ParseIP(extPeerIdAndAddr.Address),
|
IP: net.ParseIP(extPeerIdAndAddr.Address),
|
||||||
Mask: net.CIDRMask(32, 32),
|
Mask: net.CIDRMask(32, 32),
|
||||||
},
|
},
|
||||||
Peers: extClientPeerMap,
|
ExtPeerKey: extPeerIdAndAddr.ID,
|
||||||
|
Peers: extClientPeerMap,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,15 @@ type IngressInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PeerExtInfo struct {
|
type PeerExtInfo struct {
|
||||||
PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
|
PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
|
||||||
PeerKey wgtypes.Key `json:"peer_key" yaml:"peer_key"`
|
PeerKey string `json:"peer_key" yaml:"peer_key"`
|
||||||
Allow bool `json:"allow" yaml:"allow"`
|
Allow bool `json:"allow" yaml:"allow"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExtClientInfo struct {
|
type ExtClientInfo struct {
|
||||||
Masquerade bool `json:"masquerade" yaml:"masquerade"`
|
Masquerade bool `json:"masquerade" yaml:"masquerade"`
|
||||||
ExtPeerAddr net.IPNet `json:"ext_peer_addr" yaml:"ext_peer_addr"`
|
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"`
|
Peers map[string]PeerExtInfo `json:"peers" yaml:"peers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue