go-dvote/cmd/censushttp/censushttp.go
cmd/censushttp/censushttp.goRaw
1package main
2
3import (
4 "log"
5 "os"
6 "strconv"
7 "strings"
8
9 censusmanager "github.com/vocdoni/dvote-relay/service/census"
10)
11
12func main() {
13 if len(os.Args) < 2 {
14 log.Fatal("Usage: " + os.Args[0] +
15 " <port> <namespace>[:pubKey] [<namespace>[:pubKey]]...")
16 os.Exit(2)
17 }
18 port, err := strconv.Atoi(os.Args[1])
19 if err != nil {
20 log.Fatal(err)
21 os.Exit(2)
22 }
23 for i := 2; i < len(os.Args); i++ {
24 s := strings.Split(os.Args[i], ":")
25 ns := s[0]
26 pubK := ""
27 if len(s) > 1 {
28 pubK = s[1]
29 log.Printf("Public Key authentication enabled on namespace %s\n", ns)
30 }
31 censusmanager.AddNamespace(ns, pubK)
32 log.Printf("Starting process HTTP service on port %d for namespace %s\n",
33 port, ns)
34 }
35 censusmanager.Listen(port, "http")
36
37}