2021-05-11 17:10:51 +00:00
|
|
|
package cyberghost
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"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"
|
|
|
|
|
)
|
|
|
|
|
|
2021-08-19 14:09:41 +00:00
|
|
|
func (c *Cyberghost) BuildConf(connection models.Connection,
|
2021-09-13 11:30:14 -04:00
|
|
|
settings configuration.OpenVPN) (lines []string, err error) {
|
2021-05-11 17:10:51 +00:00
|
|
|
if settings.Cipher == "" {
|
|
|
|
|
settings.Cipher = constants.AES256cbc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if settings.Auth == "" {
|
|
|
|
|
settings.Auth = constants.SHA256
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lines = []string{
|
|
|
|
|
"client",
|
2021-08-20 01:13:04 +00:00
|
|
|
"dev " + settings.Interface,
|
2021-05-11 17:10:51 +00:00
|
|
|
"nobind",
|
|
|
|
|
"persist-key",
|
|
|
|
|
"persist-tun",
|
|
|
|
|
"remote-cert-tls server",
|
|
|
|
|
"ping 10",
|
|
|
|
|
"ping-exit 60",
|
|
|
|
|
"tls-exit",
|
|
|
|
|
|
|
|
|
|
// Cyberghost specific
|
|
|
|
|
|
|
|
|
|
// 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,
|
2021-08-19 14:09:41 +00:00
|
|
|
connection.OpenVPNProtoLine(),
|
|
|
|
|
connection.OpenVPNRemoteLine(),
|
2021-05-11 17:10:51 +00:00
|
|
|
"auth " + settings.Auth,
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-23 17:40:14 +00:00
|
|
|
lines = append(lines, utils.CipherLines(settings.Cipher, settings.Version)...)
|
|
|
|
|
|
2021-07-31 14:02:02 +00:00
|
|
|
if connection.Protocol == constants.UDP {
|
|
|
|
|
lines = append(lines, "explicit-exit-notify")
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 17:10:51 +00:00
|
|
|
if strings.HasSuffix(settings.Cipher, "-gcm") {
|
|
|
|
|
lines = append(lines, "ncp-ciphers AES-256-GCM:AES-256-CBC:AES-128-GCM")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !settings.Root {
|
2021-08-18 16:16:47 +00:00
|
|
|
lines = append(lines, "user "+settings.ProcUser)
|
2021-05-11 17:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if settings.MSSFix > 0 {
|
|
|
|
|
lines = append(lines, "mssfix "+strconv.Itoa(int(settings.MSSFix)))
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 15:54:01 +00:00
|
|
|
if !settings.IPv6 {
|
2021-07-19 01:46:20 +00:00
|
|
|
lines = append(lines, `pull-filter ignore "route-ipv6"`)
|
|
|
|
|
lines = append(lines, `pull-filter ignore "ifconfig-ipv6"`)
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 17:10:51 +00:00
|
|
|
lines = append(lines, utils.WrapOpenvpnCA(
|
|
|
|
|
constants.CyberghostCertificate)...)
|
|
|
|
|
lines = append(lines, utils.WrapOpenvpnCert(
|
2021-08-17 15:44:11 +00:00
|
|
|
settings.ClientCrt)...)
|
2021-05-11 17:10:51 +00:00
|
|
|
lines = append(lines, utils.WrapOpenvpnKey(
|
2021-08-17 15:44:11 +00:00
|
|
|
settings.ClientKey)...)
|
2021-05-11 17:10:51 +00:00
|
|
|
|
|
|
|
|
lines = append(lines, "")
|
|
|
|
|
|
2021-09-13 11:30:14 -04:00
|
|
|
return lines, nil
|
2021-05-11 17:10:51 +00:00
|
|
|
}
|