diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-03-23 18:19:45 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-03-23 18:19:45 +0100 |
| commit | 2da03b735517a034a5b369550036c853a7dad819 (patch) | |
| tree | 2c039dd46b43395d60a2fa8159886596f4ef6286 | |
| parent | 40053552852cf8c27fe7658b64df001d65b0a65e (diff) | |
Run gofumpt
| -rw-r--r-- | cli/main.go | 3 | ||||
| -rw-r--r-- | src/api.go | 2 | ||||
| -rw-r--r-- | src/config.go | 2 | ||||
| -rw-r--r-- | src/http.go | 3 | ||||
| -rw-r--r-- | src/oauth.go | 8 | ||||
| -rw-r--r-- | src/server.go | 18 | ||||
| -rw-r--r-- | src/verify.go | 3 | ||||
| -rw-r--r-- | src/wireguard.go | 3 |
8 files changed, 21 insertions, 21 deletions
diff --git a/cli/main.go b/cli/main.go index b9c3bf8..ddcb001 100644 --- a/cli/main.go +++ b/cli/main.go @@ -2,10 +2,11 @@ package main import ( "flag" - eduvpn "github.com/jwijenbergh/eduvpn-common/src" "log" "os/exec" "strings" + + eduvpn "github.com/jwijenbergh/eduvpn-common/src" ) func openBrowser(urlString string) { @@ -1,8 +1,8 @@ package eduvpn import ( - "fmt" "encoding/json" + "fmt" "net/http" "net/url" ) diff --git a/src/config.go b/src/config.go index 0b7c1c7..6e085d0 100644 --- a/src/config.go +++ b/src/config.go @@ -22,7 +22,7 @@ func (eduvpn *VPNState) WriteConfig() error { if marshalErr != nil { return marshalErr } - return ioutil.WriteFile(eduvpn.GetConfigName(), jsonString, 0644) + return ioutil.WriteFile(eduvpn.GetConfigName(), jsonString, 0o644) } func (eduvpn *VPNState) LoadConfig() error { diff --git a/src/http.go b/src/http.go index 8cb32b2..bc2cc20 100644 --- a/src/http.go +++ b/src/http.go @@ -66,7 +66,6 @@ type HTTPOptionalParams struct { // Construct an URL including on parameters func HTTPConstructURL(baseURL string, parameters URLParameters) (string, error) { url, err := url.Parse(baseURL) - if err != nil { return "", err } @@ -116,7 +115,6 @@ func httpOptionalHeaders(req *http.Request, opts *HTTPOptionalParams) { req.Header.Add(k, v[0]) } } - } func httpOptionalBodyReader(opts *HTTPOptionalParams) io.Reader { @@ -127,7 +125,6 @@ func httpOptionalBodyReader(opts *HTTPOptionalParams) io.Reader { } func HTTPMethodWithOpts(method string, url string, opts *HTTPOptionalParams) (http.Header, []byte, error) { - // Make sure the url contains all the parameters // This can return an error, // it already has the right error so so we don't wrap it further diff --git a/src/oauth.go b/src/oauth.go index 291a409..92c64d4 100644 --- a/src/oauth.go +++ b/src/oauth.go @@ -19,7 +19,6 @@ import ( // client. func genState() (string, error) { randomBytes, err := MakeRandomByteSlice(32) - if err != nil { return "", &OAuthGenStateUnableError{Err: err} } @@ -120,7 +119,8 @@ func (oauth *OAuth) getTokensWithAuthCode(authCode string) error { "redirect_uri": {"http://127.0.0.1:8000/callback"}, } headers := &http.Header{ - "content-type": {"application/x-www-form-urlencoded"}} + "content-type": {"application/x-www-form-urlencoded"}, + } opts := &HTTPOptionalParams{Headers: headers, Body: data} current_time := generateTimeSeconds() _, body, bodyErr := HTTPPostWithOpts(reqURL, opts) @@ -157,7 +157,8 @@ func (oauth *OAuth) getTokensWithRefresh() error { "grant_type": {"refresh_token"}, } headers := &http.Header{ - "content-type": {"application/x-www-form-urlencoded"}} + "content-type": {"application/x-www-form-urlencoded"}, + } opts := &HTTPOptionalParams{Headers: headers, Body: data} current_time := generateTimeSeconds() _, body, bodyErr := HTTPPostWithOpts(reqURL, opts) @@ -210,7 +211,6 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { // Now that we have obtained the authorization code, we can move to the next step: // Obtaining the access and refresh tokens err := oauth.getTokensWithAuthCode(extractedCode) - if err != nil { oauth.Session.CallbackError = &OAuthFailedCallbackGetTokensError{Err: err} go oauth.Session.Server.Shutdown(oauth.Session.Context) diff --git a/src/server.go b/src/server.go index 1dc0f88..d512049 100644 --- a/src/server.go +++ b/src/server.go @@ -1,27 +1,27 @@ package eduvpn import ( - "errors" "encoding/json" + "errors" ) type Server struct { - BaseURL string `json:"base_url"` - Endpoints *ServerEndpoints `json:"endpoints"` - OAuth *OAuth `json:"oauth"` + BaseURL string `json:"base_url"` + Endpoints *ServerEndpoints `json:"endpoints"` + OAuth *OAuth `json:"oauth"` Profiles *ServerProfileInfo `json:"profiles"` } type ServerProfile struct { - ID string `json:"profile_id"` - DisplayName string `json:"display_name"` - VPNProtoList []string `json:"vpn_proto_list"` - DefaultGateway bool `json:"default_gateway"` + ID string `json:"profile_id"` + DisplayName string `json:"display_name"` + VPNProtoList []string `json:"vpn_proto_list"` + DefaultGateway bool `json:"default_gateway"` } type ServerProfileInfo struct { Current uint8 `json:"current_profile"` - Info struct { + Info struct { ProfileList []ServerProfile `json:"profile_list"` } `json:"info"` } diff --git a/src/verify.go b/src/verify.go index fc30087..3c87fe1 100644 --- a/src/verify.go +++ b/src/verify.go @@ -3,8 +3,9 @@ package eduvpn import ( "errors" "fmt" - "github.com/jedisct1/go-minisign" "os" + + "github.com/jedisct1/go-minisign" ) // getKeys returns keys taken from https://git.sr.ht/~eduvpn/disco.eduvpn.org#public-keys. diff --git a/src/wireguard.go b/src/wireguard.go index 96e7547..b701b1d 100644 --- a/src/wireguard.go +++ b/src/wireguard.go @@ -2,8 +2,9 @@ package eduvpn import ( "fmt" - "golang.zx2c4.com/wireguard/wgctrl/wgtypes" "regexp" + + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) func wireguardGenerateKey() (wgtypes.Key, error) { |
