Maint: make VPN connection not specific to OpenVPN
- Add VPN field to ServerSelection struct - Set VPN type to server selection at start using VPN_TYPE - Change OpenVPNConnection to Connection with Type field - Rename Provider GetOpenVPNConnection to GetConnection - Rename GetTargetIPOpenVPNConnection to GetTargetIPConnection - Rename PickRandomOpenVPNConnection to PickRandomConnection - Add 'OpenVPN' prefix to OpenVPN specific methods on connection
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
func (p *Protonvpn) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
func (p *Protonvpn) GetConnection(selection configuration.ServerSelection) (
|
||||
connection models.Connection, err error) {
|
||||
protocol := constants.UDP
|
||||
if selection.OpenVPN.TCP {
|
||||
protocol = constants.TCP
|
||||
@@ -24,9 +24,10 @@ func (p *Protonvpn) GetOpenVPNConnection(selection configuration.ServerSelection
|
||||
return connection, err
|
||||
}
|
||||
|
||||
connections := make([]models.OpenVPNConnection, len(servers))
|
||||
connections := make([]models.Connection, len(servers))
|
||||
for i := range servers {
|
||||
connections[i] = models.OpenVPNConnection{
|
||||
connections[i] = models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: servers[i].EntryIP,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
@@ -34,8 +35,8 @@ func (p *Protonvpn) GetOpenVPNConnection(selection configuration.ServerSelection
|
||||
}
|
||||
|
||||
if selection.TargetIP != nil {
|
||||
return utils.GetTargetIPOpenVPNConnection(connections, selection.TargetIP)
|
||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
||||
}
|
||||
|
||||
return utils.PickRandomOpenVPNConnection(connections, p.randSource), nil
|
||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
func (p *Protonvpn) BuildConf(connection models.OpenVPNConnection,
|
||||
func (p *Protonvpn) BuildConf(connection models.Connection,
|
||||
settings configuration.OpenVPN) (lines []string) {
|
||||
if settings.Cipher == "" {
|
||||
settings.Cipher = constants.AES256cbc
|
||||
@@ -51,8 +51,8 @@ func (p *Protonvpn) BuildConf(connection models.OpenVPNConnection,
|
||||
// Modified variables
|
||||
"verb " + strconv.Itoa(settings.Verbosity),
|
||||
"auth-user-pass " + constants.OpenVPNAuthConf,
|
||||
connection.ProtoLine(),
|
||||
connection.RemoteLine(),
|
||||
connection.OpenVPNProtoLine(),
|
||||
connection.OpenVPNRemoteLine(),
|
||||
"auth " + settings.Auth,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user