X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgovpn%2Fcommon.go;h=030794c726a5d13ba47a97d286ef237c4262519e;hb=572cac17bde738055312f7a468a0bde0e760a262;hp=d3f8ec04a595ad62cf960ccfd1ca70310411212f;hpb=cecb63f12f4a9f523276a0c19c7feb7437c7f53a;p=govpn.git diff --git a/src/cypherpunks.ru/govpn/common.go b/src/cypherpunks.ru/govpn/common.go index d3f8ec0..030794c 100644 --- a/src/cypherpunks.ru/govpn/common.go +++ b/src/cypherpunks.ru/govpn/common.go @@ -1,6 +1,6 @@ /* GoVPN -- simple secure free software virtual private network daemon -Copyright (C) 2014-2016 Sergey Matveev +Copyright (C) 2014-2017 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,8 +28,11 @@ import ( const ( TimeoutDefault = 60 EtherSize = 14 - MTUMax = 9000 + EtherSize - MTUDefault = 1500 + EtherSize + MTUMax = 9000 + EtherSize + 1 + MTUDefault = 1500 + EtherSize + 1 + + ENV_IFACE = "GOVPN_IFACE" + ENV_REMOTE = "GOVPN_REMOTE" ) var ( @@ -40,14 +43,17 @@ var ( // You have to specify path to it and (inteface name as a rule) something // that will be the first argument when calling it. Function will return // it's output and possible error. -func ScriptCall(path, ifaceName string) ([]byte, error) { +func ScriptCall(path, ifaceName, remoteAddr string) ([]byte, error) { if path == "" { return nil, nil } if _, err := os.Stat(path); err != nil && os.IsNotExist(err) { return nil, err } - out, err := exec.Command(path, ifaceName).CombinedOutput() + cmd := exec.Command(path) + cmd.Env = append(cmd.Env, ENV_IFACE+"="+ifaceName) + cmd.Env = append(cmd.Env, ENV_REMOTE+"="+remoteAddr) + out, err := cmd.CombinedOutput() if err != nil { log.Println("Script error", path, err, string(out)) }