2 GoVPN -- simple secure free software virtual private network daemon
3 Copyright (C) 2014-2019 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 MTUMax = 9000 + EtherSize + 1
31 MTUDefault = 1500 + EtherSize + 1
33 ENV_IFACE = "GOVPN_IFACE"
34 ENV_REMOTE = "GOVPN_REMOTE"
38 Version string = "UNKNOWN"
41 // Call external program/script.
42 // You have to specify path to it and (inteface name as a rule) something
43 // that will be the first argument when calling it. Function will return
44 // it's output and possible error.
45 func ScriptCall(path, ifaceName, remoteAddr string) ([]byte, error) {
49 if _, err := os.Stat(path); err != nil && os.IsNotExist(err) {
52 cmd := exec.Command(path)
53 cmd.Env = append(cmd.Env, ENV_IFACE+"="+ifaceName)
54 cmd.Env = append(cmd.Env, ENV_REMOTE+"="+remoteAddr)
55 out, err := cmd.CombinedOutput()
57 log.Println("Script error", path, err, string(out))
63 func SliceZero(data []byte) {
64 for i := 0; i < len(data); i++ {
69 func VersionGet() string {
70 return "GoVPN version " + Version + " built with " + runtime.Version()