VPN Unlimited support (#499)
- Fixes #420 - Revert to docker/build-push-action@v2.4.0
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/purevpn"
|
||||
"github.com/qdm12/gluetun/internal/provider/surfshark"
|
||||
"github.com/qdm12/gluetun/internal/provider/torguard"
|
||||
"github.com/qdm12/gluetun/internal/provider/vpnunlimited"
|
||||
"github.com/qdm12/gluetun/internal/provider/vyprvpn"
|
||||
"github.com/qdm12/gluetun/internal/provider/windscribe"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
@@ -69,6 +70,8 @@ func New(provider string, allServers models.AllServers, timeNow func() time.Time
|
||||
return surfshark.New(allServers.Surfshark.Servers, randSource)
|
||||
case constants.Torguard:
|
||||
return torguard.New(allServers.Torguard.Servers, randSource)
|
||||
case constants.VPNUnlimited:
|
||||
return vpnunlimited.New(allServers.VPNUnlimited.Servers, randSource)
|
||||
case constants.Vyprvpn:
|
||||
return vyprvpn.New(allServers.Vyprvpn.Servers, randSource)
|
||||
case constants.Windscribe:
|
||||
|
||||
44
internal/provider/vpnunlimited/connection.go
Normal file
44
internal/provider/vpnunlimited/connection.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package vpnunlimited
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
var ErrProtocolUnsupported = errors.New("network protocol is not supported")
|
||||
|
||||
func (p *Provider) GetOpenVPNConnection(selection configuration.ServerSelection) (
|
||||
connection models.OpenVPNConnection, err error) {
|
||||
const port = 1194
|
||||
const protocol = constants.UDP
|
||||
if selection.TCP {
|
||||
return connection, ErrProtocolUnsupported
|
||||
}
|
||||
|
||||
servers, err := p.filterServers(selection)
|
||||
if err != nil {
|
||||
return connection, err
|
||||
}
|
||||
|
||||
var connections []models.OpenVPNConnection
|
||||
for _, server := range servers {
|
||||
for _, IP := range server.IPs {
|
||||
connection := models.OpenVPNConnection{
|
||||
IP: IP,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
}
|
||||
connections = append(connections, connection)
|
||||
}
|
||||
}
|
||||
|
||||
if selection.TargetIP != nil {
|
||||
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
||||
}
|
||||
|
||||
return utils.PickRandomConnection(connections, p.randSource), nil
|
||||
}
|
||||
31
internal/provider/vpnunlimited/filter.go
Normal file
31
internal/provider/vpnunlimited/filter.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package vpnunlimited
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
func (p *Provider) filterServers(selection configuration.ServerSelection) (
|
||||
servers []models.VPNUnlimitedServer, err error) {
|
||||
for _, server := range p.servers {
|
||||
switch {
|
||||
case
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.City, selection.Cities),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
selection.FreeOnly && !server.Free,
|
||||
selection.StreamOnly && !server.Stream,
|
||||
selection.TCP && !server.TCP,
|
||||
!selection.TCP && !server.UDP:
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
}
|
||||
|
||||
if len(servers) == 0 {
|
||||
return nil, utils.NoServerFoundError(selection)
|
||||
}
|
||||
|
||||
return servers, nil
|
||||
}
|
||||
69
internal/provider/vpnunlimited/openvpnconf.go
Normal file
69
internal/provider/vpnunlimited/openvpnconf.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package vpnunlimited
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
func (p *Provider) BuildConf(connection models.OpenVPNConnection,
|
||||
username string, settings configuration.OpenVPN) (lines []string) {
|
||||
lines = []string{
|
||||
"client",
|
||||
"dev tun",
|
||||
"nobind",
|
||||
"persist-key",
|
||||
"tls-exit",
|
||||
"remote-cert-tls server",
|
||||
|
||||
// VPNUnlimited specific
|
||||
"reneg-sec 0",
|
||||
"ping 5",
|
||||
"ping-exit 30",
|
||||
"comp-lzo no",
|
||||
"route-metric 1",
|
||||
|
||||
// Added constant values
|
||||
"auth-nocache",
|
||||
"mute-replay-warnings",
|
||||
"pull-filter ignore \"auth-token\"", // prevent auth failed loops
|
||||
"auth-retry nointeract",
|
||||
"suppress-timestamps",
|
||||
|
||||
// Modified variables
|
||||
"verb " + strconv.Itoa(settings.Verbosity),
|
||||
// "auth-user-pass " + constants.OpenVPNAuthConf,
|
||||
connection.ProtoLine(),
|
||||
connection.RemoteLine(),
|
||||
}
|
||||
|
||||
if settings.Cipher != "" {
|
||||
lines = append(lines, utils.CipherLines(settings.Cipher, settings.Version)...)
|
||||
}
|
||||
|
||||
if settings.Auth != "" {
|
||||
lines = append(lines, "auth "+settings.Auth)
|
||||
}
|
||||
|
||||
if settings.MSSFix > 0 {
|
||||
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||
}
|
||||
|
||||
if !settings.Root {
|
||||
lines = append(lines, "user "+username)
|
||||
}
|
||||
|
||||
lines = append(lines, utils.WrapOpenvpnCA(
|
||||
constants.VPNUnlimitedCertificateAuthority)...)
|
||||
lines = append(lines, utils.WrapOpenvpnCert(
|
||||
settings.Provider.ExtraConfigOptions.ClientCertificate)...)
|
||||
lines = append(lines, utils.WrapOpenvpnKey(
|
||||
settings.Provider.ExtraConfigOptions.ClientKey)...)
|
||||
|
||||
lines = append(lines, "")
|
||||
|
||||
return lines
|
||||
}
|
||||
17
internal/provider/vpnunlimited/portforward.go
Normal file
17
internal/provider/vpnunlimited/portforward.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package vpnunlimited
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
func (p *Provider) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, pfLogger logging.Logger, gateway net.IP,
|
||||
fw firewall.Configurator, syncState func(port uint16) (pfFilepath string)) {
|
||||
panic("port forwarding is not supported for VPN Unlimited")
|
||||
}
|
||||
19
internal/provider/vpnunlimited/provider.go
Normal file
19
internal/provider/vpnunlimited/provider.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package vpnunlimited
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
type Provider struct {
|
||||
servers []models.VPNUnlimitedServer
|
||||
randSource rand.Source
|
||||
}
|
||||
|
||||
func New(servers []models.VPNUnlimitedServer, randSource rand.Source) *Provider {
|
||||
return &Provider{
|
||||
servers: servers,
|
||||
randSource: randSource,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user