From ebc4eacee4bf1c7ceec9a43d0f65e48a57b39fed Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 28 Feb 2018 15:27:58 +0000 Subject: [PATCH] Allow sane defaults on setTunTap --- src/yggdrasil/admin.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index ebbe8b50..9051d3f2 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -64,21 +64,19 @@ func (a *admin) init(c *Core, listenaddr string) { } }) a.addHandler("setTunTap", []string{"", "[]", "[]"}, func(out *[]byte, ifparams ...string) { - // Check parameters - if (ifparams[0] != "none" && len(ifparams) != 3) || - (ifparams[0] == "none" && len(ifparams) != 1) { - *out = []byte("Invalid number of parameters given\n") - return - } // Set sane defaults iftapmode := false ifmtu := 1280 var err error + // Check we have enough params for TAP mode if len(ifparams) > 1 { // Is it a TAP adapter? if ifparams[1] == "tap" { iftapmode = true } + } + // Check we have enough params for MTU + if len(ifparams) > 2 { // Make sure the MTU is sane ifmtu, err = strconv.Atoi(ifparams[2]) if err != nil || ifmtu < 1280 || ifmtu > 65535 {