2 GoVPN -- simple secure free software virtual private network daemon
3 Copyright (C) 2014-2017 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/>.
19 // Simple secure, DPI/censorship-resistant free software VPN daemon.
26 "github.com/Sirupsen/logrus"
28 "cypherpunks.ru/govpn"
29 "cypherpunks.ru/govpn/server"
33 bindAddr = flag.String("bind", "[::]:1194", "Bind to address")
34 proto = flag.String("proto", "udp", "Protocol to use: udp, tcp or all")
35 confPath = flag.String("conf", "peers.yaml", "Path to configuration YAML")
36 stats = flag.String("stats", "", "Enable stats retrieving on host:port")
37 proxy = flag.String("proxy", "", "Enable HTTP proxy on host:port")
38 egdPath = flag.String("egd", "", "Optional path to EGD socket")
39 syslog = flag.Bool("syslog", false, "Enable logging to syslog")
40 version = flag.Bool("version", false, "Print version information")
41 warranty = flag.Bool("warranty", false, "Print warranty information")
42 logLevel = flag.String("log_level", "warning", "Log level")
47 fields := logrus.Fields{"func": "main"}
51 fmt.Println(govpn.Warranty)
55 fmt.Println(govpn.VersionGet())
59 logger, err = govpn.NewLogger(*logLevel, *syslog)
63 ).WithError(err).Fatal("Couldn't initialize logging")
65 govpn.SetLogger(logger)
73 govpn.EGDInit(*egdPath)
78 serverConfig := server.Configuration{
79 BindAddress: *bindAddr,
81 Timeout: govpn.TimeoutDefault,
83 if serverConfig.Protocol, err = govpn.NewProtocolFromString(*proto); err != nil {
84 logger.WithError(err).WithFields(
88 ).Fatal("Invalid protocol")
90 if err = serverConfig.Validate(); err != nil {
91 logger.WithError(err).WithFields(fields).Fatal("Invalid configuration")
94 srv := server.NewServer(
99 govpn.CatchSignalShutdown(),
103 go govpn.StatsProcessor(*stats, srv.KnownPeers())
107 if err = <-srv.Error; err != nil {
108 logger.WithError(err).Fatal("Fatal error")