update code

This commit is contained in:
Cadey Ratio 2017-01-18 02:22:52 -08:00
parent fc0962b16c
commit 9fe3b64e6a
3 changed files with 12 additions and 9 deletions

View File

@ -15,7 +15,7 @@ func main() {
req := routerpc.AddHostRequest{
APIKey: "hunter2",
Hostname: "",
Hostname: "xena.foobar",
PrivKey: nil,
}
resp := &routerpc.AddHostResponse{}
@ -25,5 +25,5 @@ func main() {
log.Fatal(err)
}
log.Printf("Created host %s with token %s", resp.Hostname, resp.Token)
log.Printf("Created host %s (%s) with token %s", resp.Hostname, resp.OnionHostname, resp.Token)
}

10
main.go
View File

@ -18,7 +18,6 @@ import (
"time"
"git.xeserv.us/xena/route/routerpc"
r "github.com/GoRethink/gorethink"
"github.com/Xe/uuid"
"github.com/Yawning/bulb"
@ -116,7 +115,6 @@ func create(cfg *ServerConfig) (*Server, error) {
torControlPath := filepath.Join(cfg.TorDataDir, fmt.Sprintf("%d.sock", rand.Int63()))
tc := tor.NewConfig()
tc.Set("ControlSocket", torControlPath)
tc.Set("DataDirectory", cfg.TorDataDir)
tc.Set("HashedControlPassword", cfg.TorHashedPassword)
tc.Set("SocksPort", "0")
@ -238,10 +236,14 @@ func (rs *RPCServer) AddHost(req routerpc.AddHostRequest, resp *routerpc.AddHost
return err
}
resp.Hostname = oi.OnionID + ".onion"
resp.OnionHostname = oi.OnionID + ".onion"
resp.Token = token
rs.Server.ts.AddHost(resp.Hostname, token)
if req.Hostname != "" {
rs.Server.ts.AddHost(req.Hostname, token)
resp.Hostname = req.Hostname
}
rs.Server.ts.AddHost(resp.OnionHostname, token)
if oi.PrivateKey != nil {
resp.PrivKey = oi.PrivateKey

View File

@ -23,5 +23,6 @@ type AddHostRequest struct {
type AddHostResponse struct {
Token string
Hostname string
OnionHostname string
PrivKey crypto.PrivateKey
}