telebit/vpn-server.go

55 lines
1.2 KiB
Go

package main
import (
"flag"
"io"
"log"
"os"
"time"
"git.daplie.com/Daplie/go-rvpn-server/logging"
)
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 ..
loginfo *log.Logger
logfatal *log.Logger
logFlags = log.Ldate | log.Lmicroseconds | log.Lshortfile
argServerBinding = flag.String("server-port", "127.0.0.1:8000", "server Bind listener")
argServerAdminBinding = flag.String("admin-server-port", "127.0.0.2:8000", "admin server Bind listener")
connectionTable *ConnectionTable
secretKey = "abc123"
)
func logInit(infoHandle io.Writer) {
loginfo = log.New(infoHandle, "INFO: ", logFlags)
logfatal = log.New(infoHandle, "FATAL : ", logFlags)
}
func main() {
logging.Init(os.Stdout, logFlags)
linfo, lfatal := logging.Get()
loginfo = linfo
logfatal = lfatal
loginfo.Println("startup")
flag.Parse()
go launchClientListener()
launchAdminListener()
}