bump version

This commit is contained in:
idk
2022-12-28 05:29:03 +00:00
parent e8e12b9e45
commit 8d54be38bb
4 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,6 @@
USER_GH=eyedeekay
VERSION=0.1.4
VERSION=0.1.5
packagename=go-i2pcontrol
echo:

10
auth.go
View File

@ -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,

View File

@ -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,

View File

@ -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,