|
|
@ -36,12 +36,11 @@
|
|
|
|
#include <tqwidgetstack.h>
|
|
|
|
#include <tqwidgetstack.h>
|
|
|
|
#include <tqfileinfo.h>
|
|
|
|
#include <tqfileinfo.h>
|
|
|
|
#include <tqhostaddress.h>
|
|
|
|
#include <tqhostaddress.h>
|
|
|
|
#include <tqdbusdata.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "knetworkmanager-openvpn.h"
|
|
|
|
#include "tdenetman-openvpn.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef KGenericFactory<OpenVPNPlugin> OpenVPNPluginFactory;
|
|
|
|
typedef KGenericFactory<OpenVPNPlugin> OpenVPNPluginFactory;
|
|
|
|
K_EXPORT_COMPONENT_FACTORY( knetworkmanager_openvpn, OpenVPNPluginFactory("knetworkmanager_openvpn"));
|
|
|
|
K_EXPORT_COMPONENT_FACTORY( tdenetman_openvpn, OpenVPNPluginFactory("tdenetman_openvpn"));
|
|
|
|
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
/************************************
|
|
|
|
* OpenVPNPlugin
|
|
|
|
* OpenVPNPlugin
|
|
|
@ -177,21 +176,23 @@ void OpenVPNConfig::getCipherModes()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// get all possible cipher modes
|
|
|
|
// get all possible cipher modes
|
|
|
|
TQString openvpn = findOpenVPNBinary();
|
|
|
|
TQString openvpn = findOpenVPNBinary();
|
|
|
|
if (!openvpn.isNull())
|
|
|
|
if (!openvpn.isNull()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
KProcess* cipherHelper = new KProcess();
|
|
|
|
KProcess* cipherHelper = new KProcess();
|
|
|
|
cipherHelper->setUseShell(true, "/bin/sh");
|
|
|
|
cipherHelper->setUseShell(true, "/bin/sh");
|
|
|
|
*cipherHelper << TQString::fromLatin1("%1 --show-ciphers | awk '/^[A-Z][A-Z0-9]+-/ { print $1 }'").arg(openvpn);
|
|
|
|
*cipherHelper << TQString::fromLatin1("%1 --show-ciphers | awk '/^[A-Z][A-Z0-9]+-/ { print $1 }'").arg(openvpn);
|
|
|
|
connect (cipherHelper, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), this, TQT_SLOT(receiveCipherData(KProcess*, char*, int)));
|
|
|
|
connect (cipherHelper, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), this, TQT_SLOT(receiveCipherData(KProcess*, char*, int)));
|
|
|
|
kdDebug() << "starting openvpn to get cipher modes" << endl;
|
|
|
|
kdDebug() << "starting openvpn to get cipher modes" << endl;
|
|
|
|
if (!cipherHelper->start(KProcess::Block, KProcess::Stdout))
|
|
|
|
if (!cipherHelper->start(KProcess::Block, KProcess::Stdout)) {
|
|
|
|
kdDebug() << "error starting openvpn" << endl;
|
|
|
|
kdDebug() << "error starting openvpn" << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenVPNConfig::setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties)
|
|
|
|
void OpenVPNConfig::setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
m_vpnProperties = properties;
|
|
|
|
|
|
|
|
m_vpnSecrets = secrets;
|
|
|
|
|
|
|
|
|
|
|
|
// fill up our inputfields
|
|
|
|
// fill up our inputfields
|
|
|
|
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
|
|
|
|
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -283,63 +284,98 @@ void OpenVPNConfig::setVPNData(const TQStringList& routes, const TQMap<TQString,
|
|
|
|
if (!routes.empty())
|
|
|
|
if (!routes.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_openvpnWidget->chkIPAdresses->setChecked(true);
|
|
|
|
_openvpnWidget->chkIPAdresses->setChecked(true);
|
|
|
|
_openvpnWidget->routes->setText(routes.join(" "));
|
|
|
|
TQStringList routesText;
|
|
|
|
|
|
|
|
for (TDENetworkSingleRouteConfigurationList::Iterator it = routes.begin(); it != routes.end(); ++it) {
|
|
|
|
|
|
|
|
routesText.append(TQString("%1/%2").arg((*it).ipAddress.toString()).arg((*it).networkMask.toCIDRMask()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_openvpnWidget->routes->setText(routesText.join(" "));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQMap<TQString, TQString>OpenVPNConfig::getVPNProperties()
|
|
|
|
TDENetworkSettingsMap OpenVPNConfig::getVPNProperties()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// build a StingList of properties
|
|
|
|
// Build a list of properties
|
|
|
|
TQMap<TQString, TQString> strlist;
|
|
|
|
m_vpnProperties.insert("connection-type", TQString::number(OpenVPNConnectionType::mapConnectionType2String((OpenVPNConnectionType::CONNECTIONTYPE)_openvpnWidget->cboConnectionType->currentItem())));
|
|
|
|
|
|
|
|
m_vpnProperties.insert("remote", TQString(_openvpnWidget->gateway->text()));
|
|
|
|
strlist.insert("connection-type", TQString::number(OpenVPNConnectionType::mapConnectionType2String((OpenVPNConnectionType::CONNECTIONTYPE)_openvpnWidget->cboConnectionType->currentItem())));
|
|
|
|
|
|
|
|
strlist.insert("remote", TQString(_openvpnWidget->gateway->text()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// port is not necessary
|
|
|
|
// port is not necessary
|
|
|
|
if (!_openvpnWidget->port->text().isEmpty() && !_openvpnWidget->chkDefaultPort->isChecked())
|
|
|
|
if (!_openvpnWidget->port->text().isEmpty() && !_openvpnWidget->chkDefaultPort->isChecked()) {
|
|
|
|
strlist.insert("port", _openvpnWidget->port->text());
|
|
|
|
m_vpnProperties.insert("port", _openvpnWidget->port->text());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
m_vpnProperties.remove("port");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
strlist.insert("ca", TQString(_openvpnWidget->editCA->url()));
|
|
|
|
m_vpnProperties.insert("ca", TQString(_openvpnWidget->editCA->url()));
|
|
|
|
strlist.insert("cert",TQString(_openvpnWidget->editCert->url() ));
|
|
|
|
m_vpnProperties.insert("cert",TQString(_openvpnWidget->editCert->url() ));
|
|
|
|
strlist.insert("key", TQString(_openvpnWidget->editKey->url()));
|
|
|
|
m_vpnProperties.insert("key", TQString(_openvpnWidget->editKey->url()));
|
|
|
|
|
|
|
|
|
|
|
|
if (_openvpnWidget->chkUseCipher->isChecked())
|
|
|
|
if (_openvpnWidget->chkUseCipher->isChecked()) {
|
|
|
|
strlist.insert("cipher", TQString(_openvpnWidget->cboCipher->currentText()));
|
|
|
|
m_vpnProperties.insert("cipher", TQString(_openvpnWidget->cboCipher->currentText()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
m_vpnProperties.remove("cipher");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_openvpnWidget->chkUseLZO->isChecked())
|
|
|
|
if (_openvpnWidget->chkUseLZO->isChecked()) {
|
|
|
|
strlist.insert("comp-lzo", TQString("true"));
|
|
|
|
m_vpnProperties.insert("comp-lzo", TQString("true"));
|
|
|
|
else
|
|
|
|
}
|
|
|
|
strlist.insert("comp-lzo", TQString("false"));
|
|
|
|
else {
|
|
|
|
|
|
|
|
m_vpnProperties.insert("comp-lzo", TQString("false"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
strlist.insert("static-key", TQString(_openvpnWidget->editSharedKey->url()));
|
|
|
|
m_vpnProperties.insert("static-key", TQString(_openvpnWidget->editSharedKey->url()));
|
|
|
|
strlist.insert("username", TQString(_openvpnWidget->editUsername->text()));
|
|
|
|
m_vpnProperties.insert("username", TQString(_openvpnWidget->editUsername->text()));
|
|
|
|
strlist.insert("local-ip", TQString(_openvpnWidget->editLocalIP->text()));
|
|
|
|
m_vpnProperties.insert("local-ip", TQString(_openvpnWidget->editLocalIP->text()));
|
|
|
|
strlist.insert("remote-ip", TQString(_openvpnWidget->editRemoteIP->text()));
|
|
|
|
m_vpnProperties.insert("remote-ip", TQString(_openvpnWidget->editRemoteIP->text()));
|
|
|
|
|
|
|
|
|
|
|
|
if (_openvpnWidget->chkUseTAP->isChecked()) {
|
|
|
|
if (_openvpnWidget->chkUseTAP->isChecked()) {
|
|
|
|
strlist.insert("tap-dev", "true");
|
|
|
|
m_vpnProperties.insert("tap-dev", "true");
|
|
|
|
strlist.insert("proto-tcp", "true");
|
|
|
|
m_vpnProperties.insert("proto-tcp", "true");
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
strlist.insert("tap-dev", "false");
|
|
|
|
else {
|
|
|
|
strlist.insert("proto-tcp", "false");
|
|
|
|
m_vpnProperties.insert("tap-dev", "false");
|
|
|
|
|
|
|
|
m_vpnProperties.insert("proto-tcp", "false");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_openvpnWidget->chkUseTLS->isChecked()) {
|
|
|
|
|
|
|
|
m_vpnProperties.insert("ta", TQString(_openvpnWidget->editTLSAuth->url()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
m_vpnProperties.remove("ta");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_openvpnWidget->chkUseTLS->isChecked())
|
|
|
|
m_vpnProperties.insert("ta-dir", TQString(_openvpnWidget->cboDirection->currentText()));
|
|
|
|
strlist.insert("ta", TQString(_openvpnWidget->editTLSAuth->url()));
|
|
|
|
|
|
|
|
|
|
|
|
return m_vpnProperties;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
strlist.insert("ta-dir", TQString(_openvpnWidget->cboDirection->currentText()));
|
|
|
|
TDENetworkSettingsMap OpenVPNConfig::getVPNSecrets() {
|
|
|
|
|
|
|
|
// Build a list of secrets
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
|
|
|
|
|
|
|
|
return strlist;
|
|
|
|
return m_vpnSecrets;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQStringList OpenVPNConfig::getVPNRoutes()
|
|
|
|
TDENetworkSingleRouteConfigurationList OpenVPNConfig::getVPNRoutes()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
TDENetworkSingleRouteConfigurationList ret;
|
|
|
|
TQStringList strlist;
|
|
|
|
TQStringList strlist;
|
|
|
|
if(_openvpnWidget->chkIPAdresses->isChecked())
|
|
|
|
if(_openvpnWidget->chkIPAdresses->isChecked()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
strlist = TQStringList::split(" ", _openvpnWidget->routes->text());
|
|
|
|
strlist = TQStringList::split(" ", _openvpnWidget->routes->text());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strlist;
|
|
|
|
|
|
|
|
|
|
|
|
for (TQStringList::Iterator it = strlist.begin(); it != strlist.end(); ++it) {
|
|
|
|
|
|
|
|
TQStringList pieces = TQStringList::split("/", (*it));
|
|
|
|
|
|
|
|
TDENetworkSingleRouteConfiguration routeconfig;
|
|
|
|
|
|
|
|
routeconfig.ipAddress.setAddress(pieces[0]);
|
|
|
|
|
|
|
|
if (pieces.count() > 1) {
|
|
|
|
|
|
|
|
routeconfig.networkMask.fromCIDRMask(pieces[1].toUInt());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ret.append(routeconfig);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool OpenVPNConfig::hasChanged()
|
|
|
|
bool OpenVPNConfig::hasChanged()
|
|
|
@ -526,7 +562,7 @@ OpenVPNAuthentication::~OpenVPNAuthentication()
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenVPNAuthentication::setVPNData(const TQStringList& /*routes*/, const TQMap<TQString, TQString>& properties)
|
|
|
|
void OpenVPNAuthentication::setVPNData(TDENetworkSingleRouteConfigurationList& /*routes*/, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// find the connection type property
|
|
|
|
// find the connection type property
|
|
|
|
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
|
|
|
|
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
|
|
|
@ -539,7 +575,7 @@ void OpenVPNAuthentication::setVPNData(const TQStringList& /*routes*/, const TQM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQMap<TQString, TQString> OpenVPNAuthentication::getPasswords()
|
|
|
|
TDENetworkSettingsMap OpenVPNAuthentication::getPasswords()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQMap<TQString, TQString> pwds;
|
|
|
|
TQMap<TQString, TQString> pwds;
|
|
|
|
if ((_connectionType == OpenVPNConnectionType::PASSWORD) || (_connectionType == OpenVPNConnectionType::X509USERPASS))
|
|
|
|
if ((_connectionType == OpenVPNConnectionType::PASSWORD) || (_connectionType == OpenVPNConnectionType::X509USERPASS))
|
|
|
@ -550,10 +586,10 @@ TQMap<TQString, TQString> OpenVPNAuthentication::getPasswords()
|
|
|
|
return pwds;
|
|
|
|
return pwds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenVPNAuthentication::setPasswords(TQString name, TQString value) {
|
|
|
|
void OpenVPNAuthentication::setPasswords(TDENetworkSettingsMap secrets) {
|
|
|
|
if (name == TQString("password")) {
|
|
|
|
if (secrets.contains("password")) {
|
|
|
|
_openvpnAuth->editUserPassword->erase();
|
|
|
|
_openvpnAuth->editUserPassword->erase();
|
|
|
|
_openvpnAuth->editUserPassword->insert(value);
|
|
|
|
_openvpnAuth->editUserPassword->insert(secrets["password"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -564,3 +600,4 @@ bool OpenVPNAuthentication::needsUserInteraction()
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "tdenetman-openvpn.moc"
|