36 lines
600 B
Go
36 lines
600 B
Go
package main
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"crypto/rsa"
|
|
"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)
|
|
}
|
|
|
|
req := routerpc.AddHostRequest{
|
|
APIKey: "hunter2",
|
|
PrivKey: pKey,
|
|
}
|
|
resp := &routerpc.AddHostResponse{}
|
|
|
|
err = client.Call("Urls.AddHost", req, resp)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
log.Printf("Created host %s (%s) with token %s", resp.Hostname, resp.OnionHostname, resp.Token)
|
|
}
|