diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-09-20 12:39:38 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-09-20 12:39:38 +0200 |
| commit | b0e4e454fc94935cf8ee3282a07596ec53268a18 (patch) | |
| tree | 03b4e6a43dc823bd91a75f0fb71ad78b5b2d1218 /internal | |
| parent | 2f4ddf6a1558589452c5d54674ac444e0a072b93 (diff) | |
Go vet: Fixes
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/oauth/oauth.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 10abf4a..e99b715 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -78,7 +78,7 @@ type OAuthExchangeSession struct { // filled in when constructing the callback Context context.Context - Server http.Server + Server *http.Server } // Struct that defines the json format for /.well-known/vpn-user-portal" @@ -95,7 +95,7 @@ func (oauth *OAuth) getTokensWithCallback() error { oauth.Session.Context = context.Background() mux := http.NewServeMux() addr := "127.0.0.1:8000" - oauth.Session.Server = http.Server{ + oauth.Session.Server = &http.Server{ Addr: addr, Handler: mux, } @@ -200,7 +200,9 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { code, success := req.URL.Query()["code"] // Shutdown after we're done defer func() { - go oauth.Session.Server.Shutdown(oauth.Session.Context) + if oauth.Session.Server != nil { + go oauth.Session.Server.Shutdown(oauth.Session.Context) + } }() if !success { oauth.Session.CallbackError = &types.WrappedErrorMessage{ @@ -308,7 +310,9 @@ func (oauth *OAuth) Cancel() { Message: "cancelled OAuth", Err: &OAuthCancelledCallbackError{}, } - oauth.Session.Server.Shutdown(oauth.Session.Context) + if oauth.Session.Server != nil { + oauth.Session.Server.Shutdown(oauth.Session.Context) + } } func (oauth *OAuth) EnsureTokens() error { |
