package main import ( "flag" "log" "log/syslog" "math/rand" "os" "time" "github.com/pyke369/golang-support/uconfig" ) func main() { var err error var config *uconfig.UConfig // default configuration file is /etc/openvpn/dm-mgt-server.conf configFile := flag.String("config", "/etc/openvpn/vpn-mgt.conf", "configuration file") logToSyslog := flag.Bool("syslog", false, "Log to syslog") debug := flag.Bool("debug", false, "log every message received") flag.Parse() // parseconfig if config, err = uconfig.New(*configFile); err != nil { log.Println("config", configFile, err) os.Exit(1) } // seed the prng rand.Seed(time.Now().UnixNano()) server := NewVPNServer(config.GetString("config.openvpnPort", "127.0.0.01:5000"), *debug) if *logToSyslog { log.SetFlags(0) logWriter, e := syslog.New(syslog.LOG_NOTICE, "vpncontrol") if e == nil { log.SetOutput(logWriter) defer logWriter.Close() } } // time to start the listeners go NewHTTPServer( config.GetString("config.http.port", "127.0.0.01:8080"), config.GetString("config.http.key", ""), config.GetString("config.http.cert", ""), server) server.Run() // server.Run() should never end os.Exit(1) }