Feature: OPENVPN_MSSFIX variable
This commit is contained in:
@@ -76,3 +76,11 @@ func (r *reader) GetOpenVPNAuth() (auth string, err error) {
|
|||||||
func (r *reader) GetOpenVPNIPv6() (ipv6 bool, err error) {
|
func (r *reader) GetOpenVPNIPv6() (ipv6 bool, err error) {
|
||||||
return r.env.OnOff("OPENVPN_IPV6", libparams.Default("off"))
|
return r.env.OnOff("OPENVPN_IPV6", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *reader) GetOpenVPNMSSFix() (mssFix uint16, err error) {
|
||||||
|
n, err := r.env.IntRange("OPENVPN_MSSFIX", 0, 10000, libparams.Default("0"))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return uint16(n), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ type Reader interface {
|
|||||||
GetOpenVPNCipher() (cipher string, err error)
|
GetOpenVPNCipher() (cipher string, err error)
|
||||||
GetOpenVPNAuth() (auth string, err error)
|
GetOpenVPNAuth() (auth string, err error)
|
||||||
GetOpenVPNIPv6() (tunnel bool, err error)
|
GetOpenVPNIPv6() (tunnel bool, err error)
|
||||||
|
GetOpenVPNMSSFix() (mssFix uint16, err error)
|
||||||
|
|
||||||
// PIA getters
|
// PIA getters
|
||||||
GetPortForwarding() (activated bool, err error)
|
GetPortForwarding() (activated bool, err error)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
@@ -108,6 +109,9 @@ func (c *cyberghost) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<ca>",
|
"<ca>",
|
||||||
"-----BEGIN CERTIFICATE-----",
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/firewall"
|
"github.com/qdm12/gluetun/internal/firewall"
|
||||||
@@ -117,6 +118,9 @@ func (m *mullvad) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<ca>",
|
"<ca>",
|
||||||
"-----BEGIN CERTIFICATE-----",
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/firewall"
|
"github.com/qdm12/gluetun/internal/firewall"
|
||||||
@@ -87,6 +88,11 @@ func (n *nordvpn) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if len(settings.Auth) == 0 {
|
if len(settings.Auth) == 0 {
|
||||||
settings.Auth = "sha512"
|
settings.Auth = "sha512"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultMSSFix = 1450
|
||||||
|
if settings.MSSFix == 0 {
|
||||||
|
settings.MSSFix = defaultMSSFix
|
||||||
|
}
|
||||||
lines = []string{
|
lines = []string{
|
||||||
"client",
|
"client",
|
||||||
"dev tun",
|
"dev tun",
|
||||||
@@ -97,7 +103,7 @@ func (n *nordvpn) BuildConf(connection models.OpenVPNConnection,
|
|||||||
// Nordvpn specific
|
// Nordvpn specific
|
||||||
"tun-mtu 1500",
|
"tun-mtu 1500",
|
||||||
"tun-mtu-extra 32",
|
"tun-mtu-extra 32",
|
||||||
"mssfix 1450",
|
"mssfix " + strconv.Itoa(int(settings.MSSFix)),
|
||||||
"ping 15",
|
"ping 15",
|
||||||
"ping-restart 0",
|
"ping-restart 0",
|
||||||
"ping-timer-rem",
|
"ping-timer-rem",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -164,6 +165,9 @@ func (p *pia) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<crl-verify>",
|
"<crl-verify>",
|
||||||
"-----BEGIN X509 CRL-----",
|
"-----BEGIN X509 CRL-----",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/firewall"
|
"github.com/qdm12/gluetun/internal/firewall"
|
||||||
@@ -107,6 +108,9 @@ func (s *privado) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<ca>",
|
"<ca>",
|
||||||
"-----BEGIN CERTIFICATE-----",
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/firewall"
|
"github.com/qdm12/gluetun/internal/firewall"
|
||||||
@@ -111,6 +112,9 @@ func (p *purevpn) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<ca>",
|
"<ca>",
|
||||||
"-----BEGIN CERTIFICATE-----",
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/firewall"
|
"github.com/qdm12/gluetun/internal/firewall"
|
||||||
@@ -82,6 +83,12 @@ func (s *surfshark) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if len(settings.Auth) == 0 {
|
if len(settings.Auth) == 0 {
|
||||||
settings.Auth = "SHA512"
|
settings.Auth = "SHA512"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultMSSFix = 1450
|
||||||
|
if settings.MSSFix == 0 {
|
||||||
|
settings.MSSFix = defaultMSSFix
|
||||||
|
}
|
||||||
|
|
||||||
lines = []string{
|
lines = []string{
|
||||||
"client",
|
"client",
|
||||||
"dev tun",
|
"dev tun",
|
||||||
@@ -92,7 +99,7 @@ func (s *surfshark) BuildConf(connection models.OpenVPNConnection,
|
|||||||
// Surfshark specific
|
// Surfshark specific
|
||||||
"tun-mtu 1500",
|
"tun-mtu 1500",
|
||||||
"tun-mtu-extra 32",
|
"tun-mtu-extra 32",
|
||||||
"mssfix 1450",
|
"mssfix " + strconv.Itoa(int(settings.MSSFix)),
|
||||||
"ping 15",
|
"ping 15",
|
||||||
"ping-restart 60",
|
"ping-restart 60",
|
||||||
"ping-timer-rem",
|
"ping-timer-rem",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
"github.com/qdm12/gluetun/internal/firewall"
|
"github.com/qdm12/gluetun/internal/firewall"
|
||||||
@@ -109,6 +110,9 @@ func (v *vyprvpn) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<ca>",
|
"<ca>",
|
||||||
"-----BEGIN CERTIFICATE-----",
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
"github.com/qdm12/gluetun/internal/constants"
|
||||||
@@ -114,6 +115,9 @@ func (w *windscribe) BuildConf(connection models.OpenVPNConnection,
|
|||||||
if !settings.Root {
|
if !settings.Root {
|
||||||
lines = append(lines, "user "+username)
|
lines = append(lines, "user "+username)
|
||||||
}
|
}
|
||||||
|
if settings.MSSFix > 0 {
|
||||||
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
||||||
|
}
|
||||||
lines = append(lines, []string{
|
lines = append(lines, []string{
|
||||||
"<ca>",
|
"<ca>",
|
||||||
"-----BEGIN CERTIFICATE-----",
|
"-----BEGIN CERTIFICATE-----",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type OpenVPN struct {
|
|||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Verbosity int `json:"verbosity"`
|
Verbosity int `json:"verbosity"`
|
||||||
|
MSSFix uint16 `json:"mssfix"`
|
||||||
Root bool `json:"run_as_root"`
|
Root bool `json:"run_as_root"`
|
||||||
Cipher string `json:"cipher"`
|
Cipher string `json:"cipher"`
|
||||||
Auth string `json:"auth"`
|
Auth string `json:"auth"`
|
||||||
@@ -52,6 +53,10 @@ func GetOpenVPNSettings(paramsReader params.Reader, vpnProvider models.VPNProvid
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return settings, err
|
return settings, err
|
||||||
}
|
}
|
||||||
|
settings.MSSFix, err = paramsReader.GetOpenVPNMSSFix()
|
||||||
|
if err != nil {
|
||||||
|
return settings, err
|
||||||
|
}
|
||||||
switch vpnProvider {
|
switch vpnProvider {
|
||||||
case constants.PrivateInternetAccess:
|
case constants.PrivateInternetAccess:
|
||||||
settings.Provider, err = GetPIASettings(paramsReader)
|
settings.Provider, err = GetPIASettings(paramsReader)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func Test_OpenVPN_JSON(t *testing.T) {
|
|||||||
data, err := json.Marshal(in)
|
data, err := json.Marshal(in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
assert.Equal(t, `{"user":"","password":"","verbosity":0,"run_as_root":true,"cipher":"","auth":"","provider":{"name":"name","server_selection":{"network_protocol":"","regions":null,"group":"","countries":null,"cities":null,"hostnames":null,"isps":null,"owned":false,"custom_port":0,"numbers":null,"encryption_preset":""},"extra_config":{"encryption_preset":"","openvpn_ipv6":false},"port_forwarding":{"enabled":false,"filepath":""}}}`, string(data))
|
assert.Equal(t, `{"user":"","password":"","verbosity":0,"mssfix":0,"run_as_root":true,"cipher":"","auth":"","provider":{"name":"name","server_selection":{"network_protocol":"","regions":null,"group":"","countries":null,"cities":null,"hostnames":null,"isps":null,"owned":false,"custom_port":0,"numbers":null,"encryption_preset":""},"extra_config":{"encryption_preset":"","openvpn_ipv6":false},"port_forwarding":{"enabled":false,"filepath":""}}}`, string(data))
|
||||||
var out OpenVPN
|
var out OpenVPN
|
||||||
err = json.Unmarshal(data, &out)
|
err = json.Unmarshal(data, &out)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user