Maint: configuration Openvpn selection structure

- Move network protocol from ServerSelection to OpenVPNSelection child
- Move PIA encryption preset from ServerSelection to OpenVPNSelection child
- Move custom port from ServerSelection to OpenVPNSelection child
This commit is contained in:
Quentin McGaw (desktop)
2021-08-17 16:54:22 +00:00
parent cc2235653a
commit 9105b33e9f
57 changed files with 321 additions and 282 deletions

View File

@@ -11,7 +11,7 @@ func (c *Cyberghost) GetOpenVPNConnection(selection configuration.ServerSelectio
connection models.OpenVPNConnection, err error) {
const port = 443
protocol := constants.UDP
if selection.TCP {
if selection.OpenVPN.TCP {
protocol = constants.TCP
}

View File

@@ -16,7 +16,7 @@ var ErrGroupMismatchesProtocol = errors.New("server group does not match protoco
func (c *Cyberghost) filterServers(selection configuration.ServerSelection) (
servers []models.CyberghostServer, err error) {
if len(selection.Groups) == 0 {
if selection.TCP {
if selection.OpenVPN.TCP {
selection.Groups = tcpGroupChoices()
} else {
selection.Groups = udpGroupChoices()
@@ -25,7 +25,7 @@ func (c *Cyberghost) filterServers(selection configuration.ServerSelection) (
// Check each group match the protocol
groupsCheckFn := groupsAreAllUDP
if selection.TCP {
if selection.OpenVPN.TCP {
groupsCheckFn = groupsAreAllTCP
}
if err := groupsCheckFn(selection.Groups); err != nil {

View File

@@ -41,7 +41,9 @@ func Test_Cyberghost_filterServers(t *testing.T) {
{Region: "d", Group: "Premium UDP Europe"},
},
selection: configuration.ServerSelection{
TCP: true,
OpenVPN: configuration.OpenVPNSelection{
TCP: true,
},
},
filteredServers: []models.CyberghostServer{
{Region: "a", Group: "Premium TCP Asia"},