diff options
author | cyBerta <cyberta@riseup.net> | 2022-06-23 00:41:32 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2022-06-23 00:41:32 +0200 |
commit | 295f071ce87dacd59f1b57fc90ea9803aadaa9cf (patch) | |
tree | 4e6ed376ce76c74be558b22bd3d905678351f13a /client | |
parent | f4113a5dfa178f1fe86c04b2f196842c83e2bffe (diff) |
fix started state tracking
Diffstat (limited to 'client')
-rw-r--r-- | client/client.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/client/client.go b/client/client.go index d4a7976..d9cb12b 100644 --- a/client/client.go +++ b/client/client.go @@ -24,7 +24,6 @@ type Client struct { socksAddr string obfs4Cert string server *socks5.Server - started bool EventLogger EventLogger } @@ -46,8 +45,8 @@ func (c *Client) Start() (bool, error) { c.log("STOPPED", "", nil) } - if c.started { - log.Printf("Cannot start proxy server, already running") + if c.IsStarted() { + c.error("Cannot start proxy server, already running") return false, ErrAlreadyRunning } @@ -77,13 +76,11 @@ func (c *Client) Start() (bool, error) { c.server = nil return false, err } - c.started = true return true, nil } func (c *Client) Stop() (bool, error) { - - if !c.started || c.server == nil { + if !c.IsStarted() { return false, ErrNotRunning } @@ -92,7 +89,6 @@ func (c *Client) Stop() (bool, error) { return false, err } - c.started = false c.server = nil return true, nil } @@ -113,3 +109,7 @@ func (c *Client) error(format string, a ...interface{}) { } log.Printf(format, a...) } + +func (c *Client) IsStarted() bool { + return c.server != nil +} |