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
Container Registry
Model registry
Operate
Environments
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
leap
bitmask-vpn
Commits
cda7f025
Unverified
Commit
cda7f025
authored
4 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[refactor] fix error handling after review
parent
2f1f3523
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!105
Sip login
Pipeline
#45780
failed
4 years ago
Stage: build
Stage: trigger
Stage: vendor
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/vpn/bonafide/auth_sip.go
+5
-3
5 additions, 3 deletions
pkg/vpn/bonafide/auth_sip.go
pkg/vpn/bonafide/bonafide.go
+4
-4
4 additions, 4 deletions
pkg/vpn/bonafide/bonafide.go
with
9 additions
and
7 deletions
pkg/vpn/bonafide/auth_sip.go
+
5
−
3
View file @
cda7f025
...
...
@@ -70,25 +70,27 @@ func writeToken(token []byte) {
tp
:=
getTokenPath
()
err
:=
ioutil
.
WriteFile
(
tp
,
token
,
0600
)
if
err
!=
nil
{
log
.
Println
(
"BUG: cannot write token to"
,
tp
)
log
.
Println
(
"BUG: cannot write token to"
,
tp
,
err
)
}
}
func
readToken
()
([]
byte
,
error
)
{
f
,
err
:=
os
.
Open
(
getTokenPath
())
if
err
!=
nil
{
log
.
Println
(
"Error: cannot open token file"
)
log
.
Println
(
"Error: cannot open token file"
,
err
)
return
nil
,
err
}
token
,
err
:=
ioutil
.
ReadAll
(
f
)
if
err
!=
nil
{
log
.
Println
(
"Error: cannot read token"
)
log
.
Println
(
"Error: cannot read token"
,
err
)
return
nil
,
err
}
return
token
,
nil
}
func
hasRecentToken
()
bool
{
/* See https://0xacab.org/leap/bitmask-vpn/-/issues/346 for ability to refresh tokens,
when implemented that should be tried in a goroutine */
statinfo
,
err
:=
os
.
Stat
(
getTokenPath
())
if
err
!=
nil
{
return
false
...
...
This diff is collapsed.
Click to expand it.
pkg/vpn/bonafide/bonafide.go
+
4
−
4
View file @
cda7f025
...
...
@@ -239,7 +239,7 @@ func (b *Bonafide) fetchGeolocation() ([]string, error) {
client
:=
&
http
.
Client
{}
_resp
,
err
:=
client
.
Post
(
config
.
GeolocationAPI
,
""
,
nil
)
if
err
!=
nil
{
log
.
Print
ln
(
"ERROR: could not fetch geolocation:
"
,
fmt
.
Errorf
(
"%s
"
,
err
)
)
log
.
Print
f
(
"ERROR: could not fetch geolocation:
%s
\n
"
,
err
)
return
nil
,
err
}
resp
=
_resp
...
...
@@ -247,15 +247,15 @@ func (b *Bonafide) fetchGeolocation() ([]string, error) {
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
200
{
log
.
Println
(
"ERROR: bad status code while fetching geolocation:"
,
fmt
.
Errorf
(
"%s"
,
resp
.
Status
)
)
return
nil
,
fmt
.
Errorf
(
"Get geolocation failed with status: %s"
,
resp
.
Status
)
log
.
Println
(
"ERROR: bad status code while fetching geolocation:"
,
resp
.
Status
Code
)
return
nil
,
fmt
.
Errorf
(
"Get geolocation failed with status: %s"
,
resp
.
Status
Code
)
}
geo
:=
&
geoLocation
{}
dataJSON
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
err
=
json
.
Unmarshal
(
dataJSON
,
&
geo
)
if
err
!=
nil
{
log
.
Print
ln
(
"ERROR: cannot parse geolocation json
"
,
fmt
.
Errorf
(
"%s
"
,
err
)
)
log
.
Print
f
(
"ERROR: cannot parse geolocation json
: %s
\n
"
,
err
)
log
.
Println
(
string
(
dataJSON
))
_
=
fmt
.
Errorf
(
"bad json"
)
return
nil
,
err
...
...
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