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
Julian Merlin
bitmask-vpn
Commits
9f1807c2
Unverified
Commit
9f1807c2
authored
3 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[bug] populate gateways early on
- Closes: #511
parent
514a6a8a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
pkg/backend/gatewaychecker.go
+32
-0
32 additions, 0 deletions
pkg/backend/gatewaychecker.go
pkg/backend/init.go
+1
-0
1 addition, 0 deletions
pkg/backend/init.go
pkg/vpn/main.go
+2
-1
2 additions, 1 deletion
pkg/vpn/main.go
pkg/vpn/openvpn.go
+9
-0
9 additions, 0 deletions
pkg/vpn/openvpn.go
with
44 additions
and
1 deletion
pkg/backend/gatewaychecker.go
0 → 100644
+
32
−
0
View file @
9f1807c2
package
backend
import
(
"time"
)
// The gateway selector gets populated asynchronously, so this spawns a goroutine that
// checks whether they've been fetched to update status.
func
(
c
connectionCtx
)
delayCheckForGateways
()
{
go
func
()
{
cnt
:=
0
for
{
if
cnt
>
60
*
2
{
break
}
time
.
Sleep
(
time
.
Second
*
5
)
transport
:=
c
.
bm
.
GetTransport
()
locs
:=
c
.
bm
.
ListLocationFullness
(
transport
)
if
len
(
locs
)
!=
0
{
c
.
Locations
=
locs
updateStatusForGateways
()
break
}
}
}()
}
func
updateStatusForGateways
()
{
statusMutex
.
Lock
()
defer
statusMutex
.
Unlock
()
go
trigger
(
OnStatusChanged
)
}
This diff is collapsed.
Click to expand it.
pkg/backend/init.go
+
1
−
0
View file @
9f1807c2
...
...
@@ -35,6 +35,7 @@ func initializeContext(opts *InitOpts) {
go
checkErrors
(
errCh
)
initializeBitmask
(
errCh
,
opts
)
go
trigger
(
OnStatusChanged
)
ctx
.
delayCheckForGateways
()
}
func
checkErrors
(
errCh
chan
string
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/vpn/main.go
+
2
−
1
View file @
9f1807c2
...
...
@@ -69,8 +69,9 @@ func Init() (*Bitmask, error) {
*/
err
=
ioutil
.
WriteFile
(
b
.
getTempCaCertPath
(),
config
.
CaCert
,
0600
)
go
b
.
fetchGateways
()
go
b
.
openvpnManagement
()
return
&
b
,
err
}
...
...
This diff is collapsed.
Click to expand it.
pkg/vpn/openvpn.go
+
9
−
0
View file @
9f1807c2
...
...
@@ -219,6 +219,15 @@ func (b *Bitmask) getCert() (certPath string, err error) {
return
certPath
,
err
}
// Explicit call to GetGateways, to be able to fetch them all before starting the vpn
func
(
b
*
Bitmask
)
fetchGateways
()
{
log
.
Println
(
"Fetching gateways..."
)
_
,
err
:=
b
.
bonafide
.
GetAllGateways
(
b
.
transport
)
if
err
!=
nil
{
log
.
Println
(
"ERROR Cannot fetch gateways"
)
}
}
// StopVPN or cancel
func
(
b
*
Bitmask
)
StopVPN
()
error
{
err
:=
b
.
launch
.
firewallStop
()
...
...
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