2017-02-02 23:25:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"time"
|
2017-02-06 03:19:04 +00:00
|
|
|
|
|
|
|
"git.daplie.com/Daplie/go-rvpn-server/logging"
|
2017-02-02 23:25:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Time allowed to write a message to the peer.
|
|
|
|
writeWait = 10 * time.Second
|
|
|
|
|
|
|
|
// Time allowed to read the next pong message from the peer.
|
|
|
|
pongWait = 60 * time.Second
|
|
|
|
|
|
|
|
// Send pings to peer with this period. Must be less than pongWait.
|
|
|
|
pingPeriod = (pongWait * 9) / 10
|
|
|
|
|
|
|
|
// Maximum message size allowed from peer.
|
|
|
|
maxMessageSize = 512
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
//Info ..
|
2017-02-09 03:08:53 +00:00
|
|
|
loginfo *log.Logger
|
|
|
|
logfatal *log.Logger
|
|
|
|
logFlags = log.Ldate | log.Lmicroseconds | log.Lshortfile
|
|
|
|
argServerBinding = flag.String("server-port", "127.0.0.1:3502", "server Bind listener")
|
|
|
|
argServerAdminBinding = flag.String("admin-server-port", "127.0.0.2:8000", "admin server Bind listener")
|
|
|
|
argServerExternalBinding = flag.String("external-server-port", "127.0.0.1:8080", "external server Bind listener")
|
|
|
|
connectionTable *ConnectionTable
|
|
|
|
secretKey = "abc123"
|
2017-02-02 23:25:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func logInit(infoHandle io.Writer) {
|
|
|
|
loginfo = log.New(infoHandle, "INFO: ", logFlags)
|
|
|
|
logfatal = log.New(infoHandle, "FATAL : ", logFlags)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2017-02-06 03:19:04 +00:00
|
|
|
logging.Init(os.Stdout, logFlags)
|
|
|
|
linfo, lfatal := logging.Get()
|
|
|
|
loginfo = linfo
|
|
|
|
logfatal = lfatal
|
|
|
|
|
2017-02-02 23:25:12 +00:00
|
|
|
loginfo.Println("startup")
|
|
|
|
flag.Parse()
|
|
|
|
|
2017-02-09 03:08:53 +00:00
|
|
|
connectionTable = newConnectionTable()
|
|
|
|
go connectionTable.run()
|
2017-02-06 03:19:04 +00:00
|
|
|
go launchClientListener()
|
2017-02-09 03:08:53 +00:00
|
|
|
go launchWebRequestExternalListener()
|
2017-02-06 03:19:04 +00:00
|
|
|
launchAdminListener()
|
2017-02-02 23:25:12 +00:00
|
|
|
}
|