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( openvpn )
add_subdirectory( pptp ) add_subdirectory( pptp )
# add_subdirectory( strongswan ) add_subdirectory( strongswan )
add_subdirectory( vpnc ) add_subdirectory( vpnc )

@ -1 +1,2 @@
Timothy Pearson <kb9vqf@pearsoncomputing.net>
Thomas Kallenberg <tkallenb@hsr.ch>, <thomas@no-more-secrets.ch> 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 <kgenericfactory.h>
#include <tqlabel.h> #include <tqlabel.h>
#include "knetworkmanager-strongswan.h" #include "tdenetman-strongswan.h"
typedef KGenericFactory<StrongswanPlugin> StrongswanPluginFactory; 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) 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) StrongswanConnectionType::CONNECTIONTYPE StrongswanConnectionType::mapString2ConnectionType(int prop)
{ {
if (prop == 0) if (prop == 0)
@ -113,8 +113,11 @@ int StrongswanConnectionType::mapConnectionType2String(CONNECTIONTYPE connType)
return -1; 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) // fill up our inputfields (only textfields atm)
for(TQMap<TQString, TQString>::ConstIterator it = properties.begin(); it != properties.end(); ++it) 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 // Build a list of properties
TQMap<TQString, TQString> strlist; 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())); if (_strongswanWidget->chkIPcomp->isChecked()) {
strlist.insert("certificate", TQString(_strongswanWidget->certificate->url())); m_vpnProperties.insert("ipcomp", TQString("yes"));
strlist.insert("username", TQString(_strongswanWidget->username->text())); }
strlist.insert("method", else {
TQString::number(StrongswanConnectionType::mapConnectionType2String((StrongswanConnectionType::CONNECTIONTYPE)_strongswanWidget->authtype->currentItem()))); m_vpnProperties.remove("ipcomp");
}
if (_strongswanWidget->chkUDPenc->isChecked()) if (_strongswanWidget->chkIPinner->isChecked()) {
strlist.insert("encap", TQString("yes")); m_vpnProperties.insert("virtual", TQString("yes"));
}
else {
m_vpnProperties.remove("virtual");
}
if (_strongswanWidget->chkIPcomp->isChecked()) return m_vpnProperties;
strlist.insert("ipcomp", TQString("yes")); }
if (_strongswanWidget->chkIPinner->isChecked()) TDENetworkSettingsMap StrongswanConfig::getVPNSecrets() {
strlist.insert("virtual", TQString("yes")); // Build a list of secrets
// FIXME
return strlist; return m_vpnSecrets;
} }
TQStringList StrongswanConfig::getVPNRoutes() TDENetworkSingleRouteConfigurationList StrongswanConfig::getVPNRoutes()
{ {
TDENetworkSingleRouteConfigurationList ret;
#if 0
TQStringList strlist; TQStringList strlist;
/*if(_strongswanWidget->chkIPAdresses->isChecked()) if(_strongswanWidget->chkIPAdresses->isChecked()) {
{
strlist = TQStringList::split(" ", _strongswanWidget->routes->text()); 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; TQMap<TQString, TQString> pwds;
pwds.insert("user", TQString(_strongswanAuth->username->text())); pwds.insert("user", TQString(_strongswanAuth->username->text()));
@ -226,9 +257,11 @@ TQMap<TQString, TQString> StrongswanAuthentication::getPasswords()
return pwds; return pwds;
} }
void StrongswanAuthentication::setPasswords(TQString name, TQString value) { void StrongswanAuthentication::setPasswords(TDENetworkSettingsMap secrets) {
if (name == TQString("password")) { if (secrets.contains("password")) {
_strongswanAuth->password->erase(); _strongswanAuth->password->erase();
_strongswanAuth->password->insert(value); _strongswanAuth->password->insert(secrets["password"]);
} }
} }
#include "tdenetman-strongswan.moc"

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

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