From 8d54be38bb0b7441f3e1db638f58397bcb2c0c8b Mon Sep 17 00:00:00 2001 From: idk Date: Wed, 28 Dec 2022 05:29:03 +0000 Subject: [PATCH] bump version --- Makefile | 2 +- auth.go | 10 +++++++--- info.go | 5 +++-- manager.go | 7 +++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0d27855..ed884e7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ USER_GH=eyedeekay -VERSION=0.1.4 +VERSION=0.1.5 packagename=go-i2pcontrol echo: diff --git a/auth.go b/auth.go index 381f48c..e98eb84 100644 --- a/auth.go +++ b/auth.go @@ -3,9 +3,10 @@ package i2pcontrol import ( "crypto/tls" "crypto/x509" - "github.com/ybbus/jsonrpc/v2" "io/ioutil" "net/http" + + "github.com/ybbus/jsonrpc/v2" ) var ( @@ -14,7 +15,7 @@ var ( token string ) -// +// Initialize set up the rpcClient with the specified host, port, and path func Initialize(host, port, path string) { RPCOpts = &jsonrpc.RPCClientOpts{ HTTPClient: &http.Client{ @@ -28,6 +29,7 @@ func Initialize(host, port, path string) { rpcClient = jsonrpc.NewClientWithOpts("http://"+host+":"+port+"/"+path+"/", RPCOpts) } +// InitializeWithSelfSignedCert will set up an rpcClient which will accept a self-signed certificate, at the path speciied by cert. func InitializeWithSelfSignedCert(host, port, path, cert string) error { caCert, err := ioutil.ReadFile(cert) if err != nil { @@ -44,10 +46,11 @@ func InitializeWithSelfSignedCert(host, port, path, cert string) error { }, }, } - rpcClient = jsonrpc.NewClientWithOpts("http://"+host+":"+port+"/"+path+"/", RPCOpts) + rpcClient = jsonrpc.NewClientWithOpts("https://"+host+":"+port+"/"+path+"/", RPCOpts) return nil } +// Call an RPC method with params func Call(method string, params interface{}) (map[string]interface{}, error) { response, err := rpcClient.Call(method, params) if err != nil { @@ -62,6 +65,7 @@ func Call(method string, params interface{}) (map[string]interface{}, error) { return retpre, nil } +// Authenticate to the RPC API with a password func Authenticate(password string) (int, error) { retpre, err := Call("Authenticate", map[string]interface{}{ "API": 1, diff --git a/info.go b/info.go index 414fad6..9b31b86 100644 --- a/info.go +++ b/info.go @@ -2,7 +2,6 @@ package i2pcontrol import "fmt" - // ParticipatingTunnels gets the number of participating tunnels the router has currently func ParticipatingTunnels() (int, error) { retpre, err := Call("RouterInfo", map[string]interface{}{ @@ -16,7 +15,7 @@ func ParticipatingTunnels() (int, error) { return result, nil } -// +// Status queries the status of the router func Status() (string, error) { retpre, err := Call("RouterInfo", map[string]interface{}{ "i2p.router.status": nil, @@ -29,6 +28,7 @@ func Status() (string, error) { return result, nil } +// NetStatus queries the status of the network connection func NetStatus() (string, error) { retpre, err := Call("RouterInfo", map[string]interface{}{ "i2p.router.net.status": nil, @@ -73,6 +73,7 @@ func NetStatus() (string, error) { return "Unexpected result", fmt.Errorf("Unexpected result %d", result) } +// Reseeding checks if the I2P Router is reseeding func Reseeding() (bool, error) { retpre, err := Call("Routerinfo", map[string]interface{}{ "i2p.router.netdb.isreseeding": nil, diff --git a/manager.go b/manager.go index 2933e56..15c1c13 100644 --- a/manager.go +++ b/manager.go @@ -1,5 +1,6 @@ package i2pcontrol +// Echo test the API func Echo(echo string) (string, error) { retpre, err := Call("Echo", map[string]interface{}{ "Echo": echo, @@ -12,6 +13,7 @@ func Echo(echo string) (string, error) { return result, nil } +// RestartGraceful initiates a graceful restart, which will occur in around 11 minutes. func RestartGraceful() (string, error) { _, err := Call("RouterManager", map[string]interface{}{ "RestartGraceful": nil, @@ -23,6 +25,7 @@ func RestartGraceful() (string, error) { return "Graceful Restart Initiated", nil } +// Restart the router immediately func Restart() (string, error) { _, err := Call("RouterManager", map[string]interface{}{ "Restart": nil, @@ -34,6 +37,7 @@ func Restart() (string, error) { return "Restart Initiated", nil } +// Shutdown initiates a graceful restart, which will occur in around 11 minutes. func ShutdownGraceful() (string, error) { _, err := Call("RouterManager", map[string]interface{}{ "ShutdownGraceful": nil, @@ -45,6 +49,7 @@ func ShutdownGraceful() (string, error) { return "Graceful Shutdown Initiated", nil } +// Shutdown the router immediately func Shutdown() (string, error) { _, err := Call("RouterManager", map[string]interface{}{ "Shutdown": nil, @@ -56,6 +61,7 @@ func Shutdown() (string, error) { return "Shutdown Initiated", nil } +// FindUpdates pings the server to check for updates func FindUpdates() (bool, error) { retpre, err := Call("RouterManager", map[string]interface{}{ "FindUpdates": nil, @@ -68,6 +74,7 @@ func FindUpdates() (bool, error) { return result, nil } +// Starts an update. func Update() (string, error) { _, err := Call("RouterManager", map[string]interface{}{ "Update": nil,