From 9fe3b64e6a1dc3a47fd568f98544c2f385cef537 Mon Sep 17 00:00:00 2001 From: Cadey Dodrill Date: Wed, 18 Jan 2017 02:22:52 -0800 Subject: [PATCH] update code --- cmd/api/main.go | 4 ++-- main.go | 10 ++++++---- routerpc/rpc.go | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index e7b3684..d4a2e8d 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -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) } diff --git a/main.go b/main.go index 9619d7b..cdd4352 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/routerpc/rpc.go b/routerpc/rpc.go index a4e58c2..225bb9a 100644 --- a/routerpc/rpc.go +++ b/routerpc/rpc.go @@ -21,7 +21,8 @@ type AddHostRequest struct { // AddHostResponse ... type AddHostResponse struct { - Token string - Hostname string - PrivKey crypto.PrivateKey + Token string + Hostname string + OnionHostname string + PrivKey crypto.PrivateKey }