update code
This commit is contained in:
parent
fc0962b16c
commit
9fe3b64e6a
|
@ -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
10
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue