package main import ( "flag" "log" "log/syslog" "os" "github.com/pyke369/golang-support/uconfig" ) var config *uconfig.UConfig func main() { var err error // default configuration file is ./openvpn-dm-mgt-server.conf configFile := flag.String("config", "openvpn-dm-mgt-server.conf", "configuration file") logToSyslog := flag.Bool("syslog", false, "Log to syslog") flag.Parse() // parseconfig if config, err = uconfig.New(*configFile); err != nil { log.Println(err) os.Exit(1) } server := NewVPNServer(config.GetString("config.openvpnPort", "127.0.0.01:5000")) server.vpnlogUrl = config.GetString("config.vpnLogUrl", "") server.mailRelay = config.GetString("config.mailRelay", "") server.MailFrom = config.GetString("config.mailFrom", "") server.CcPwnPassword = config.GetString("config.ccPwnPassword", "") server.pwnTemplate = config.GetString("config.pwnTemplate", "") server.newAsTemplate = config.GetString("config.newAsTemplate", "") server.slackTemplate = config.GetString("config.slackTemplate", "") server.slackTemplate2 = config.GetString("config.slackTemplate2", "") server.cacheDir = config.GetString("config.cacheDir", "") server.authCa = config.GetString("config.authCa", "") server.syslog = false if *logToSyslog { log.SetFlags(0) server.syslog = true logWriter, e := syslog.New(syslog.LOG_NOTICE, "") if e == nil { log.SetOutput(logWriter) defer logWriter.Close() } } go server.Run() NewHTTPServer( config.GetString("config.httpPort", "127.0.0.01:8080"), config.GetString("config.httpKey", ""), config.GetString("config.httpCert", ""), config.GetString("config.httpCa", ""), server) }