HTTP-over-Onionv3 Reseeder

This commit is contained in:
idk
2019-05-08 12:23:21 -04:00
parent e7d4585361
commit bc91c473c2
4 changed files with 42 additions and 7 deletions

View File

@@ -6,8 +6,10 @@ import (
"net"
"runtime"
"time"
"strconv"
"github.com/MDrollette/i2p-tools/reseed"
"github.com/cretz/bine/tor"
"github.com/codegangsta/cli"
)
@@ -25,6 +27,10 @@ func NewReseedCommand() cli.Command {
Name: "tlsHost",
Usage: "The public hostname used on your TLS certificate",
},
cli.BoolFlag{
Name: "onion",
Usage: "Present an onionv3 address",
},
cli.StringFlag{
Name: "key",
Usage: "Path to your su3 signing private key",
@@ -105,6 +111,7 @@ func reseedAction(c *cli.Context) {
var tlsCert, tlsKey string
tlsHost := c.String("tlsHost")
if tlsHost != "" {
tlsKey = c.String("tlsKey")
// if no key is specified, default to the host.pem in the current dir
@@ -179,7 +186,13 @@ func reseedAction(c *cli.Context) {
}()
}
if tlsHost != "" && tlsCert != "" && tlsKey != "" {
if c.Bool("onion") {
port, err := strconv.Atoi(c.String("port"))
if err != nil {
log.Fatalln(err.Error())
}
log.Fatalln(server.ListenAndServeOnion(nil, &tor.ListenConf{LocalPort: port, RemotePorts: []int{80}}))
}else if tlsHost != "" && tlsCert != "" && tlsKey != "" {
log.Printf("HTTPS server started on %s\n", server.Addr)
log.Fatalln(server.ListenAndServeTLS(tlsCert, tlsKey))
} else {