diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-11-28 14:29:12 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-11-28 14:29:12 +0100 |
| commit | 0bfb35520d7e138e6219e550187e0b55bc8a29ac (patch) | |
| tree | a087049edae0ff932bc7a14fef323783b26a2ff1 /internal | |
| parent | 59e6ccd051452162fab852a25deb4f0f8a9e22b2 (diff) | |
Formatting: Run gofumpt -w
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/config/config.go | 2 | ||||
| -rw-r--r-- | internal/discovery/discovery.go | 5 | ||||
| -rw-r--r-- | internal/fsm/fsm.go | 15 | ||||
| -rw-r--r-- | internal/log/log.go | 2 | ||||
| -rw-r--r-- | internal/oauth/oauth.go | 33 | ||||
| -rw-r--r-- | internal/oauth/token.go | 13 | ||||
| -rw-r--r-- | internal/server/common.go | 12 | ||||
| -rw-r--r-- | internal/server/secureinternet.go | 2 |
8 files changed, 42 insertions, 42 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index bea97f7..96ce742 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -18,7 +18,7 @@ type Config struct { Directory string // Name defines the name of file excluding the .json extension - Name string + Name string } // Init initializes the configuration using the provided directory and name. diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 40fa165..35c2689 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -11,14 +11,13 @@ import ( "github.com/eduvpn/eduvpn-common/types" ) - // Discovery is the main structure used for this package. type Discovery struct { // organizations represents the organizations that are returned by the discovery server organizations types.DiscoveryOrganizations // servers represents the servers that are returned by the discovery server - servers types.DiscoveryServers + servers types.DiscoveryServers } // discoFile is a helper function that gets a disco JSON and fills the structure with it @@ -79,7 +78,7 @@ func (discovery *Discovery) DetermineOrganizationsUpdate() bool { return discovery.organizations.Timestamp.IsZero() } -// SecureLocationList returns a slice of all the available locations. +// SecureLocationList returns a slice of all the available locations. func (discovery *Discovery) SecureLocationList() []string { var locations []string for _, currentServer := range discovery.servers.List { diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index 4114a32..0163fed 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -8,12 +8,13 @@ import ( "os/exec" "path" "sort" + "github.com/eduvpn/eduvpn-common/types" ) type ( // StateID represents the Identifier of the state. - StateID int8 + StateID int8 // StateIDSlice represents the list of state identifiers. StateIDSlice []StateID ) @@ -33,7 +34,7 @@ func (v StateIDSlice) Swap(i, j int) { // Transition indicates an arrow in the state graph. type Transition struct { // To represents the to-be-new state - To StateID + To StateID // Description is what type of message the arrow gets in the graph Description string } @@ -51,26 +52,26 @@ type State struct { // FSM represents the total graph. type FSM struct { // States is the map from state ID to states - States States + States States // Current is the current state represented by the identifier Current StateID // Name represents the descriptive name of this state machine - Name string + Name string // StateCallback is the function ran when a transition occurs // It takes the old state, the new state and the data and returns if this is handled by the client StateCallback func(StateID, StateID, interface{}) bool // Directory represents the path where the state graph is stored - Directory string + Directory string // Generate represents whether we want to generate the graph - Generate bool + Generate bool // GetStateName gets the name of a state as a string - GetStateName func(StateID) string + GetStateName func(StateID) string } // Init initializes the state machine and sets it to the given current state. diff --git a/internal/log/log.go b/internal/log/log.go index 43bc737..67e41fa 100644 --- a/internal/log/log.go +++ b/internal/log/log.go @@ -19,7 +19,7 @@ type FileLogger struct { Level Level // file represents a pointer to the open log file - file *os.File + file *os.File } type Level int8 diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 3c1e5d6..6abdb7f 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -57,11 +57,13 @@ func genChallengeS256(verifier string) string { // minimum length of 43 characters and a maximum length of 128 // characters. // We implement it according to the note: -// NOTE: The code verifier SHOULD have enough entropy to make it -// impractical to guess the value. It is RECOMMENDED that the output of -// a suitable random number generator be used to create a 32-octet -// sequence. The octet sequence is then base64url-encoded to produce a -// 43-octet URL safe string to use as the code verifier. +// +// NOTE: The code verifier SHOULD have enough entropy to make it +// impractical to guess the value. It is RECOMMENDED that the output of +// a suitable random number generator be used to create a 32-octet +// sequence. The octet sequence is then base64url-encoded to produce a +// 43-octet URL safe string to use as the code verifier. +// // See: https://datatracker.ietf.org/doc/html/rfc7636#section-4.1 func genVerifier() (string, error) { randomBytes, err := util.MakeRandomByteSlice(32) @@ -78,19 +80,19 @@ func genVerifier() (string, error) { // OAuth defines the main structure for this package. type OAuth struct { // ISS indicates the issuer indentifier of the authorization server as defined in RFC 9207 - ISS string `json:"iss"` + ISS string `json:"iss"` // BaseAuthorizationURL is the URL where authorization should take place - BaseAuthorizationURL string `json:"base_authorization_url"` + BaseAuthorizationURL string `json:"base_authorization_url"` // TokenURL is the URL where tokens should be obtained - TokenURL string `json:"token_url"` + TokenURL string `json:"token_url"` // session is the internal in progress OAuth session - session ExchangeSession `json:"-"` + session ExchangeSession `json:"-"` // Token is where the access and refresh tokens are stored along with the timestamps - token Token `json:"-"` + token Token `json:"-"` } // ExchangeSession is a structure that gets passed to the callback for easy access to the current state. @@ -102,19 +104,19 @@ type ExchangeSession struct { ClientID string // ISS indicates the issuer inditifer - ISS string + ISS string // State is the expected URL state paremeter - State string + State string // Verifier is the preimage of the challenge Verifier string // Context is the context used for cancellation - Context context.Context + Context context.Context // Server is the server of the session - Server *http.Server + Server *http.Server // Listener is the listener where the servers 'listens' on Listener net.Listener @@ -332,7 +334,7 @@ main { // oauthResponseHTML is a structure that is used to give back the OAuth response. type oauthResponseHTML struct { - Title string + Title string Message string } @@ -385,7 +387,6 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { ) return } - } // Make sure the state is present and matches to protect against cross-site request forgeries diff --git a/internal/oauth/token.go b/internal/oauth/token.go index eb79357..bd17647 100644 --- a/internal/oauth/token.go +++ b/internal/oauth/token.go @@ -5,26 +5,25 @@ import "time" // TokenResponse defines the OAuth response from the server that includes the tokens. type TokenResponse struct { // Access is the access token returned by the server - Access string `json:"access_token"` + Access string `json:"access_token"` // Refresh token is the refresh token returned by the server - Refresh string `json:"refresh_token"` + Refresh string `json:"refresh_token"` // Type indicates which type of tokens we have - Type string `json:"token_type"` + Type string `json:"token_type"` // Expires is the expires time returned by the server - Expires int64 `json:"expires_in"` - + Expires int64 `json:"expires_in"` } // Token is a structure that contains our access and refresh tokens and a timestamp when they expire. type Token struct { // Access is the access token returned by the server - access string + access string // Refresh token is the refresh token returned by the server - refresh string + refresh string // ExpiredTimestamp is the Expires field but converted to a Go timestamp expiredTimestamp time.Time diff --git a/internal/server/common.go b/internal/server/common.go index e8c8e51..e8eedd0 100644 --- a/internal/server/common.go +++ b/internal/server/common.go @@ -15,8 +15,8 @@ type Base struct { URL string `json:"base_url"` DisplayName map[string]string `json:"display_name"` SupportContact []string `json:"support_contact"` - Endpoints Endpoints `json:"endpoints"` - Profiles ProfileInfo `json:"profiles"` + Endpoints Endpoints `json:"endpoints"` + Profiles ProfileInfo `json:"profiles"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"expire_time"` Type string `json:"server_type"` @@ -35,7 +35,7 @@ type Servers struct { CustomServers InstituteAccessServers `json:"custom_servers"` InstituteServers InstituteAccessServers `json:"institute_servers"` SecureInternetHomeServer SecureInternetHomeServer `json:"secure_internet_home"` - IsType Type `json:"is_secure_internet"` + IsType Type `json:"is_secure_internet"` } type Server interface { @@ -60,7 +60,7 @@ type ProfileListInfo struct { } type ProfileInfo struct { - Current string `json:"current_profile"` + Current string `json:"current_profile"` Info ProfileListInfo `json:"info"` } @@ -503,10 +503,10 @@ func Config(server Server, clientSupportsWireguard bool, preferTCP bool) (string // A wireguard connect call needs to generate a wireguard key and add it to the config // Also the server could send back an OpenVPN config if it supports OpenVPN config, configType, configErr = wireguardGetConfig(server, preferTCP, supportsOpenVPN) - // The config only supports OpenVPN + // The config only supports OpenVPN } else if supportsOpenVPN { config, configType, configErr = openVPNGetConfig(server, preferTCP) - // The config supports no available protocol because the profile only supports WireGuard but the client doesn't + // The config supports no available protocol because the profile only supports WireGuard but the client doesn't } else { return "", "", types.NewWrappedError(errorMessage, errors.New("no supported protocol found")) } diff --git a/internal/server/secureinternet.go b/internal/server/secureinternet.go index fa4c9c9..998390d 100644 --- a/internal/server/secureinternet.go +++ b/internal/server/secureinternet.go @@ -12,7 +12,7 @@ import ( // A secure internet server which has its own OAuth tokens // It specifies the current location url it is connected to. type SecureInternetHomeServer struct { - Auth oauth.OAuth `json:"oauth"` + Auth oauth.OAuth `json:"oauth"` DisplayName map[string]string `json:"display_name"` // The home server has a list of info for each configured server location |
