diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-20 16:22:07 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-20 16:22:07 +0200 |
| commit | b73e1489b06fd4546da6ba32697331584db02e71 (patch) | |
| tree | 3893b79958b551d2552efb6d20e729d916346ec6 /src/state.go | |
| parent | 63dfe633c7e62f570d44af6e0ea17967155cb5db (diff) | |
Refactor: Eliminate most uses of pointers in structs
Diffstat (limited to 'src/state.go')
| -rw-r--r-- | src/state.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/state.go b/src/state.go index 6c740c1..76cd635 100644 --- a/src/state.go +++ b/src/state.go @@ -12,16 +12,16 @@ type VPNState struct { StateCallbackData string `json:"-"` // The chosen server - Server *Server `json:"server"` + Server Server `json:"server"` // The list of servers and organizations from disco - DiscoList *DiscoList `json:"disco"` + DiscoList DiscoList `json:"disco"` // The file we keep open for logging - LogFile *FileLogger `json:"-"` + LogFile FileLogger `json:"-"` // The fsm - FSM *FSM `json:"-"` + FSM FSM `json:"-"` // Whether to enable debugging Debug bool `json:"-"` @@ -66,21 +66,21 @@ func (state *VPNState) Deregister() error { state.WriteConfig() // Re-initialize the server and FSM - state.Server = &Server{} + state.Server = Server{} state.InitializeFSM() return nil } func (state *VPNState) Connect(url string) (string, error) { - if state.Server == nil || state.Server.BaseURL != url { - state.Server = &Server{} + // New server chosen, ensure the server is fresh + if state.Server.BaseURL != url { + state.Server = Server{} } initializeErr := state.Server.Initialize(url) if initializeErr != nil { return "", initializeErr } - // Relogin with oauth // This moves the state to authenticated if state.Server.NeedsRelogin() { |
