diff --git a/Makefile b/Makefile index a435bcdea406a56278350a7b68021cc8d0cf88bd..209e71cb8dbb792ae95767e471c6d73c49ddfe91 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 e1a31c9c06d573cc263dd8648c1d9487c5c9c841..69191435dd9ee571e8735994934a75c445a956c0 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 4f223a24a0a21e630eded41b3c95565d7798a698..2bfd94dbd22c0de4f163e745daf83dff0190ac45 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 similarity index 100% rename from scripts/templates/eip-service.json.jinja rename to 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 0000000000000000000000000000000000000000..9dd549870876b4580fbe70d51fb91c2ee83d2be1 --- /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) }} +}