summaryrefslogtreecommitdiff
path: root/docs/src/api/go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-13 12:12:22 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-13 12:12:22 +0200
commit5abf00ab87a55662eefc7716de52ead9749293c6 (patch)
tree1cfa64b99482d7cc08b1d7da5d6833b75f5f7714 /docs/src/api/go
parent57d6c2ac55a5fd1ea609c873d5410174b7cf6ca4 (diff)
Refactor: Adapt the API to the documentation
Diffstat (limited to 'docs/src/api/go')
-rw-r--r--docs/src/api/go/example.md72
-rw-r--r--docs/src/api/go/functions.md11
2 files changed, 20 insertions, 63 deletions
diff --git a/docs/src/api/go/example.md b/docs/src/api/go/example.md
index e7b0d36..0ed7d02 100644
--- a/docs/src/api/go/example.md
+++ b/docs/src/api/go/example.md
@@ -1,63 +1,13 @@
-# Example with Comments
-
+# Example with comments
+The following is an example [in the repository](https://github.com/jwijenbergh/eduvpn-common/blob/main/cmd/cli/main.go). It is a command line client with the following flags
+```
+-get-institute string
+ The url of an institute to connect to
+-get-secure string
+ Gets secure internet servers.
+-get-secure-all string
+ Gets certificates for all secure internet servers. It stores them in ./certs. Provide an URL for the home server e.g. nl.eduvpn.org.
+```
```go
-
-// Bring the library into scope with the eduvpn prefix
-import eduvpn "github.com/jwijenbergh/eduvpn-common"
-
-// Callbacks
-
-func stateCallback(state *eduvpn.VPNState, oldState string, newState string, data string) {
-
- // OAuth is started, open the browser with the authorization URL
- if newState == "OAuth_Started" {
- openBrowser(data)
- }
-
- // Multiple profiles are found, we need to send a profile ID back using state.SetProfileID
- if newState == "Ask_Profile" {
- selectAndSendProfile(state, data)
- }
-}
-
-func main() {
- // Create the VPNState
- state := &eduvpn.VPNState{}
-
- // Register the state
- // We use linux so the client ID will be org.eduvpn.app.linux
- // We want to store the config files in configs
- // We wrap the callback with the state argument
- // And enable debugging
- registerErr := state.Register("org.eduvpn.app.linux", "configs", func(old string, new string, data string) {
- stateCallback(state, old, new, data)
- }, true)
-
- if registErr != nil {
- // handle the error of not being able to register
- }
-
- // Cleanup the library at the end
- defer state.Deregister()
-
- // Connect to an example server without forcing TCP
- config, configType, configErr := state.GetConnectConfig("eduvpn.example.com", false)
-
- if configErr != nil {
- // handle the error of not being able to get a config
- }
-
- if configType == "wireguard" {
- // Connect using wireguard with the config
- } else {
- // Connect using OpenVPN with the config
- }
-
- // We are connected
- setConnectErr := state.SetConnected()
-
- if setConnectErr != nil {
- // handle the error of not being able to call set connected
- }
-}
+{{#include ../../../../cmd/cli/main.go}}
```
diff --git a/docs/src/api/go/functions.md b/docs/src/api/go/functions.md
index c647787..381f5be 100644
--- a/docs/src/api/go/functions.md
+++ b/docs/src/api/go/functions.md
@@ -26,9 +26,10 @@ Returns a string of JSON data with the servers/organizations and an `error`, nil
## OpenVPN/Wireguard config
See [Overview](../overview/getconfig.html)
```go
-func GetConnectConfig(url string, forceTCP bool) (string, string, error)
+func GetConfigInstituteAccess(url string, forceTCP bool) (string, string, error)
+func GetConfigSecureInternet(url string, forceTCP bool) (string, string, error)
```
-- `url`: The url of the server to get a connect config for
+- `url`: The URL of the Institute Access or Secure Internet server to get a connect config for
- `forceTCP`: Whether or not we want to force enable TCP
Returns:
@@ -36,6 +37,12 @@ Returns:
- A `string`, `openvpn` or `wireguard` indicating if it is an OpenVPN or Wireguard config
- An `error` (can be nil)
+### Cancelling OAuth
+```go
+func CancelOAuth() error
+```
+Returns an `error`, can be nil indicating no error
+
### Setting a profile ID
```go
func SetProfileID(profileID string) error