Maint: refactor VPN configuration structure

- Paves the way for Wireguard
- VPN struct contains Type, Openvpn and Provider configurations
- OpenVPN specific options (e.g. client key) moved from Provider to Openvpn configuration struct
- Move Provider configuration from OpenVPN configuration to VPN
- HTTP control server returns only openvpn settings (not provider settings)
This commit is contained in:
Quentin McGaw (desktop)
2021-08-17 15:44:11 +00:00
parent a00de75f61
commit cc2235653a
39 changed files with 372 additions and 301 deletions

View File

@@ -13,9 +13,6 @@ func Test_OpenVPN_JSON(t *testing.T) {
in := OpenVPN{
Root: true,
Flags: []string{},
Provider: Provider{
Name: "name",
},
}
data, err := json.MarshalIndent(in, "", " ")
require.NoError(t, err)
@@ -28,35 +25,10 @@ func Test_OpenVPN_JSON(t *testing.T) {
"run_as_root": true,
"cipher": "",
"auth": "",
"provider": {
"name": "name",
"server_selection": {
"tcp": false,
"regions": null,
"groups": null,
"countries": null,
"cities": null,
"hostnames": null,
"names": null,
"isps": null,
"owned": false,
"custom_port": 0,
"numbers": null,
"encryption_preset": "",
"free_only": false,
"stream_only": false
},
"extra_config": {
"encryption_preset": "",
"openvpn_ipv6": false
},
"port_forwarding": {
"enabled": false,
"filepath": ""
}
},
"custom_config": "",
"version": ""
"version": "",
"encryption_preset": "",
"ipv6": false
}`, string(data))
var out OpenVPN
err = json.Unmarshal(data, &out)