You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
743 B

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