ryanrishi / glinet-client-go

GL.iNet client for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

glinet-client-go

Tests GitHub release (latest by date) Go Report Card

A Go client to access GL.iNet routers. Based on v4 firmware.

Usage

Installing

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

Run examples

Most examples require authentication. Set GLINET_USERNAME and GLINET_PASSWORD environment variables.

If running through GoLand, I recommend using the EnvFile plugin.

Authentication Overview

$ 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": ... }

About

GL.iNet client for Go

License:MIT License


Languages

Language:Go 100.0%