Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vladimir KozLove
bitmask-vpn
Commits
fa08af46
Verified
Commit
fa08af46
authored
6 years ago
by
meskio
Browse files
Options
Downloads
Patches
Plain Diff
[feat] autostart the standalone systray if the vpn was on
- Resolves:
#8
parent
2ac0be0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
autostart.go
+16
-0
16 additions, 0 deletions
autostart.go
bitmaskd.go
+4
-0
4 additions, 0 deletions
bitmaskd.go
main.go
+6
-1
6 additions, 1 deletion
main.go
notificator.go
+36
-10
36 additions, 10 deletions
notificator.go
standalone.go
+12
-0
12 additions, 0 deletions
standalone.go
systray.go
+7
-2
7 additions, 2 deletions
systray.go
with
81 additions
and
13 deletions
autostart.go
0 → 100644
+
16
−
0
View file @
fa08af46
package
main
type
autostart
interface
{
Disable
()
error
Enable
()
error
}
type
dummyAutostart
struct
{}
func
(
a
*
dummyAutostart
)
Disable
()
error
{
return
nil
}
func
(
a
*
dummyAutostart
)
Enable
()
error
{
return
nil
}
This diff is collapsed.
Click to expand it.
bitmaskd.go
+
4
−
0
View file @
fa08af46
...
...
@@ -24,3 +24,7 @@ import (
func
initBitmask
()
(
bitmask
.
Bitmask
,
error
)
{
return
bitmaskd
.
Init
()
}
func
newAutostart
(
appName
string
,
iconPath
string
)
autostart
{
return
&
dummyAutostart
{}
}
This diff is collapsed.
Click to expand it.
main.go
+
6
−
1
View file @
fa08af46
...
...
@@ -81,7 +81,12 @@ func main() {
defer
b
.
Close
()
go
checkAndStartBitmask
(
b
,
notify
,
conf
)
run
(
b
,
conf
,
notify
)
as
:=
newAutostart
(
applicationName
,
getIconPath
())
err
=
as
.
Enable
()
if
err
!=
nil
{
log
.
Printf
(
"Error enabling autostart: %v"
,
err
)
}
run
(
b
,
conf
,
notify
,
as
)
}
func
checkAndStartBitmask
(
b
bitmask
.
Bitmask
,
notify
*
notificator
,
conf
*
systrayConfig
)
{
...
...
This diff is collapsed.
Click to expand it.
notificator.go
+
36
−
10
View file @
fa08af46
...
...
@@ -18,6 +18,7 @@ package main
import
(
"os"
"path"
"runtime"
"time"
"0xacab.org/leap/go-dialog"
...
...
@@ -58,7 +59,7 @@ func (n *notificator) donations() {
if
n
.
conf
.
needsNotification
()
{
letsDonate
:=
dialog
.
Message
(
printer
.
Sprintf
(
donationText
,
applicationName
))
.
Title
(
printer
.
Sprintf
(
"Donate"
))
.
Icon
(
get
SVG
Path
())
.
Icon
(
get
Icon
Path
())
.
YesNo
()
n
.
conf
.
setNotification
()
if
letsDonate
{
...
...
@@ -72,32 +73,61 @@ func (n *notificator) donations() {
func
(
n
*
notificator
)
about
(
version
string
)
{
dialog
.
Message
(
printer
.
Sprintf
(
aboutText
,
applicationName
,
version
))
.
Title
(
printer
.
Sprintf
(
"About"
))
.
Icon
(
get
SVG
Path
())
.
Icon
(
get
Icon
Path
())
.
Info
()
}
func
(
n
*
notificator
)
bitmaskNotRunning
()
{
dialog
.
Message
(
printer
.
Sprintf
(
notRunning
))
.
Title
(
printer
.
Sprintf
(
"Can't contact bitmask"
))
.
Icon
(
get
SVG
Path
())
.
Icon
(
get
Icon
Path
())
.
Error
()
}
func
(
n
*
notificator
)
authAgent
()
{
dialog
.
Message
(
printer
.
Sprintf
(
missingAuthAgent
))
.
Title
(
printer
.
Sprintf
(
"Missing authentication agent"
))
.
Icon
(
get
SVG
Path
())
.
Icon
(
get
Icon
Path
())
.
Error
()
}
func
(
n
*
notificator
)
errorStartingVPN
(
err
error
)
{
dialog
.
Message
(
printer
.
Sprintf
(
errorStartingVPN
,
applicationName
,
err
))
.
Title
(
printer
.
Sprintf
(
"Error starting VPN"
))
.
Icon
(
get
SVG
Path
())
.
Icon
(
get
Icon
Path
())
.
Error
()
}
func
getSVGPath
()
string
{
func
getIconPath
()
string
{
gopath
:=
os
.
Getenv
(
"GOPATH"
)
if
gopath
==
""
{
gopath
=
path
.
Join
(
os
.
Getenv
(
"HOME"
),
"go"
)
}
if
runtime
.
GOOS
==
"windows"
{
icoPath
:=
`C:\Program Files\RiseupVPN\riseupvpn.ico`
if
fileExist
(
icoPath
)
{
return
icoPath
}
icoPath
=
path
.
Join
(
gopath
,
"src"
,
"0xacab.org"
,
"leap"
,
"riseup_vpn"
,
"assets"
,
"riseupvpn.ico"
)
if
fileExist
(
icoPath
)
{
return
icoPath
}
return
""
}
if
runtime
.
GOOS
==
"darwin"
{
icnsPath
:=
"/Applications/RiseupVPN.app/Contents/Resources/app.icns"
if
fileExist
(
icnsPath
)
{
return
icnsPath
}
icnsPath
=
path
.
Join
(
gopath
,
"src"
,
"0xacab.org"
,
"leap"
,
"riseup_vpn"
,
"assets"
,
"riseupvpn.icns"
)
if
fileExist
(
icnsPath
)
{
return
icnsPath
}
return
""
}
snapPath
:=
os
.
Getenv
(
"SNAP"
)
if
snapPath
!=
""
{
return
snapPath
+
"/snap/gui/riseupvpn.svg"
...
...
@@ -114,10 +144,6 @@ func getSVGPath() string {
return
svgPath
}
gopath
:=
os
.
Getenv
(
"GOPATH"
)
if
gopath
==
""
{
gopath
=
path
.
Join
(
os
.
Getenv
(
"HOME"
),
"go"
)
}
svgPath
=
path
.
Join
(
gopath
,
"src"
,
"0xacab.org"
,
"leap"
,
"bitmask-systray"
,
svgFileName
)
if
fileExist
(
svgPath
)
{
return
svgPath
...
...
This diff is collapsed.
Click to expand it.
standalone.go
+
12
−
0
View file @
fa08af46
...
...
@@ -17,10 +17,22 @@
package
main
import
(
"os"
"0xacab.org/leap/bitmask-systray/bitmask"
standalone
"0xacab.org/leap/bitmask-systray/standalone"
pmautostart
"github.com/ProtonMail/go-autostart"
)
func
initBitmask
()
(
bitmask
.
Bitmask
,
error
)
{
return
standalone
.
Init
()
}
func
newAutostart
(
appName
string
,
iconPath
string
)
autostart
{
return
&
pmautostart
.
App
{
Name
:
appName
,
Exec
:
os
.
Args
,
DisplayName
:
appName
,
Icon
:
iconPath
,
}
}
This diff is collapsed.
Click to expand it.
systray.go
+
7
−
2
View file @
fa08af46
...
...
@@ -39,6 +39,7 @@ type bmTray struct {
mDonate
*
systray
.
MenuItem
mCancel
*
systray
.
MenuItem
activeGateway
*
gatewayTray
autostart
autostart
}
type
gatewayTray
struct
{
...
...
@@ -46,8 +47,8 @@ type gatewayTray struct {
name
string
}
func
run
(
bm
bitmask
.
Bitmask
,
conf
*
systrayConfig
,
notify
*
notificator
)
{
bt
:=
bmTray
{
bm
:
bm
,
conf
:
conf
,
notify
:
notify
}
func
run
(
bm
bitmask
.
Bitmask
,
conf
*
systrayConfig
,
notify
*
notificator
,
as
autostart
)
{
bt
:=
bmTray
{
bm
:
bm
,
conf
:
conf
,
notify
:
notify
,
autostart
:
as
}
systray
.
Run
(
bt
.
onReady
,
bt
.
onExit
)
}
...
...
@@ -131,6 +132,10 @@ func (bt *bmTray) onReady() {
bt
.
notify
.
about
(
versionStr
)
case
<-
mQuit
.
ClickedCh
:
err
:=
bt
.
autostart
.
Disable
()
if
err
!=
nil
{
log
.
Printf
(
"Error disabling autostart: %v"
,
err
)
}
systray
.
Quit
()
case
<-
signalCh
:
systray
.
Quit
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment