feat: add VPNsecure.me support (#848)
- `OPENVPN_ENCRYPTED_KEY` environment variable - `OPENVPN_ENCRYPTED_KEY_SECRETFILE` environment variable - `OPENVPN_KEY_PASSPHRASE` environment variable - `OPENVPN_KEY_PASSPHRASE_SECRETFILE` environment variable - `PREMIUM_ONLY` environment variable - OpenVPN user and password not required for vpnsecure provider
This commit is contained in:
@@ -40,6 +40,10 @@ func filterServer(server models.Server,
|
||||
return true
|
||||
}
|
||||
|
||||
if *selection.PremiumOnly && !server.Premium {
|
||||
return true
|
||||
}
|
||||
|
||||
if *selection.StreamOnly && !server.Stream {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -88,6 +88,19 @@ func Test_FilterServers(t *testing.T) {
|
||||
{Free: true, VPN: vpn.OpenVPN, UDP: true},
|
||||
},
|
||||
},
|
||||
"filter by premium only": {
|
||||
selection: settings.ServerSelection{
|
||||
PremiumOnly: boolPtr(true),
|
||||
}.WithDefaults(providers.Surfshark),
|
||||
servers: []models.Server{
|
||||
{Premium: false, VPN: vpn.OpenVPN, UDP: true},
|
||||
{Premium: true, VPN: vpn.OpenVPN, UDP: true},
|
||||
{Premium: false, VPN: vpn.OpenVPN, UDP: true},
|
||||
},
|
||||
filtered: []models.Server{
|
||||
{Premium: true, VPN: vpn.OpenVPN, UDP: true},
|
||||
},
|
||||
},
|
||||
"filter by stream only": {
|
||||
selection: settings.ServerSelection{
|
||||
StreamOnly: boolPtr(true),
|
||||
|
||||
@@ -189,6 +189,13 @@ func OpenVPNConfig(provider OpenVPNProviderSettings,
|
||||
lines.addLines(WrapOpenvpnTLSCrypt(provider.TLSCrypt))
|
||||
}
|
||||
|
||||
if *settings.EncryptedKey != "" {
|
||||
lines.add("askpass", openvpn.AskPassPath)
|
||||
keyData, err := extract.PEM([]byte(*settings.EncryptedKey))
|
||||
panicOnError(err, "cannot extract PEM encrypted key")
|
||||
lines.addLines(WrapOpenvpnEncryptedKey(keyData))
|
||||
}
|
||||
|
||||
if *settings.Cert != "" {
|
||||
certData, err := extract.PEM([]byte(*settings.Cert))
|
||||
panicOnError(err, "cannot extract OpenVPN certificate")
|
||||
@@ -295,6 +302,16 @@ func WrapOpenvpnKey(clientKey string) (lines []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func WrapOpenvpnEncryptedKey(encryptedKey string) (lines []string) {
|
||||
return []string{
|
||||
"<key>",
|
||||
"-----BEGIN ENCRYPTED PRIVATE KEY-----",
|
||||
encryptedKey,
|
||||
"-----END ENCRYPTED PRIVATE KEY-----",
|
||||
"</key>",
|
||||
}
|
||||
}
|
||||
|
||||
func WrapOpenvpnRSAKey(rsaPrivateKey string) (lines []string) {
|
||||
return []string{
|
||||
"<key>",
|
||||
|
||||
Reference in New Issue
Block a user