From b0a6c9fa534a0cbcda1287af787e7b787451752a Mon Sep 17 00:00:00 2001 From: Markovskij Date: Sun, 3 Sep 2017 15:55:51 +0300 Subject: [PATCH 1/2] Make tunnels.conf more readable --- qt/i2pd_qt/TunnelConfig.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/qt/i2pd_qt/TunnelConfig.cpp b/qt/i2pd_qt/TunnelConfig.cpp index 0de17486..d282f23c 100644 --- a/qt/i2pd_qt/TunnelConfig.cpp +++ b/qt/i2pd_qt/TunnelConfig.cpp @@ -6,12 +6,19 @@ void TunnelConfig::saveHeaderToStringStream(std::stringstream& out) { } void TunnelConfig::saveI2CPParametersToStringStream(std::stringstream& out) { - out << "inbound.length=" << i2cpParameters.getInbound_length().toStdString() << "\n" - << "outbound.length=" << i2cpParameters.getOutbound_length().toStdString() << "\n" - << "inbound.quantity=" << i2cpParameters.getInbound_quantity().toStdString() << "\n" - << "outbound.quantity=" << i2cpParameters.getOutbound_quantity().toStdString() << "\n" - << "crypto.tagsToSend=" << i2cpParameters.getCrypto_tagsToSend().toStdString() << "\n" - << "explicitPeers=" << i2cpParameters.getExplicitPeers().toStdString() << "\n\n"; + if (i2cpParameters.getInbound_length().toUShort() != 3) + out << "inbound.length=" << i2cpParameters.getInbound_length().toStdString() << "\n"; + if (i2cpParameters.getOutbound_length().toUShort() != 3) + out << "outbound.length=" << i2cpParameters.getOutbound_length().toStdString() << "\n"; + if (i2cpParameters.getInbound_quantity().toUShort() != 5) + out << "inbound.quantity=" << i2cpParameters.getInbound_quantity().toStdString() << "\n"; + if (i2cpParameters.getOutbound_quantity().toUShort() != 5) + out << "outbound.quantity=" << i2cpParameters.getOutbound_quantity().toStdString() << "\n"; + if (i2cpParameters.getCrypto_tagsToSend().toUShort() != 40) + out << "crypto.tagsToSend=" << i2cpParameters.getCrypto_tagsToSend().toStdString() << "\n"; + if (!i2cpParameters.getExplicitPeers().isEmpty()) + out << "explicitPeers=" << i2cpParameters.getExplicitPeers().toStdString() << "\n"; + out << "\n"; } void ClientTunnelConfig::saveToStringStream(std::stringstream& out) { From a549ebc25fc84387a51fc60c352197ec28460b2f Mon Sep 17 00:00:00 2001 From: Markovskij Date: Mon, 4 Sep 2017 07:23:59 +0300 Subject: [PATCH 2/2] Add constants --- qt/i2pd_qt/TunnelConfig.cpp | 28 +++++++++++++++++----------- qt/i2pd_qt/TunnelConfig.h | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/qt/i2pd_qt/TunnelConfig.cpp b/qt/i2pd_qt/TunnelConfig.cpp index d282f23c..8cf86d14 100644 --- a/qt/i2pd_qt/TunnelConfig.cpp +++ b/qt/i2pd_qt/TunnelConfig.cpp @@ -6,18 +6,24 @@ void TunnelConfig::saveHeaderToStringStream(std::stringstream& out) { } void TunnelConfig::saveI2CPParametersToStringStream(std::stringstream& out) { - if (i2cpParameters.getInbound_length().toUShort() != 3) - out << "inbound.length=" << i2cpParameters.getInbound_length().toStdString() << "\n"; - if (i2cpParameters.getOutbound_length().toUShort() != 3) - out << "outbound.length=" << i2cpParameters.getOutbound_length().toStdString() << "\n"; - if (i2cpParameters.getInbound_quantity().toUShort() != 5) - out << "inbound.quantity=" << i2cpParameters.getInbound_quantity().toStdString() << "\n"; - if (i2cpParameters.getOutbound_quantity().toUShort() != 5) - out << "outbound.quantity=" << i2cpParameters.getOutbound_quantity().toStdString() << "\n"; - if (i2cpParameters.getCrypto_tagsToSend().toUShort() != 40) - out << "crypto.tagsToSend=" << i2cpParameters.getCrypto_tagsToSend().toStdString() << "\n"; + if (i2cpParameters.getInbound_length().toUShort() != i2p::client::DEFAULT_INBOUND_TUNNEL_LENGTH) + out << i2p::client::I2CP_PARAM_INBOUND_TUNNEL_LENGTH << "=" + << i2cpParameters.getInbound_length().toStdString() << "\n"; + if (i2cpParameters.getOutbound_length().toUShort() != i2p::client::DEFAULT_OUTBOUND_TUNNEL_LENGTH) + out << i2p::client::I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH << "=" + << i2cpParameters.getOutbound_length().toStdString() << "\n"; + if (i2cpParameters.getInbound_quantity().toUShort() != i2p::client::DEFAULT_INBOUND_TUNNELS_QUANTITY) + out << i2p::client::I2CP_PARAM_INBOUND_TUNNELS_QUANTITY << "=" + << i2cpParameters.getInbound_quantity().toStdString() << "\n"; + if (i2cpParameters.getOutbound_quantity().toUShort() != i2p::client::DEFAULT_OUTBOUND_TUNNELS_QUANTITY) + out << i2p::client::I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY << "=" + << i2cpParameters.getOutbound_quantity().toStdString() << "\n"; + if (i2cpParameters.getCrypto_tagsToSend().toUShort() != i2p::client::DEFAULT_TAGS_TO_SEND) + out << i2p::client::I2CP_PARAM_TAGS_TO_SEND << "=" + << i2cpParameters.getCrypto_tagsToSend().toStdString() << "\n"; if (!i2cpParameters.getExplicitPeers().isEmpty()) - out << "explicitPeers=" << i2cpParameters.getExplicitPeers().toStdString() << "\n"; + out << i2p::client::I2CP_PARAM_EXPLICIT_PEERS << "=" + << i2cpParameters.getExplicitPeers().toStdString() << "\n"; out << "\n"; } diff --git a/qt/i2pd_qt/TunnelConfig.h b/qt/i2pd_qt/TunnelConfig.h index 087ec30b..c714a4f5 100644 --- a/qt/i2pd_qt/TunnelConfig.h +++ b/qt/i2pd_qt/TunnelConfig.h @@ -5,6 +5,7 @@ #include #include "../../libi2pd_client/ClientContext.h" +#include "../../libi2pd/Destination.h" #include "TunnelsPageUpdateListener.h"