2 GoVPN -- simple secure free software virtual private network daemon
3 Copyright (C) 2014-2016 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, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
31 RefreshRate = time.Minute
35 confs map[govpn.PeerId]*govpn.PeerConf
36 idsCache govpn.CipherCache
39 func confRead() map[govpn.PeerId]*govpn.PeerConf {
40 data, err := ioutil.ReadFile(*confPath)
42 log.Fatalln("Unable to read configuration:", err)
44 confsRaw := new(map[string]govpn.PeerConf)
45 err = json.Unmarshal(data, confsRaw)
47 log.Fatalln("Unable to parse configuration:", err)
50 confs := make(map[govpn.PeerId]*govpn.PeerConf, len(*confsRaw))
51 for name, pc := range *confsRaw {
52 verifier, err := govpn.VerifierFromString(pc.VerifierRaw)
54 log.Fatalln("Unable to decode the key:", err.Error(), pc.VerifierRaw)
59 conf := govpn.PeerConf{
70 if pc.TimeoutInt <= 0 {
71 pc.TimeoutInt = govpn.TimeoutDefault
73 conf.Timeout = time.Second * time.Duration(pc.TimeoutInt)
74 confs[*verifier.Id] = &conf
81 ids := make([]govpn.PeerId, 0, len(confs))
82 for peerId, _ := range confs {
83 ids = append(ids, peerId)
89 idsCache = govpn.NewCipherCache(nil)
93 time.Sleep(RefreshRate)