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{ req := routerpc.AddHostRequest{
APIKey: "hunter2", APIKey: "hunter2",
Hostname: "", Hostname: "xena.foobar",
PrivKey: nil, PrivKey: nil,
} }
resp := &routerpc.AddHostResponse{} resp := &routerpc.AddHostResponse{}
@ -25,5 +25,5 @@ func main() {
log.Fatal(err) 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" "time"
"git.xeserv.us/xena/route/routerpc" "git.xeserv.us/xena/route/routerpc"
r "github.com/GoRethink/gorethink" r "github.com/GoRethink/gorethink"
"github.com/Xe/uuid" "github.com/Xe/uuid"
"github.com/Yawning/bulb" "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())) torControlPath := filepath.Join(cfg.TorDataDir, fmt.Sprintf("%d.sock", rand.Int63()))
tc := tor.NewConfig() tc := tor.NewConfig()
tc.Set("ControlSocket", torControlPath)
tc.Set("DataDirectory", cfg.TorDataDir) tc.Set("DataDirectory", cfg.TorDataDir)
tc.Set("HashedControlPassword", cfg.TorHashedPassword) tc.Set("HashedControlPassword", cfg.TorHashedPassword)
tc.Set("SocksPort", "0") tc.Set("SocksPort", "0")
@ -238,10 +236,14 @@ func (rs *RPCServer) AddHost(req routerpc.AddHostRequest, resp *routerpc.AddHost
return err return err
} }
resp.Hostname = oi.OnionID + ".onion" resp.OnionHostname = oi.OnionID + ".onion"
resp.Token = token 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 { if oi.PrivateKey != nil {
resp.PrivKey = oi.PrivateKey resp.PrivKey = oi.PrivateKey

View File

@ -21,7 +21,8 @@ type AddHostRequest struct {
// AddHostResponse ... // AddHostResponse ...
type AddHostResponse struct { type AddHostResponse struct {
Token string Token string
Hostname string Hostname string
PrivKey crypto.PrivateKey OnionHostname string
PrivKey crypto.PrivateKey
} }