diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-04-12 22:58:24 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | 025e373f726d9924fd3bba13610169b70636a5bb (patch) | |
| tree | 6238c0d6dfcd6860d0251e414d7e9d5acb648d76 /cmd/cli/main.go | |
| parent | 696befcc0e29dade5879dab2f33ea2d705be244b (diff) | |
Exports: Implement newest API using cookie handlers
BREAKING CHANGES:
- The following functions need a special "cookie" as the first argument
- Add server (also now has an extra int as last argument, if non 0 run no callbacks, useful for preprovisioned servers)
- Get config
- Set secure location
- Disco servers
- Disco organizations
- Cleanup
- Renew session
- Start failover
Removed functions:
- "CancelOAuth", "CancelFailover" replaced by "CookieCancel"
- SecureLocationList, removed because the secure internet server
from ServerList() now has the locations embedded in the JSON
A cookie is a specialized context that can be used for cancellation
and sending values across a channel. Cancel OAuth and Cancel failover
functions have thus been removed. Instead, create a cookie with
"CookieNew", pass it to the function as the first argument and when you
want to cancel, run "CookieCancel".
The functions mentioned above use network requests, or some other
long running procedure. Even though we have a timeout set to 10
seconds for failover and network requests, it might make sense to make
this longer and just have clients cancel the request.
Cookies that have been created with "CookieNew" must be freed with
CookieDelete, which cancels the cookie and then deletes the underlying
handle.
Because cookies have a channel associated with them, they are used for
replying to state callbacks. When you receive an ASK_PROFILE or
ASK_LOCATION request, you get the same cookie back that you have
created when passed to the function (key "cookie" in the state
data). Reply with your answer (the profile or location) with
"CookieReply" passing in the cookie as first argument and the data as
second.
This means that SetProfileID and SetSecureLocation should
now only be used when not in a state callback. E.g. just changing the
profile or location when triggered by the user.
Finally, when a cookie is canceled, the error that is returned by the
function inherits from the Go context cancellation error:
https://pkg.go.dev/context#pkg-variables ("context canceled")
Diffstat (limited to 'cmd/cli/main.go')
0 files changed, 0 insertions, 0 deletions
