Reactivate strongswan VPN plugin

pull/1/head
Timothy Pearson 12 years ago
parent 60bf9a139f
commit b99db6aa82

@ -11,5 +11,5 @@
add_subdirectory( openvpn )
add_subdirectory( pptp )
# add_subdirectory( strongswan )
add_subdirectory( strongswan )
add_subdirectory( vpnc )

@ -1 +1,2 @@
Timothy Pearson <kb9vqf@pearsoncomputing.net>
Thomas Kallenberg <tkallenb@hsr.ch>, <thomas@no-more-secrets.ch>

@ -0,0 +1,14 @@
#################################################
#
# (C) 2012 Timothy Pearson
# kb9vqf (AT) pearsoncomputing.net
#
# Improvements and feedback are welcome
#
# This file is released under GPL >= 2
#
#################################################
add_subdirectory( src )
install( FILES tdenetman_strongswan.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

@ -35,10 +35,10 @@
#include <kgenericfactory.h>
#include <tqlabel.h>
#include "knetworkmanager-strongswan.h"
#include "tdenetman-strongswan.h"
typedef KGenericFactory<StrongswanPlugin> StrongswanPluginFactory;
K_EXPORT_COMPONENT_FACTORY( knetworkmanager_strongswan, StrongswanPluginFactory("knetworkmanager_strongswan"));
K_EXPORT_COMPONENT_FACTORY( tdenetman_strongswan, StrongswanPluginFactory("tdenetman_strongswan"));
StrongswanPlugin::StrongswanPlugin(TQObject* parent, const char* name, const TQStringList& args)
@ -85,7 +85,7 @@ void StrongswanConfig::languageChange()
}
// usercert agent password userkey
// usercert agent password userkey
StrongswanConnectionType::CONNECTIONTYPE StrongswanConnectionType::mapString2ConnectionType(int prop)
{
if (prop == 0)
@ -113,8 +113,11 @@ int StrongswanConnectionType::mapConnectionType2String(CONNECTIONTYPE connType)
return -1;
}
void StrongswanConfig::setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties)
void StrongswanConfig::setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets)
{
m_vpnProperties = properties;
m_vpnSecrets = secrets;
// fill up our inputfields (only textfields atm)
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it)
{
@ -154,38 +157,66 @@ void StrongswanConfig::setVPNData(const TQStringList& routes, const TQMap<TQStri
}
}
TQMap<TQString, TQString> StrongswanConfig::getVPNProperties()
TDENetworkSettingsMap StrongswanConfig::getVPNProperties()
{
// build a StingList of properties
TQMap<TQString, TQString> strlist;
// Build a list of properties
m_vpnProperties.insert("gateway", TQString(_strongswanWidget->gateway->text()));
m_vpnProperties.insert("certificate", TQString(_strongswanWidget->certificate->url()));
m_vpnProperties.insert("username", TQString(_strongswanWidget->username->text()));
m_vpnProperties.insert("method", TQString::number(StrongswanConnectionType::mapConnectionType2String((StrongswanConnectionType::CONNECTIONTYPE)_strongswanWidget->authtype->currentItem())));
if (_strongswanWidget->chkUDPenc->isChecked()) {
m_vpnProperties.insert("encap", TQString("yes"));
}
else {
m_vpnProperties.remove("encap");
}
strlist.insert("gateway", TQString(_strongswanWidget->gateway->text()));
strlist.insert("certificate", TQString(_strongswanWidget->certificate->url()));
strlist.insert("username", TQString(_strongswanWidget->username->text()));
strlist.insert("method",
TQString::number(StrongswanConnectionType::mapConnectionType2String((StrongswanConnectionType::CONNECTIONTYPE)_strongswanWidget->authtype->currentItem())));
if (_strongswanWidget->chkIPcomp->isChecked()) {
m_vpnProperties.insert("ipcomp", TQString("yes"));
}
else {
m_vpnProperties.remove("ipcomp");
}
if (_strongswanWidget->chkUDPenc->isChecked())
strlist.insert("encap", TQString("yes"));
if (_strongswanWidget->chkIPinner->isChecked()) {
m_vpnProperties.insert("virtual", TQString("yes"));
}
else {
m_vpnProperties.remove("virtual");
}
if (_strongswanWidget->chkIPcomp->isChecked())
strlist.insert("ipcomp", TQString("yes"));
return m_vpnProperties;
}
if (_strongswanWidget->chkIPinner->isChecked())
strlist.insert("virtual", TQString("yes"));
TDENetworkSettingsMap StrongswanConfig::getVPNSecrets() {
// Build a list of secrets
// FIXME
return strlist;
return m_vpnSecrets;
}
TQStringList StrongswanConfig::getVPNRoutes()
TDENetworkSingleRouteConfigurationList StrongswanConfig::getVPNRoutes()
{
TDENetworkSingleRouteConfigurationList ret;
#if 0
TQStringList strlist;
/*if(_strongswanWidget->chkIPAdresses->isChecked())
{
if(_strongswanWidget->chkIPAdresses->isChecked()) {
strlist = TQStringList::split(" ", _strongswanWidget->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);
}
#endif
return ret;
}
@ -218,7 +249,7 @@ StrongswanAuthentication::~StrongswanAuthentication()
}
TQMap<TQString, TQString> StrongswanAuthentication::getPasswords()
TDENetworkSettingsMap StrongswanAuthentication::getPasswords()
{
TQMap<TQString, TQString> pwds;
pwds.insert("user", TQString(_strongswanAuth->username->text()));
@ -226,9 +257,11 @@ TQMap<TQString, TQString> StrongswanAuthentication::getPasswords()
return pwds;
}
void StrongswanAuthentication::setPasswords(TQString name, TQString value) {
if (name == TQString("password")) {
void StrongswanAuthentication::setPasswords(TDENetworkSettingsMap secrets) {
if (secrets.contains("password")) {
_strongswanAuth->password->erase();
_strongswanAuth->password->insert(value);
_strongswanAuth->password->insert(secrets["password"]);
}
}
}
#include "tdenetman-strongswan.moc"

@ -30,7 +30,7 @@
#include <tqwidget.h>
#include <tqlayout.h>
#include "knetworkmanager-vpnplugin.h"
#include "tdenetman-vpnplugin.h"
#include "strongswanprop.h"
#include "strongswanauth.h"
@ -48,17 +48,17 @@ class StrongswanPlugin : public VPNPlugin
class StrongswanConnectionType
{
public:
enum CONNECTIONTYPE
{
UNKNOWN = -1
, psk = 0
, key
, agent
};
static CONNECTIONTYPE mapString2ConnectionType(int string);
static int mapConnectionType2String(CONNECTIONTYPE connectionType);
public:
enum CONNECTIONTYPE
{
UNKNOWN = -1
, psk = 0
, key
, agent
};
static CONNECTIONTYPE mapString2ConnectionType(int string);
static int mapConnectionType2String(CONNECTIONTYPE connectionType);
};
class StrongswanConfig : public VPNConfigWidget
@ -66,9 +66,10 @@ class StrongswanConfig : public VPNConfigWidget
Q_OBJECT
public:
void setVPNData(const TQStringList& routes, const TQMap<TQString, TQString>& properties);
TQMap<TQString, TQString> getVPNProperties();
TQStringList getVPNRoutes();
void setVPNData(TDENetworkSingleRouteConfigurationList& routes, TDENetworkSettingsMap& properties, TDENetworkSettingsMap& secrets);
TDENetworkSettingsMap getVPNProperties();
TDENetworkSettingsMap getVPNSecrets();
TDENetworkSingleRouteConfigurationList getVPNRoutes();
bool hasChanged();
bool isValid(TQStringList& );
@ -78,6 +79,9 @@ class StrongswanConfig : public VPNConfigWidget
private:
StrongswanConfigWidget* _strongswanWidget;
TDENetworkSettingsMap m_vpnProperties;
TDENetworkSettingsMap m_vpnSecrets;
protected slots:
void languageChange();
};
@ -89,8 +93,8 @@ class StrongswanAuthentication : public VPNAuthenticationWidget
public:
StrongswanAuthentication(TQWidget* parent = NULL, char* name = NULL);
~StrongswanAuthentication();
TQMap<TQString, TQString> getPasswords();
void setPasswords(TQString name, TQString value);
TDENetworkSettingsMap getPasswords();
void setPasswords(TDENetworkSettingsMap secrets);
private:
StrongswanAuthenticationWidget* _strongswanAuth;

@ -3,11 +3,11 @@ Encoding=UTF-8
Type=Service
Icon=
ServiceTypes=TDENetworkManager/VPNPlugin
X-TDE-Library=knetworkmanager_strongswan
X-TDE-Library=tdenetman_strongswan
X-NetworkManager-Services=strongswan
X-TDE-PluginInfo-Author=Thomas Kallenberg
X-TDE-PluginInfo-Email=tkallenb@hsr.ch
X-TDE-PluginInfo-Name=knetworkmanager_strongswan
X-TDE-PluginInfo-Author=Timothy Pearson
X-TDE-PluginInfo-Email=kb9vqf@pearsoncomputing.net
X-TDE-PluginInfo-Name=tdenetman_strongswan
X-TDE-PluginInfo-Version=0.1
X-TDE-PluginInfo-Website=
X-TDE-PluginInfo-Category=VPNService
Loading…
Cancel
Save