2017-02-12 04:13:29 +00:00
|
|
|
package rvpnmain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/admin"
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/client"
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/connection"
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/external"
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/rvpn/packer"
|
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
|
|
|
|
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() {
|
|
|
|
flag.StringVar(&argServerBinding, "server-port", "127.0.0.1:3502", "server Bind listener")
|
|
|
|
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")
|
|
|
|
|
|
|
|
p := packer.NewPacker()
|
|
|
|
p.Header.SetAddress("127.0.0.2")
|
2017-02-14 00:47:16 +00:00
|
|
|
p.Header.Port = 32768
|
|
|
|
p.Data.AppendString("A test message")
|
|
|
|
p.PackV1()
|
2017-02-12 04:13:29 +00:00
|
|
|
|
2017-02-14 00:47:16 +00:00
|
|
|
fmt.Println("-=-=-=-=-=-=-=-=-=-=")
|
2017-02-12 04:13:29 +00:00
|
|
|
|
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()
|
|
|
|
go client.LaunchClientListener(connectionTable, &secretKey, &argServerBinding)
|
|
|
|
go external.LaunchWebRequestExternalListener(&argServerExternalBinding)
|
|
|
|
|
|
|
|
err := admin.LaunchAdminListener(&argServerAdminBinding)
|
|
|
|
if err != nil {
|
|
|
|
loginfo.Println("LauchAdminListener failed: ", err)
|
|
|
|
}
|
|
|
|
}
|