Merge pull request #37 from botto/require-xor-ipv4-ipv6
Ensure we always have at least 1 address in config
This commit is contained in:
commit
4c6e5301db
8
up.go
8
up.go
@ -20,6 +20,10 @@ func RunPostUp(conf *DsnetConfig) {
|
||||
// CreateLink sets up the WG interface and link with the correct
|
||||
// address
|
||||
func CreateLink(conf *DsnetConfig) {
|
||||
if len(conf.IP) == 0 && len(conf.IP6) == 0 {
|
||||
ExitFail("No IPv4 or IPv6 network defined in config")
|
||||
}
|
||||
|
||||
linkAttrs := netlink.NewLinkAttrs()
|
||||
linkAttrs.Name = conf.InterfaceName
|
||||
|
||||
@ -33,7 +37,7 @@ func CreateLink(conf *DsnetConfig) {
|
||||
ExitFail("Could not add interface '%s' (%v)", conf.InterfaceName, err)
|
||||
}
|
||||
|
||||
if conf.IP != nil {
|
||||
if len(conf.IP) != 0 {
|
||||
addr := &netlink.Addr{
|
||||
IPNet: &net.IPNet{
|
||||
IP: conf.IP,
|
||||
@ -47,7 +51,7 @@ func CreateLink(conf *DsnetConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
if conf.IP6 != nil {
|
||||
if len(conf.IP6) != 0 {
|
||||
addr6 := &netlink.Addr{
|
||||
IPNet: &net.IPNet{
|
||||
IP: conf.IP6,
|
||||
|
Loading…
Reference in New Issue
Block a user