func main() { // Redis pool = &redis.Pool{ MaxIdle: 3, IdleTimeout: 240 * time.Second, Dial: func() (redis.Conn, error) { c, err := redis.Dial("tcp", ":6379") if err != nil { log.Fatal("Cannot connect to Redis") } return c, err }, TestOnBorrow: func(c redis.Conn, t time.Time) error { _, err := c.Do("PING") return err }, } var err error db, err = sql.Open("sqlite3", "./users.sqlite3") if err != nil { log.Fatal(err) } defer db.Close() serverPGP = pgp.NewPGP() ws := new(restful.WebService) ws.Route(ws.POST("/register").To(handleRegister). Consumes(restful.MIME_JSON). Produces(restful.MIME_JSON)) ws.Route(ws.POST("/register/token").To(handleRegisterToken). Consumes(restful.MIME_JSON). Produces(restful.MIME_JSON)) ws.Route(ws.POST("/identify").To(handleIdentify). Consumes(restful.MIME_JSON). Produces(restful.MIME_JSON)) ws.Route(ws.POST("/identify/token").To(handleIdentifyToken). Consumes(restful.MIME_JSON). Produces(restful.MIME_JSON)) restful.Add(ws) addr := "localhost:8080" log.WithFields(log.Fields{"address": addr}).Info("Listen") http.ListenAndServe(addr, nil) }
func main() { var err error client = pgp.NewPGP() if err != nil { panic(err) } client.DecryptEntity() app := cli.NewApp() app.Name = "pgp-client" app.Usage = "" app.Action = func(c *cli.Context) { identify() } app.Commands = []cli.Command{ { Name: "register", Aliases: []string{"r"}, Usage: "", Action: func(c *cli.Context) { register() }, }, } app.Run(os.Args) //identify() //bytes, err := client.EncryptBytes([]byte("testToken"), client.PublicEntities) //f, _ := os.Create("./msg.gpg") //f.Write(pgp.ToArmor(bytes, pgp.PGPMessage)) //f.Close() //f, _ = os.Create("./public.asc") //f.Write(pgp.ToArmor(client.ExportPublicKey(), pgp.PGPPublicKey)) //f.Close() //encToken := readTokenReq(conn) //log.Println(encToken) }