From 05c180e7b28c4659b55e5bf1ebc4847e5b62230e Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 12 Aug 2024 11:33:52 +0200 Subject: Util: Add a function to calculate the gateway --- docs/src/api/functiondocs.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'docs/src/api/functiondocs.md') diff --git a/docs/src/api/functiondocs.md b/docs/src/api/functiondocs.md index dccb547..c1b1122 100644 --- a/docs/src/api/functiondocs.md +++ b/docs/src/api/functiondocs.md @@ -4,6 +4,7 @@ This document was automatically generated from the exports/exports.go file - [About the API](#about-the-api) - [Functions](#functions) * [AddServer](#addserver) + * [CalculateGateway](#calculategateway) * [Cleanup](#cleanup) * [CookieCancel](#cookiecancel) * [CookieDelete](#cookiedelete) @@ -113,6 +114,20 @@ Example Output: "misc": false } +## CalculateGateway +Signature: + ```go +func CalculateGateway(subnet *C.char) (*C.char, *C.char) +``` +CalculateGateway calculates the gateway for a subnet, it can take IPv4 or +IPv6 networks with CIDR notation as inputs and returns the gateway address +This is useful to pass to `StartFailover`. It returns an error if it fails +to calculate a gateway. + +Example Input: ```CalculateGateway("10.10.0.5/24")``` + +Example Output: ```"10.10.0.1", null``` + ## Cleanup Signature: ```go @@ -854,7 +869,8 @@ WireGuard connection to OpenVPN over TCP - `c` is the cookie that is passed for cancellation. To create a cookie, use the `CookieNew` function - - `gateway` is the gateway IP of the VPN + - `gateway` is the gateway IP of the VPN. You MAY calculate this with the + `CalculateGateway` function - `readRxBytes` is a function that returns the current rx bytes of the VPN interface, this should return a `long long int` in c -- cgit v1.2.3