Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-systemsettings] Support 'tcp' protocol option. Contr…
…ibutes to MER#1702
  • Loading branch information
matthewvogt committed Nov 18, 2016
1 parent 4a39467 commit 5f9efe6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/vpnmodel.cpp
Expand Up @@ -897,6 +897,14 @@ QVariantMap VpnModel::processOpenVpnProvisioningFile(QFile &provisioningFile)

const QString outputPath("/home/nemo/.local/share/system/vpn-provisioning");

auto normaliseProtocol = [](const QString &proto) {
if (proto == QStringLiteral("tcp")) {
// 'tcp' is an undocumented option, which is interpreted by openvpn as 'tcp-client'
return QStringLiteral("tcp-client");
}
return proto;
};

QTextStream is(&provisioningFile);
while (!is.atEnd()) {
QString line(is.readLine());
Expand Down Expand Up @@ -975,7 +983,7 @@ QVariantMap VpnModel::processOpenVpnProvisioningFile(QFile &provisioningFile)
rv.insert(QStringLiteral("OpenVPN.Port"), arguments.at(1));
}
if (arguments.count() > 2) {
rv.insert(QStringLiteral("OpenVPN.Proto"), arguments.at(2));
rv.insert(QStringLiteral("OpenVPN.Proto"), normaliseProtocol(arguments.at(2)));
}
} else {
extraOptions.append(line);
Expand Down Expand Up @@ -1018,7 +1026,7 @@ QVariantMap VpnModel::processOpenVpnProvisioningFile(QFile &provisioningFile)
if (!arguments.isEmpty()) {
// All values from a 'remote' directive to take precedence
if (!rv.contains(QStringLiteral("OpenVPN.Proto"))) {
rv.insert(QStringLiteral("OpenVPN.Proto"), arguments.join(QChar(' ')));
rv.insert(QStringLiteral("OpenVPN.Proto"), normaliseProtocol(arguments.join(QChar(' '))));
}
}
} else if (directive == QStringLiteral("port")) {
Expand Down

0 comments on commit 5f9efe6

Please sign in to comment.