X-Git-Url: https://www.flypig.org.uk/git/?p=openvpnui.git;a=blobdiff_plain;f=src%2Fvpncontrol.cpp;h=19351948f66fec55258b3d447bd547ddb96ed2ba;hp=a519dce1f29d799ab4e16ac995d447a440d967b9;hb=23fb3768d515e0e901298d2b030561b9a98ffb33;hpb=2e0816fb79e6c696ada4fe098ba006fca2741a1f diff --git a/src/vpncontrol.cpp b/src/vpncontrol.cpp index a519dce..1935194 100644 --- a/src/vpncontrol.cpp +++ b/src/vpncontrol.cpp @@ -86,7 +86,6 @@ void VPNControl::setServer(const QString &value) emit serverChanged(server); } - void VPNControl::vpnConnect() { if (vpnProcess != NULL) { printf ("Process already running.\n"); @@ -95,11 +94,8 @@ void VPNControl::vpnConnect() { printf ("Connect\n"); vpnProcess = new QProcess(); - //QString program = "/home/nemo/Documents/Development/Projects/Stooge/stooge"; QString program = "openvpn"; - QStringList arguments; - arguments << "/home/nemo/Documents/Configure/OpenVPN/client.ovpn"; - + collectArguments (); vpnProcess->setReadChannel(QProcess::StandardOutput); connect(vpnProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(readError(QProcess::ProcessError))); connect(vpnProcess, SIGNAL(readyRead()), this, SLOT(readData())); @@ -109,9 +105,53 @@ void VPNControl::vpnConnect() { vpnProcess->start(program, arguments); vpnProcess->closeWriteChannel(); setStatus(VPNSTATUS_INITIALISING); + arguments.clear(); + } +} + +void VPNControl::collectArguments () { + arguments.clear(); + + addArgument("config", "/home/nemo/Documents/Configure/OpenVPN/config.ovpn"); + addArgument("remote", server); + addArgument("port", QString::number(port)); + addOption("comp-lzo", compressed); + if (useTLS) { + addArgument("tls-auth", "/home/nemo/Documents/Configure/OpenVPN/ta.key"); + addValue(QString::number(tlsDirection)); + } + addArgument("ca", "/home/nemo/Documents/Configure/OpenVPN/ca.crt"); + addArgument("cert", "/home/nemo/Documents/Configure/OpenVPN/Jolla.crt"); + addArgument("key", "/home/nemo/Documents/Configure/OpenVPN/Jolla.key"); +} + +void VPNControl::addArgument (QString key, QString value) { + QString argument; + + argument = "--" + key; + arguments.append(argument); + if (value != "") { + arguments.append(value); } } +void VPNControl::addArgument (QString key) { + QString argument; + + argument = "--" + key; + arguments.append(argument); +} + +void VPNControl::addOption (QString key, bool add) { + if (add) { + addArgument (key); + } +} + +void VPNControl::addValue (QString key) { + arguments.append(key); +} + void VPNControl::vpnDisconnect() { if (vpnProcess != NULL) { printf ("Disconnect\n");