From 37f38b166aaaeb99f444abea817f8192ff77dd2a Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 12 Feb 2024 20:38:39 +0100 Subject: Docs: Add a WireGuard + proxyguard example --- docs/src/api/functiondocs.md | 20 ++++++++++++++++---- exports/exports.go | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/src/api/functiondocs.md b/docs/src/api/functiondocs.md index 4f7e455..8aa2138 100644 --- a/docs/src/api/functiondocs.md +++ b/docs/src/api/functiondocs.md @@ -417,7 +417,8 @@ Signature: ```go func GetConfig(c C.uintptr_t, _type C.int, id *C.char, pTCP C.int, startup C.int) (*C.char, *C.char) ``` -GetConfig gets a configuration for the server +GetConfig gets a configuration for the server. It returns additional +information in case WireGuard over Proxyguard is used (see the last example) `c` is the cookie that is used for cancellation. Create a cookie first with CookieNew, this same cookie is also used for replying to state transitions @@ -526,10 +527,21 @@ Example Input (3=custom server): ```GetConfig(myCookie, 3, Example Output (2=WireGuard): + { + "config": "[Interface]\nPrivateKey = ...\nAddress = ...\nDNS = ...\n\n[Peer]\nPublicKey = ...=\nAllowedIPs = 0.0.0.0/0,::/0\nEndpoint = ...", + "protocol": 2, + "default_gateway": true, + "should_failover": true, <- whether or not the failover procedure should happen + } + +Example Output (3=WireGuard + Proxyguard): + { - "config": "https://demo.eduvpn.nl/\n# Profile: ...\n# Expires: ...\n\n[Interface]\nPrivateKey = ...\nAddress = ...\nDNS = ...\n\n[Peer]\nPublicKey = ...=\nAllowedIPs = 0.0.0.0/0,::/0\nEndpoint = ...", - "protocol": 2, - "default_gateway": true + "config":"[Interface]\nMTU = ...\nAddress = ...\nDNS = ...\nPrivateKey = ...\n[Peer]\nPublicKey = ...\nAllowedIPs = ...\nEndpoint = 127.0.0.1:x\n", + "protocol":3, + "default_gateway":true, + "should_failover":true, + "proxy":{"source_port":38683,"listen":"127.0.0.1:59812","peer":"https://..."} } ## InState diff --git a/exports/exports.go b/exports/exports.go index 19a2ca4..3461c37 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -475,7 +475,7 @@ func ServerList() (*C.char, *C.char) { return C.CString(ret), nil } -// GetConfig gets a configuration for the server +// GetConfig gets a configuration for the server. It returns additional information in case WireGuard over Proxyguard is used (see the last example) // // `c` is the cookie that is used for cancellation. Create a cookie first with CookieNew, this same cookie is also used for replying to state transitions // @@ -561,11 +561,22 @@ func ServerList() (*C.char, *C.char) { // Example Output (2=WireGuard): // // { -// "config": "https://demo.eduvpn.nl/\n# Profile: ...\n# Expires: ...\n\n[Interface]\nPrivateKey = ...\nAddress = ...\nDNS = ...\n\n[Peer]\nPublicKey = ...=\nAllowedIPs = 0.0.0.0/0,::/0\nEndpoint = ...", +// "config": "[Interface]\nPrivateKey = ...\nAddress = ...\nDNS = ...\n\n[Peer]\nPublicKey = ...=\nAllowedIPs = 0.0.0.0/0,::/0\nEndpoint = ...", // "protocol": 2, -// "default_gateway": true +// "default_gateway": true, +// "should_failover": true, <- whether or not the failover procedure should happen // } // +// Example Output (3=WireGuard + Proxyguard): +// +// { +// "config":"[Interface]\nMTU = ...\nAddress = ...\nDNS = ...\nPrivateKey = ...\n[Peer]\nPublicKey = ...\nAllowedIPs = ...\nEndpoint = 127.0.0.1:x\n", +// "protocol":3, +// "default_gateway":true, +// "should_failover":true, +// "proxy":{"source_port":38683,"listen":"127.0.0.1:59812","peer":"https://..."} +// } +// //export GetConfig func GetConfig(c C.uintptr_t, _type C.int, id *C.char, pTCP C.int, startup C.int) (*C.char, *C.char) { state, stateErr := getVPNState() -- cgit v1.2.3