FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
1,269 views 1 comments
by
Hi,

I would like to set openvpn client properties remotely by using JSON RPC. I have already created the vpn configuration but I don't know how to upload files that are necessary (cert, ca, key and tls_auth). Is it possible to do it through JSON RPC or I need to upload them through SSH ?

Thank you

2 Answers

0 votes
by anonymous

Hello,

try something with this one.

Source: https://github.com/openwrt/luci/wiki/JsonRpcHowTo

The Filesystem library /rpc/fs offers functionality to interact with the filesystem on the host machine.

Exported Functions:

Note: All functions are exported as they are except for readfile which encodes its return value in Base64 and writefile which only accepts Base64 encoded data as second argument. Note that both functions will only be available when the luasocket packet is installed on the host system.

0 votes
by
It is possible to download a file without additional packet with this message on http://192.168.1.1/ubus

{ "jsonrpc" : "2.0", "id" : 1, "method" : "call", "params" : ["file", "read", {"path" : "PATH OF THE FILE"}]}

And to upload one with this message on http://192.168.1.1/ubus

{ "jsonrpc" : "2.0", "id" : 1, "method" : "call", "params" : ["file", "write", {"path" : "PATH OF THE FILE", "data" : "File data as String"}]}

However, data must be string as it is not encoded.
by
Params also take "base64":true or "base64":false parameter but even in base64 there still are errors on readind / writing binary files