summaryrefslogtreecommitdiff
path: root/docs/src/api/go/functions.md
blob: c6477871043c5c83ebe20879cb051d3e0df2a788 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Functions
## Registering
See [Overview](../overview/registering.html)
```go
func Register(name string, directory string, stateCallback func, debug bool) error
```
- `name`: The name of the client
- `directory`: The directory where the configs and logging should be stored
- `stateCallback`: function with three arguments, full type:
  ```go
  func(oldState string, newState string, data string)
  ```
- `debug`: Whether or not we want to enable debugging

Returns an `error` type, nil if no error

## Discovery
See [Overview](../overview/discovery.html)
```go
func GetDiscoServers() (string, error)
func GetDiscoOrganizations() (string, error)
```

Returns a string of JSON data with the servers/organizations and an `error`, nil if no error

## OpenVPN/Wireguard config
See [Overview](../overview/getconfig.html)
```go
func GetConnectConfig(url string, forceTCP bool) (string, string, error)
```
- `url`: The url of the server to get a connect config for
- `forceTCP`: Whether or not we want to force enable TCP

Returns:
- A `string` of the OpenVPN/Wireguard config
- A `string`, `openvpn` or `wireguard` indicating if it is an OpenVPN or Wireguard config
- An `error` (can be nil)

### Setting a profile ID
```go
func SetProfileID(profileID string) error
```
- `profileID`: The profile ID to connect to

Returns an `error`, can be nil indicating no error

## Connecting/Disconnecting
See [Overview](../overview/connecting.html)
```go
func SetConnected() error
func SetDisconnected() error
```

Returns an `error`, can be nil indicating no error

## Deregister
See [Overview](../overview/deregistering.html)
```go
func Deregister() error
```

Returns an `error`, can be nil indicating no error