77 lines
1.7 KiB
Go
77 lines
1.7 KiB
Go
package surfshark
|
|
|
|
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 (s *Surfshark) BuildConf(connection models.OpenVPNConnection,
|
|
username string, settings configuration.OpenVPN) (lines []string) {
|
|
if settings.Cipher == "" {
|
|
settings.Cipher = constants.AES256gcm
|
|
}
|
|
|
|
if settings.Auth == "" {
|
|
settings.Auth = constants.SHA512
|
|
}
|
|
|
|
const defaultMSSFix = 1450
|
|
if settings.MSSFix == 0 {
|
|
settings.MSSFix = defaultMSSFix
|
|
}
|
|
|
|
lines = []string{
|
|
"client",
|
|
"dev tun",
|
|
"nobind",
|
|
"persist-key",
|
|
"remote-cert-tls server",
|
|
"ping 15",
|
|
"ping-timer-rem",
|
|
"tls-exit",
|
|
|
|
// Surfshark specific
|
|
"tun-mtu 1500",
|
|
"tun-mtu-extra 32",
|
|
"mssfix " + strconv.Itoa(int(settings.MSSFix)),
|
|
"reneg-sec 0",
|
|
"fast-io",
|
|
"key-direction 1",
|
|
"script-security 2",
|
|
"ping-restart 0",
|
|
|
|
// 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(),
|
|
"data-ciphers-fallback " + settings.Cipher,
|
|
"data-ciphers " + settings.Cipher,
|
|
"auth " + settings.Auth,
|
|
}
|
|
|
|
if !settings.Root {
|
|
lines = append(lines, "user "+username)
|
|
}
|
|
|
|
lines = append(lines, utils.WrapOpenvpnCA(
|
|
constants.SurfsharkCertificate)...)
|
|
lines = append(lines, utils.WrapOpenvpnTLSAuth(
|
|
constants.SurfsharkOpenvpnStaticKeyV1)...)
|
|
|
|
lines = append(lines, "")
|
|
|
|
return lines
|
|
}
|