summaryrefslogtreecommitdiff
path: root/client/client.go
diff options
context:
space:
mode:
authoratanarjuat <atanarjuat@example.com>2022-06-06 15:04:45 +0200
committeratanarjuat <atanarjuat@example.com>2022-06-06 15:04:45 +0200
commitd50d19ca2ed3d78909316a711060ed0be98555e0 (patch)
treebf451f0b01449fc32eb177eebc4fbd02ef6ae658 /client/client.go
parent0a51eb34640b83a9fcd03ec37911397ad6702ad5 (diff)
refactor conditional for readability
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/client/client.go b/client/client.go
index bd002f1..482f66f 100644
--- a/client/client.go
+++ b/client/client.go
@@ -42,8 +42,8 @@ func (c *Client) Start() (bool, error) {
c.mu.Lock()
defer c.mu.Unlock()
- if c.server != nil {
- log.Printf("Cannot start proxy server if already initialized")
+ if c.started {
+ log.Printf("Cannot start proxy server, already running")
return false, ErrAlreadyRunning
}
@@ -81,7 +81,7 @@ func (c *Client) Stop() (bool, error) {
c.mu.Lock()
defer c.mu.Unlock()
- if c.server == nil {
+ if !c.started || c.server == nil {
return false, ErrNotRunning
}
@@ -90,6 +90,7 @@ func (c *Client) Stop() (bool, error) {
return false, err
}
+ c.started = false
c.server = nil
return true, nil
}