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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user