mirror of
https://github.com/openwrt/packages.git
synced 2025-02-07 01:09:53 +00:00
The rpcd wireguard plugin provides essential functions similar to the `wg` tool. It uses the embeddable-wg-library [0], which describes itself as: "This is a mini single-file library, meant to be embedded directly into the source code of your program. Copy wireguard.c and wireguard.h into your project. They should build with any C89 compiler. There are no dependencies except libc" The plugin does exactly that and therefor inherits the LGPL license. At this point it provides the following functions: 'wireguard' "status":{} "genkey":{} "genpsk":{} "pubkey":{"private":"String"} Examples: $ ubus call wireguard status { "wg0": { "ifindex": 12, "public_key": "<base64 encoded public key>", "listen_port": 1234, "peers": { "<base64 encoded public peer key>": { "allowed_ips": [ "192.168.1.123/32" ], "last_handshake": 0, "rx_bytes": 0, "tx_bytes": 0 }, "<another base64 encoded public peer key>": { "endpoint": "<ip:port>", "allowed_ips": [ "192.168.1.124/32" ], "last_handshake": 1676287619, "rx_bytes": 8731604, "tx_bytes": 88333652 } } } } $ ubus call wireguard genpsk { "preshared": "EKQJ3XI/6xLoifAoGb5bNA39De1tiwZ3x7h8OS2zKkE=" } $ ubus call wireguard genkey { "private": "IFyGkfXlO+WO8DMO3cqhaDZ8rBfioP5pVnAoQlEpXnI=", "public": "uF2O6/ZXZjKnUnxBnldElBYIXfpyvvtUnZfKP+BSBSI=" } $ ubus call wireguard pubkey '{"private":"IFyGkfXlO+WO8DMO3cqhaDZ8rBfioP5pVnAoQlEpXnI="}' { "public": "uF2O6/ZXZjKnUnxBnldElBYIXfpyvvtUnZfKP+BSBSI=" } Size comparison: 52436 /usr/bin/wg 18544 /usr/lib/rpcd/wireguard.so [0] https://git.zx2c4.com/wireguard-tools/tree/contrib/embeddable-wg-library Signed-off-by: Andre Heider <a.heider@gmail.com>