summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-06-23 19:51:00 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-06-26 12:13:45 +0200
commit0f20d7403f25e8ed7b0d01997be019c561525fba (patch)
treef54803b885c181dffd72a25dc5987f68e6a68a31 /pkg
parent06a7453984adca0b34e62421a1baa8fe54b0d7bb (diff)
[refactor] cleanup function was unneeded
Diffstat (limited to 'pkg')
-rw-r--r--pkg/backend/actions.go4
-rw-r--r--pkg/backend/api.go5
-rw-r--r--pkg/backend/cleanup.go9
-rw-r--r--pkg/vpn/main.go12
4 files changed, 8 insertions, 22 deletions
diff --git a/pkg/backend/actions.go b/pkg/backend/actions.go
index 725a550..ca45347 100644
--- a/pkg/backend/actions.go
+++ b/pkg/backend/actions.go
@@ -19,3 +19,7 @@ func stopVPN() {
log.Println(err)
}
}
+
+func closeVPN() {
+ ctx.bm.Close()
+}
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index cf9ec5c..58e0a42 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -30,10 +30,11 @@ func Unblock() {
func Quit() {
if ctx.Status != off {
go setStatus(stopping)
+ ctx.cfg.SetUserStoppedVPN(false)
+ } else {
ctx.cfg.SetUserStoppedVPN(true)
- stopVPN()
}
- cleanup()
+ closeVPN()
}
func DonateAccepted() {
diff --git a/pkg/backend/cleanup.go b/pkg/backend/cleanup.go
deleted file mode 100644
index 16f36e4..0000000
--- a/pkg/backend/cleanup.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package backend
-
-import (
- "0xacab.org/leap/bitmask-vpn/pkg/vpn"
-)
-
-func cleanup() {
- vpn.Cleanup()
-}
diff --git a/pkg/vpn/main.go b/pkg/vpn/main.go
index f3c5b83..4bf4395 100644
--- a/pkg/vpn/main.go
+++ b/pkg/vpn/main.go
@@ -19,8 +19,6 @@ import (
"io/ioutil"
"log"
"os"
- "path"
- "path/filepath"
"0xacab.org/leap/bitmask-vpn/pkg/config"
"0xacab.org/leap/bitmask-vpn/pkg/vpn/bonafide"
@@ -76,7 +74,7 @@ func (b *Bitmask) GetStatusCh() <-chan string {
return b.statusCh
}
-// Close the connection to bitmask
+// Close the connection to bitmask, and does cleanup of temporal files
func (b *Bitmask) Close() {
log.Printf("Close: cleanup and vpn shutdown...")
b.StopVPN()
@@ -94,11 +92,3 @@ func (b *Bitmask) Close() {
func (b *Bitmask) Version() (string, error) {
return "", nil
}
-
-func Cleanup() {
- dirs, _ := filepath.Glob(path.Join(os.TempDir(), "leap-*"))
- for _, d := range dirs {
- log.Println("removing temp dir:", d)
- os.RemoveAll(d)
- }
-}