write correct netmask to conf files
This commit is contained in:
parent
a361bffa3c
commit
b38e0966eb
9
add.go
9
add.go
@ -8,8 +8,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO -- replace hardcoded /22 with one derived from conf.Network
|
|
||||||
|
|
||||||
const wgQuickPeerConf = `[Interface]
|
const wgQuickPeerConf = `[Interface]
|
||||||
Address = {{ .Peer.IP }}/22
|
Address = {{ .Peer.IP }}/22
|
||||||
PrivateKey={{ .Peer.PrivateKey.Key }}
|
PrivateKey={{ .Peer.PrivateKey.Key }}
|
||||||
@ -28,12 +26,12 @@ PersistentKeepalive={{ .Keepalive }}
|
|||||||
const vyattaPeerConf = `[Interface]
|
const vyattaPeerConf = `[Interface]
|
||||||
configure
|
configure
|
||||||
|
|
||||||
set interfaces wireguard dsnet address {{ .Peer.IP }}/22
|
set interfaces wireguard dsnet address {{ .Peer.IP }}/{{ .Cidrmask }}
|
||||||
set interfaces wireguard dsnet route-allowed-ips true
|
set interfaces wireguard dsnet route-allowed-ips true
|
||||||
|
|
||||||
set interfaces wireguard dsnet peer {{ .DsnetConfig.PrivateKey.PublicKey.Key }} endpoint {{ .DsnetConfig.ExternalIP }}:{{ .DsnetConfig.ListenPort }}
|
set interfaces wireguard dsnet peer {{ .DsnetConfig.PrivateKey.PublicKey.Key }} endpoint {{ .DsnetConfig.ExternalIP }}:{{ .DsnetConfig.ListenPort }}
|
||||||
set interfaces wireguard dsnet peer allowed-ips {{ .AllowedIPs }}
|
set interfaces wireguard dsnet peer allowed-ips {{ .AllowedIPs }}
|
||||||
set interfaces wireguard dsnet peer persistent-keepalive {{.AllowedIPs}}
|
set interfaces wireguard dsnet peer persistent-keepalive {{ .Keepalive }}
|
||||||
|
|
||||||
{{- if .DsnetConfig.DNS }}
|
{{- if .DsnetConfig.DNS }}
|
||||||
#set service dns forwarding name-server {{ .DsnetConfig.DNS }}
|
#set service dns forwarding name-server {{ .DsnetConfig.DNS }}
|
||||||
@ -108,12 +106,15 @@ func PrintPeerCfg(peer PeerConfig, conf *DsnetConfig) {
|
|||||||
ExitFail("Unrecognised DSNET_OUTPUT type")
|
ExitFail("Unrecognised DSNET_OUTPUT type")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cidrmask, _ := conf.Network.IPNet.Mask.Size()
|
||||||
|
|
||||||
t := template.Must(template.New("peerConf").Parse(peerConf))
|
t := template.Must(template.New("peerConf").Parse(peerConf))
|
||||||
err := t.Execute(os.Stdout, map[string]interface{}{
|
err := t.Execute(os.Stdout, map[string]interface{}{
|
||||||
"Peer": peer,
|
"Peer": peer,
|
||||||
"DsnetConfig": conf,
|
"DsnetConfig": conf,
|
||||||
"Keepalive": time.Duration(KEEPALIVE).Seconds(),
|
"Keepalive": time.Duration(KEEPALIVE).Seconds(),
|
||||||
"AllowedIPs": strings.Join(allowedIPsStr, ","),
|
"AllowedIPs": strings.Join(allowedIPsStr, ","),
|
||||||
|
"Cidrmask": cidrmask,
|
||||||
})
|
})
|
||||||
check(err)
|
check(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user