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
399360bd
Commit
399360bd
authored
4 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
fix uninitialized byCity bug
parent
34e24135
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/vpn/bonafide/gateways.go
+10
-7
10 additions, 7 deletions
pkg/vpn/bonafide/gateways.go
with
10 additions
and
7 deletions
pkg/vpn/bonafide/gateways.go
+
10
−
7
View file @
399360bd
...
...
@@ -79,8 +79,13 @@ func (p *gatewayPool) populateCityList() {
func
(
p
*
gatewayPool
)
getCities
()
[]
string
{
c
:=
make
([]
string
,
0
)
for
city
,
_
:=
range
p
.
byCity
{
c
=
append
(
c
,
city
)
if
p
==
nil
||
p
.
byCity
==
nil
||
len
(
p
.
byCity
)
==
0
{
return
c
}
if
len
(
p
.
byCity
)
!=
0
{
for
city
:=
range
p
.
byCity
{
c
=
append
(
c
,
city
)
}
}
return
c
}
...
...
@@ -196,9 +201,8 @@ func (p *gatewayPool) getBest(transport string, tz, max int) ([]Gateway, error)
func
(
p
*
gatewayPool
)
getAll
(
transport
string
,
tz
int
)
([]
Gateway
,
error
)
{
if
len
(
p
.
recommended
)
!=
0
{
return
p
.
getGatewaysFromMenshen
(
transport
,
999
)
}
else
{
return
p
.
getGatewaysByTimezone
(
transport
,
tz
,
999
)
}
return
p
.
getGatewaysByTimezone
(
transport
,
tz
,
999
)
}
/* picks at most max gateways, filtering by transport, from the ordered list menshen returned */
...
...
@@ -235,9 +239,8 @@ func (p *gatewayPool) getGatewaysByTimezone(transport string, tzOffsetHours, max
if
err
!=
nil
{
log
.
Printf
(
"Error sorting gateways: %v"
,
err
)
return
gws
,
err
}
else
{
distance
=
tzDistance
(
tzOffsetHours
,
gwOffset
)
}
distance
=
tzDistance
(
tzOffsetHours
,
gwOffset
)
gwVector
=
append
(
gwVector
,
gatewayDistance
{
gw
,
distance
})
}
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
...
...
@@ -262,7 +265,7 @@ func newGatewayPool(eip *eipService) *gatewayPool {
p
:=
gatewayPool
{}
p
.
available
=
eip
.
getGateways
()
p
.
locations
=
eip
.
Locations
p
.
byCity
=
make
(
map
[
string
][]
string
,
0
)
p
.
byCity
=
make
(
map
[
string
][]
string
)
p
.
populateCityList
()
return
&
p
}
...
...
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