A Go client to access GL.iNet routers. Based on v4 firmware.
Use go get to retrieve the SDK to add it to your GOPATH workspace, or
project's Go module dependencies.
go get github.com/ryanrishi/glinet-client-go
To update the SDK use go get -u to retrieve the latest version of the SDK.
go get -u github.com/glinet-client-go
Most examples require authentication. Set GLINET_USERNAME and GLINET_PASSWORD environment variables.
If running through GoLand, I recommend using the EnvFile plugin.
$ curl -XPOST http://192.168.8.1/rpc -d '{"jsonrpc": "2.0", "id": 1, "method": "challenge", "params": {"username": "root"}}'
{"id":1,"jsonrpc":"2.0","result":{"salt":"1Aa2BbC3","alg":1,"nonce":"asdflkjasdflkj"}}
$ openssl passwd -1 -salt $salt $GLINET_PASSWORD | tee >hash
$ echo -n "root:$hash:$nonce" | md5sum | tee>login_hash
$ curl -XPOST http://192.168.8.1/rpc -d '{"jsonrpc": "2.0", "id": 1, "method": "login", "params": {"username": "root", "hash": "$login_hash"}}' | jq '.result'
{ "sid": ... }