summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkwadronaut <kwadronaut@autistici.org>2021-02-23 15:44:34 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-05-27 20:45:06 +0200
commitbbe82d29b8f97bda48ea27e76d0a60d1caa99b85 (patch)
tree2c37c2ea1d14b659b719950514407ff86a874812
parentb32696ea1c07c823b806b00b44ee71d1e9d09c30 (diff)
[feat] add eip v4HEAD1.0master
- Closes: #16
-rw-r--r--Makefile10
-rwxr-xr-xconfig/CONFIG1
-rw-r--r--main.go9
-rw-r--r--scripts/templates/v3/eip-service.json.jinja (renamed from scripts/templates/eip-service.json.jinja)0
-rw-r--r--scripts/templates/v4/eip-service.json.jinja34
5 files changed, 49 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index a435bcd..209e71c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,8 @@
CONFIG=config/demo.yaml
-EIP_TEMPLATE=scripts/templates/eip-service.json.jinja
-EIP_SERVICE=deploy/public/3/eip-service.json
+EIP_TEMPLATE_3=scripts/templates/3/eip-service.json.jinja
+EIP_TEMPLATE_4=scripts/templates/4/eip-service.json.jinja
+EIP_SERVICE_3=deploy/public/3/eip-service.json
+EIP_SERVICE_4=deploy/public/4/eip-service.json
PROVIDER_TEMPLATE=scripts/templates/provider.json.jinja
PROVIDER=deploy/public/provider.json
@@ -17,7 +19,9 @@ gen-shapeshifter:
scripts/gen-shapeshifter-state.py deploy/shapeshifter-state
gen-provider:
mkdir -p deploy/public/3
- @python3 scripts/simplevpn.py --file=eip --config=$(CONFIG) --template=$(EIP_TEMPLATE) --obfs4_state deploy/shapeshifter-state > $(EIP_SERVICE) || echo "ERROR: see $(EIP_SERVICE) for output"
+ mkdir -p deploy/public/4
+ @python3 scripts/simplevpn.py --file=eip --config=$(CONFIG) --template=$(EIP_TEMPLATE_3) --obfs4_state deploy/shapeshifter-state > $(EIP_SERVICE_3) || echo "ERROR: see $(EIP_SERVICE_3) for output"
+ @python3 scripts/simplevpn.py --file=eip --config=$(CONFIG) --template=$(EIP_TEMPLATE_4) --obfs4_state deploy/shapeshifter-state > $(EIP_SERVICE_4) || echo "ERROR: see $(EIP_SERVICE_4) for output"
@python3 scripts/simplevpn.py --file=provider --config=$(CONFIG) --template=$(PROVIDER_TEMPLATE) > $(PROVIDER) || echo "ERROR: see $(PROVIDER) for output"
rsync -ra deploy/public/ public/
populate:
diff --git a/config/CONFIG b/config/CONFIG
index e1a31c9..6919143 100755
--- a/config/CONFIG
+++ b/config/CONFIG
@@ -1,6 +1,7 @@
# general variables
export VPNWEB_API_PATH="./public"
+export VPNWEB_API_VERSION="4"
export VPNWEB_PROVIDER_CA="./public/ca.crt"
export VPNWEB_AUTH=sip2
export VPNWEB_CAKEY=test/files/ca.key
diff --git a/main.go b/main.go
index 4f223a2..2bfd94d 100644
--- a/main.go
+++ b/main.go
@@ -29,11 +29,16 @@ func main() {
/* static files */
+ web.HttpFileHandler(srv, "/provider.json", filepath.Join(opts.ApiPath, "provider.json"))
+ web.HttpFileHandler(srv, "/ca.crt", opts.ProviderCaPath)
web.HttpFileHandler(srv, "/3/configs.json", filepath.Join(opts.ApiPath, "3", "configs.json"))
web.HttpFileHandler(srv, "/3/service.json", filepath.Join(opts.ApiPath, "3", "service.json"))
web.HttpFileHandler(srv, "/3/config/eip-service.json", filepath.Join(opts.ApiPath, "3", "eip-service.json"))
- web.HttpFileHandler(srv, "/provider.json", filepath.Join(opts.ApiPath, "provider.json"))
- web.HttpFileHandler(srv, "/ca.crt", opts.ProviderCaPath)
+
+ web.HttpFileHandler(srv, "/4/configs.json", filepath.Join(opts.ApiPath, "4", "configs.json"))
+ web.HttpFileHandler(srv, "/4/service.json", filepath.Join(opts.ApiPath, "4", "service.json"))
+ web.HttpFileHandler(srv, "/4/config/eip-service.json", filepath.Join(opts.ApiPath, "4", "eip-service.json"))
+ web.HttpFileHandler(srv, "/4/ca.crt", opts.ProviderCaPath)
mtr := http.NewServeMux()
mtr.Handle("/metrics", promhttp.Handler())
diff --git a/scripts/templates/eip-service.json.jinja b/scripts/templates/v3/eip-service.json.jinja
index 5d55168..5d55168 100644
--- a/scripts/templates/eip-service.json.jinja
+++ b/scripts/templates/v3/eip-service.json.jinja
diff --git a/scripts/templates/v4/eip-service.json.jinja b/scripts/templates/v4/eip-service.json.jinja
new file mode 100644
index 0000000..9dd5498
--- /dev/null
+++ b/scripts/templates/v4/eip-service.json.jinja
@@ -0,0 +1,34 @@
+{
+ "serial": 4,
+ "version": 4,
+ "locations": { {% for loc in locations %}
+ "{{loc}}": {
+ "name": "{{ locations[loc]['name'] }}",
+ "country_code": "{{ locations[loc]['country_code'] }}",
+ "hemisphere": "{{ locations[loc]['hemisphere'] }}",
+ "timezone": "{{ locations[loc]['timezone'] }}"
+ }{{ "," if not loop.last }}{% endfor %}
+ },
+ "gateways": [ {% for gw in gateways %}
+ {
+ "host": "{{ gateways[gw]["host"] }}",
+ "ip_address": "{{ gateways[gw]["ip_address"] }}",
+ "ip_address6": "{{ gateways[gw]["ip_address6"] }}",
+ "location": "{{ gateways[gw]["location"] }}",
+ "capabilities": {
+ "adblock": false,
+ "filter_dns": false,
+ "limited": false,
+ "transport": [ {% for tr, proto, port, options in gateways[gw]["transports"] %}
+ {"type": "{{ tr }}",
+ "protocols": ["{{ proto }}"],{% if options %}
+ "options": {{ options | tojson }},{% endif %}
+ "ports": ["{{ port }}"]
+ }{{ "," if not loop.last }}{% endfor %}
+ ]
+ }
+ }{{ "," if not loop.last }}{% endfor %}
+ ],
+ "auth": "{{ auth }}",
+ "openvpn_configuration": {{ openvpn|tojson(indent=8) }}
+}