62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"math/rand"
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
|
|
"git.xeserv.us/xena/route/server"
|
|
|
|
"github.com/facebookgo/flagenv"
|
|
_ "github.com/joho/godotenv/autoload"
|
|
)
|
|
|
|
var (
|
|
rethinkDBHost = flag.String("rethink-host", "", "RethinkDB host")
|
|
rethinkDBDatabase = flag.String("rethink-database", "", "RethinkDB database")
|
|
controlKeyFile = flag.String("control-key-file", "", "Control host keyfile")
|
|
controlHost = flag.String("control-host", "", "Control host onion hash")
|
|
torDataDir = flag.String("tor-data-dir", "./var", "Tor data directory")
|
|
torHashedPassword = flag.String("tor-hashed-password", "", "Tor hashed password")
|
|
torPassword = flag.String("tor-password", "hunter2", "Tor clear password")
|
|
webPort = flag.String("web-port", "9234", "HTTP ingress port for backends and users")
|
|
domainSuffix = flag.String("domain-suffix", ".apps.xeserv.us", "Domain name suffix associated with the load balancer")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
flagenv.Parse()
|
|
rand.Seed(time.Now().Unix())
|
|
|
|
s, err := server.New(server.Config{
|
|
ControlHost: *controlHost,
|
|
ControlKeyFile: *controlKeyFile,
|
|
RethinkDBHost: *rethinkDBHost,
|
|
RethinkDBDatabase: *rethinkDBDatabase,
|
|
TorDataDir: *torDataDir,
|
|
TorHashedPassword: *torHashedPassword,
|
|
TorPassword: *torPassword,
|
|
WebPort: *webPort,
|
|
DomainSuffix: *domainSuffix,
|
|
})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
l, err := net.Listen("tcp", "127.0.0.1:"+*webPort)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer l.Close()
|
|
|
|
hs := &http.Server{
|
|
Handler: s,
|
|
Addr: "127.0.0.1:" + *webPort,
|
|
}
|
|
|
|
hs.Serve(l)
|
|
}
|