2017-02-12 04:13:29 +00:00
|
|
|
package rvpnmain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/connection"
|
2017-02-25 05:56:40 +00:00
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/genericlistener"
|
2017-02-12 20:39:50 +00:00
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/xlate"
|
2017-02-12 04:13:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
loginfo *log.Logger
|
|
|
|
logdebug *log.Logger
|
|
|
|
logFlags = log.Ldate | log.Lmicroseconds | log.Lshortfile
|
2017-02-25 05:56:40 +00:00
|
|
|
argWssClientListener string
|
|
|
|
argGenericBinding string
|
2017-02-12 04:13:29 +00:00
|
|
|
argServerBinding string
|
|
|
|
argServerAdminBinding string
|
|
|
|
argServerExternalBinding string
|
|
|
|
connectionTable *connection.Table
|
2017-02-12 20:39:50 +00:00
|
|
|
wssMapping *xlate.WssMapping
|
2017-02-12 04:13:29 +00:00
|
|
|
secretKey = "abc123"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2017-02-25 05:56:40 +00:00
|
|
|
flag.StringVar(&argGenericBinding, "ssl-listener", ":8443", "generic SSL Listener")
|
|
|
|
flag.StringVar(&argWssClientListener, "wss-client-listener", ":3502", "wss client listener address:port")
|
2017-02-12 04:13:29 +00:00
|
|
|
flag.StringVar(&argServerAdminBinding, "admin-server-port", "127.0.0.2:8000", "admin server Bind listener")
|
|
|
|
flag.StringVar(&argServerExternalBinding, "external-server-port", "127.0.0.1:8080", "external server Bind listener")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Run -- main entry point
|
|
|
|
func Run() {
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
loginfo = log.New(os.Stdout, "INFO: packer: ", logFlags)
|
|
|
|
logdebug = log.New(os.Stdout, "DEBUG: packer:", logFlags)
|
|
|
|
|
|
|
|
loginfo.Println("startup")
|
|
|
|
|
2017-02-14 00:47:16 +00:00
|
|
|
fmt.Println("-=-=-=-=-=-=-=-=-=-=")
|
2017-02-12 04:13:29 +00:00
|
|
|
|
2017-02-25 05:56:40 +00:00
|
|
|
// certbundle, err := tls.LoadX509KeyPair("certs/fullchain.pem", "certs/privkey.pem")
|
|
|
|
// if err != nil {
|
|
|
|
// loginfo.Println(err)
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// loginfo.Println(certbundle)
|
|
|
|
|
2017-02-12 20:39:50 +00:00
|
|
|
wssMapping = xlate.NewwssMapping()
|
|
|
|
go wssMapping.Run()
|
|
|
|
|
2017-02-12 04:13:29 +00:00
|
|
|
connectionTable = connection.NewTable()
|
|
|
|
go connectionTable.Run()
|
2017-02-25 05:56:40 +00:00
|
|
|
|
|
|
|
//go client.LaunchClientListener(connectionTable, &secretKey, &argServerBinding)
|
2017-02-18 21:21:36 +00:00
|
|
|
//go external.LaunchWebRequestExternalListener(&argServerExternalBinding, connectionTable)
|
2017-02-25 05:56:40 +00:00
|
|
|
//go external.LaunchExternalServer(argServerExternalBinding, connectionTable)
|
|
|
|
//err = admin.LaunchAdminListener(&argServerAdminBinding, connectionTable)
|
|
|
|
//if err != nil {
|
|
|
|
// loginfo.Println("LauchAdminListener failed: ", err)
|
|
|
|
//}
|
|
|
|
|
|
|
|
genericlistener.LaunchWssListener(connectionTable, secretKey, argWssClientListener, "certs/fullchain.pem", "certs/privkey.pem")
|
2017-02-12 04:13:29 +00:00
|
|
|
}
|