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
3cb8f572
Unverified
Commit
3cb8f572
authored
5 years ago
by
Kali Kaneko
Committed by
meskio
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[refactor] rename things
parent
336cae5c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
branding/scripts/check-ca-crt.py
+46
-0
46 additions, 0 deletions
branding/scripts/check-ca-crt.py
branding/scripts/vendorize.py
+99
-0
99 additions, 0 deletions
branding/scripts/vendorize.py
branding/template/config.go
+32
-0
32 additions, 0 deletions
branding/template/config.go
with
177 additions
and
0 deletions
branding/scripts/check-ca-crt.py
0 → 100755
+
46
−
0
View file @
3cb8f572
#!/usr/bin/env python3
import
re
import
sys
import
urllib.request
SCRIPT_NAME
=
'
check-ca-crt.py
'
USAGE
=
'''
Check that the stored provider CA matches the one announced online.
Usage: {name} <provider> <uri>
Example: {name} riseup black.riseup.net
'''
.
format
(
name
=
SCRIPT_NAME
)
def
getLocalCert
(
provider
):
sanitized
=
re
.
sub
(
r
'
[^\w\s-]
'
,
''
,
provider
).
strip
().
lower
()
with
open
(
'
config/{provider}-ca.crt
'
.
format
(
provider
=
sanitized
))
as
crt
:
return
crt
.
read
().
strip
()
def
getRemoteCert
(
uri
):
fp
=
urllib
.
request
.
urlopen
(
'
https://
'
+
uri
+
'
/ca.crt
'
)
remote_cert
=
fp
.
read
().
decode
(
'
utf-8
'
).
strip
()
fp
.
close
()
return
remote_cert
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
!=
3
:
print
(
'
[!] Not enough arguments
'
)
print
(
USAGE
)
sys
.
exit
(
1
)
provider
=
sys
.
argv
[
1
]
uri
=
sys
.
argv
[
2
]
local
=
getLocalCert
(
provider
)
remote
=
getRemoteCert
(
uri
)
try
:
assert
local
==
remote
except
AssertionError
:
print
(
'
[!] ERROR: remote and local CA certs do not match
'
)
sys
.
exit
(
1
)
else
:
print
(
'
OK
'
)
This diff is collapsed.
Click to expand it.
branding/scripts/vendorize.py
0 → 100755
+
99
−
0
View file @
3cb8f572
#!/usr/bin/env python3
import
os
import
sys
from
string
import
Template
import
configparser
OUTFILE
=
'
config.go
'
INFILE
=
'
config.go.tmpl
'
CONFIGFILE
=
'
config/vendor.conf
'
SCRIPT_NAME
=
'
vendorize
'
def
getProviderData
(
config
):
default
=
config
[
'
default
'
][
'
provider
'
]
print
(
"
[+] Configured provider:
"
,
default
)
c
=
config
[
default
]
d
=
dict
()
keys
=
(
'
name
'
,
'
applicationName
'
,
'
binaryName
'
,
'
providerURL
'
,
'
tosURL
'
,
'
helpURL
'
,
'
donateURL
'
,
'
apiURL
'
,
'
geolocationAPI
'
,
'
caCertString
'
)
for
value
in
keys
:
d
[
value
]
=
c
.
get
(
value
)
return
d
def
addCaData
(
data
,
configfile
):
provider
=
data
.
get
(
'
name
'
).
lower
()
folder
,
f
=
os
.
path
.
split
(
configfile
)
caFile
=
os
.
path
.
join
(
folder
,
provider
+
'
-ca.crt
'
)
if
not
os
.
path
.
isfile
(
caFile
):
bail
(
'
[!] Cannot find CA file in {path}
'
.
format
(
path
=
caFile
))
with
open
(
caFile
)
as
ca
:
data
[
'
caCertString
'
]
=
ca
.
read
().
strip
()
def
writeOutput
(
data
,
infile
,
outfile
):
with
open
(
infile
)
as
infile
:
s
=
Template
(
infile
.
read
())
with
open
(
outfile
,
'
w
'
)
as
outf
:
outf
.
write
(
s
.
substitute
(
data
))
def
bail
(
msg
=
None
):
if
not
msg
:
print
(
'
Usage: {scriptname}.py <template> <config> <output>
'
.
format
(
scriptname
=
SCRIPT_NAME
))
else
:
print
(
msg
)
sys
.
exit
(
1
)
if
__name__
==
"
__main__
"
:
infile
=
outfile
=
""
if
len
(
sys
.
argv
)
>
4
:
bail
()
elif
len
(
sys
.
argv
)
==
1
:
infile
=
INFILE
outfile
=
OUTFILE
configfile
=
CONFIGFILE
else
:
try
:
infile
=
sys
.
argv
[
1
]
configfile
=
sys
.
argv
[
2
]
outfile
=
sys
.
argv
[
3
]
except
IndexError
:
bail
()
if
not
os
.
path
.
isfile
(
infile
):
bail
(
'
[!] Cannot find template in {path}
'
.
format
(
path
=
os
.
path
.
abspath
(
infile
)))
elif
not
os
.
path
.
isfile
(
configfile
):
bail
(
'
[!] Cannot find config in {path}
'
.
format
(
path
=
os
.
path
.
abspath
(
configfile
)))
else
:
print
(
'
[+] Using {path} as template
'
.
format
(
path
=
os
.
path
.
abspath
(
infile
)))
print
(
'
[+] Using {path} as config
'
.
format
(
path
=
os
.
path
.
abspath
(
configfile
)))
config
=
configparser
.
ConfigParser
()
config
.
read
(
configfile
)
data
=
getProviderData
(
config
)
addCaData
(
data
,
configfile
)
writeOutput
(
data
,
infile
,
outfile
)
print
(
'
[+] Wrote configuration for {provider} to {outf}
'
.
format
(
provider
=
data
.
get
(
'
name
'
),
outf
=
os
.
path
.
abspath
(
outfile
)))
This diff is collapsed.
Click to expand it.
branding/template/config.go
0 → 100644
+
32
−
0
View file @
3cb8f572
/*
DO NOT EDIT --------------------------------------------------
This file has been automatically generated by `go generate`.
Any changes will be overriden.
DO NOT EDIT --------------------------------------------------
*/
package
config
/* All these constants are defined in the vendor.conf file
*/
const
(
Provider
=
"$providerURL"
ApplicationName
=
"$applicationName"
BinaryName
=
"$binaryName"
DonateURL
=
"$donateURL"
HelpURL
=
"$helpURL"
TosURL
=
"$tosURL"
APIURL
=
"$apiURL"
GeolocationAPI
=
"$geolocationAPI"
)
/*
CaCert : a string containing a representation of the provider CA, used to
sign the webapp and openvpn certificates. should be placed in
config/[provider]-ca.crt
*/
var
CaCert
=
[]
byte
(
`$caCertString`
)
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