route/cmd/api/main.go

36 lines
600 B
Go
Raw Normal View History

2017-01-18 09:57:18 +00:00
package main
import (
"crypto/rand"
"crypto/rsa"
2017-01-18 09:57:18 +00:00
"log"
"net/rpc"
"git.xeserv.us/xena/route/routerpc"
)
func main() {
client, err := rpc.DialHTTP("tcp", "127.0.0.1:9234")
if err != nil {
log.Fatal(err)
}
pKey, err := rsa.GenerateKey(rand.Reader, 1024)
if err != nil {
log.Fatal(err)
}
2017-01-18 09:57:18 +00:00
req := routerpc.AddHostRequest{
2017-01-18 17:01:52 +00:00
APIKey: "hunter2",
PrivKey: pKey,
2017-01-18 09:57:18 +00:00
}
resp := &routerpc.AddHostResponse{}
err = client.Call("Urls.AddHost", req, resp)
if err != nil {
log.Fatal(err)
}
2017-01-18 10:22:52 +00:00
log.Printf("Created host %s (%s) with token %s", resp.Hostname, resp.OnionHostname, resp.Token)
2017-01-18 09:57:18 +00:00
}