pkg/mesh: enable generating config without peer
This commit re-enables old functionality, which permitted the generation of the configuration for a cluster without any peers. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
parent
810dae695e
commit
b54b31b699
@ -400,22 +400,19 @@ func (t *Topology) AsPeer() *wireguard.Peer {
|
|||||||
|
|
||||||
// PeerConf generates a WireGuard configuration file for a given peer in a Topology.
|
// PeerConf generates a WireGuard configuration file for a given peer in a Topology.
|
||||||
func (t *Topology) PeerConf(name string) *wireguard.Conf {
|
func (t *Topology) PeerConf(name string) *wireguard.Conf {
|
||||||
var p *Peer
|
var pka int
|
||||||
for i := range t.peers {
|
for i := range t.peers {
|
||||||
if t.peers[i].Name == name {
|
if t.peers[i].Name == name {
|
||||||
p = t.peers[i]
|
pka = t.peers[i].PersistentKeepalive
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
c := &wireguard.Conf{}
|
c := &wireguard.Conf{}
|
||||||
for _, s := range t.segments {
|
for _, s := range t.segments {
|
||||||
peer := &wireguard.Peer{
|
peer := &wireguard.Peer{
|
||||||
AllowedIPs: s.allowedIPs,
|
AllowedIPs: s.allowedIPs,
|
||||||
Endpoint: s.endpoint,
|
Endpoint: s.endpoint,
|
||||||
PersistentKeepalive: p.PersistentKeepalive,
|
PersistentKeepalive: pka,
|
||||||
PublicKey: s.key,
|
PublicKey: s.key,
|
||||||
}
|
}
|
||||||
c.Peers = append(c.Peers, peer)
|
c.Peers = append(c.Peers, peer)
|
||||||
@ -426,7 +423,7 @@ func (t *Topology) PeerConf(name string) *wireguard.Conf {
|
|||||||
}
|
}
|
||||||
peer := &wireguard.Peer{
|
peer := &wireguard.Peer{
|
||||||
AllowedIPs: t.peers[i].AllowedIPs,
|
AllowedIPs: t.peers[i].AllowedIPs,
|
||||||
PersistentKeepalive: p.PersistentKeepalive,
|
PersistentKeepalive: pka,
|
||||||
PublicKey: t.peers[i].PublicKey,
|
PublicKey: t.peers[i].PublicKey,
|
||||||
Endpoint: t.peers[i].Endpoint,
|
Endpoint: t.peers[i].Endpoint,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user