Make sure we check for ipv4 and ipv6 early
Otherwise we still get an interface added but without any config
This commit is contained in:
parent
c47ff356c1
commit
0e3eb80602
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
|
// CreateLink sets up the WG interface and link with the correct
|
||||||
// address
|
// address
|
||||||
func CreateLink(conf *DsnetConfig) {
|
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 := netlink.NewLinkAttrs()
|
||||||
linkAttrs.Name = conf.InterfaceName
|
linkAttrs.Name = conf.InterfaceName
|
||||||
|
|
||||||
@ -33,10 +37,6 @@ func CreateLink(conf *DsnetConfig) {
|
|||||||
ExitFail("Could not add interface '%s' (%v)", conf.InterfaceName, err)
|
ExitFail("Could not add interface '%s' (%v)", conf.InterfaceName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(conf.IP) == 0 && len(conf.IP6) == 0 {
|
|
||||||
ExitFail("No IPv4 or IPv6 network defined in config")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(conf.IP) != 0 {
|
if len(conf.IP) != 0 {
|
||||||
addr := &netlink.Addr{
|
addr := &netlink.Addr{
|
||||||
IPNet: &net.IPNet{
|
IPNet: &net.IPNet{
|
||||||
|
Loading…
Reference in New Issue
Block a user