2017-03-14 12:34:01 +00:00
|
|
|
#ifndef TUNNELCONFIG_H
|
|
|
|
#define TUNNELCONFIG_H
|
|
|
|
|
|
|
|
#include "QString"
|
|
|
|
#include <string>
|
|
|
|
|
2017-06-02 15:43:33 +00:00
|
|
|
#include "../../libi2pd_client/ClientContext.h"
|
2017-09-04 04:23:59 +00:00
|
|
|
#include "../../libi2pd/Destination.h"
|
2017-06-02 14:59:13 +00:00
|
|
|
#include "TunnelsPageUpdateListener.h"
|
2017-03-14 12:34:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class I2CPParameters{
|
|
|
|
QString inbound_length;//number of hops of an inbound tunnel. 3 by default; lower value is faster but dangerous
|
|
|
|
QString outbound_length;//number of hops of an outbound tunnel. 3 by default; lower value is faster but dangerous
|
|
|
|
QString inbound_quantity; //number of inbound tunnels. 5 by default
|
|
|
|
QString outbound_quantity; //number of outbound tunnels. 5 by default
|
|
|
|
QString crypto_tagsToSend; //number of ElGamal/AES tags to send. 40 by default; too low value may cause problems with tunnel building
|
|
|
|
QString explicitPeers; //list of comma-separated b64 addresses of peers to use, default: unset
|
2020-10-21 06:46:31 +00:00
|
|
|
QString i2p_streaming_initialAckDelay; //i2p.streaming.initialAckDelay -- milliseconds to wait before sending Ack. 200 by default
|
|
|
|
bool i2p_streaming_answerPings; //i2p.streaming.answerPings -- enable sending pongs. true by default
|
|
|
|
QString i2cp_leaseSetType; //i2cp.leaseSetType -- type of LeaseSet to be sent. 1, 3 or 5. 1 by default
|
|
|
|
QString i2cp_leaseSetEncType; //i2cp.leaseSetEncType -- comma separated encryption types to be used in LeaseSet type 3 or 5. Identity's type by default
|
|
|
|
QString i2cp_leaseSetPrivKey; //i2cp.leaseSetPrivKey -- decryption key for encrypted LeaseSet in base64. PSK or private DH
|
|
|
|
QString i2cp_leaseSetAuthType; //i2cp.leaseSetAuthType -- authentication type for encrypted LeaseSet. 0 - no authentication(default), 1 - DH, 2 - PSK
|
2017-03-14 12:34:01 +00:00
|
|
|
public:
|
|
|
|
I2CPParameters(): inbound_length(),
|
|
|
|
outbound_length(),
|
|
|
|
inbound_quantity(),
|
|
|
|
outbound_quantity(),
|
|
|
|
crypto_tagsToSend(),
|
2020-10-21 06:46:31 +00:00
|
|
|
explicitPeers(),
|
|
|
|
i2p_streaming_initialAckDelay(),
|
|
|
|
i2p_streaming_answerPings(true),
|
|
|
|
i2cp_leaseSetType(),
|
|
|
|
i2cp_leaseSetEncType(),
|
|
|
|
i2cp_leaseSetPrivKey(),
|
|
|
|
i2cp_leaseSetAuthType() {}
|
2017-03-14 12:34:01 +00:00
|
|
|
const QString& getInbound_length(){return inbound_length;}
|
|
|
|
const QString& getOutbound_length(){return outbound_length;}
|
|
|
|
const QString& getInbound_quantity(){return inbound_quantity;}
|
|
|
|
const QString& getOutbound_quantity(){return outbound_quantity;}
|
|
|
|
const QString& getCrypto_tagsToSend(){return crypto_tagsToSend;}
|
|
|
|
const QString& getExplicitPeers(){return explicitPeers;}
|
2020-10-21 06:46:31 +00:00
|
|
|
const QString& get_i2p_streaming_initialAckDelay(){return i2p_streaming_initialAckDelay;}
|
|
|
|
bool get_i2p_streaming_answerPings(){return i2p_streaming_answerPings;}
|
|
|
|
const QString& get_i2cp_leaseSetType(){return i2cp_leaseSetType;}
|
|
|
|
const QString& get_i2cp_leaseSetEncType(){return i2cp_leaseSetEncType;}
|
|
|
|
const QString& get_i2cp_leaseSetPrivKey(){return i2cp_leaseSetPrivKey;}
|
|
|
|
const QString& get_i2cp_leaseSetAuthType(){return i2cp_leaseSetAuthType;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setInbound_length(QString inbound_length_){inbound_length=inbound_length_;}
|
|
|
|
void setOutbound_length(QString outbound_length_){outbound_length=outbound_length_;}
|
|
|
|
void setInbound_quantity(QString inbound_quantity_){inbound_quantity=inbound_quantity_;}
|
|
|
|
void setOutbound_quantity(QString outbound_quantity_){outbound_quantity=outbound_quantity_;}
|
|
|
|
void setCrypto_tagsToSend(QString crypto_tagsToSend_){crypto_tagsToSend=crypto_tagsToSend_;}
|
|
|
|
void setExplicitPeers(QString explicitPeers_){explicitPeers=explicitPeers_;}
|
2020-10-21 06:46:31 +00:00
|
|
|
void set_i2p_streaming_initialAckDelay(QString i2p_streaming_initialAckDelay_){i2p_streaming_initialAckDelay=i2p_streaming_initialAckDelay_;}
|
|
|
|
void set_i2p_streaming_answerPings(bool i2p_streaming_answerPings_){i2p_streaming_answerPings=i2p_streaming_answerPings_;}
|
|
|
|
void set_i2cp_leaseSetType(QString i2cp_leaseSetType_){i2cp_leaseSetType=i2cp_leaseSetType_;}
|
|
|
|
void set_i2cp_leaseSetEncType(QString i2cp_leaseSetEncType_){i2cp_leaseSetEncType=i2cp_leaseSetEncType_;}
|
|
|
|
void set_i2cp_leaseSetPrivKey(QString i2cp_leaseSetPrivKey_){i2cp_leaseSetPrivKey=i2cp_leaseSetPrivKey_;}
|
|
|
|
void set_i2cp_leaseSetAuthType(QString i2cp_leaseSetAuthType_){i2cp_leaseSetAuthType=i2cp_leaseSetAuthType_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ClientTunnelConfig;
|
|
|
|
class ServerTunnelConfig;
|
2020-03-10 15:22:49 +00:00
|
|
|
|
|
|
|
class TunnelPane;
|
|
|
|
|
2017-03-14 12:34:01 +00:00
|
|
|
class TunnelConfig {
|
|
|
|
/*
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_CLIENT[] = "client";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_SERVER[] = "server";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_HTTP[] = "http";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_IRC[] = "irc";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_UDPCLIENT[] = "udpclient";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_UDPSERVER[] = "udpserver";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_SOCKS[] = "socks";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_WEBSOCKS[] = "websocks";
|
|
|
|
const char I2P_TUNNELS_SECTION_TYPE_HTTPPROXY[] = "httpproxy";
|
|
|
|
*/
|
|
|
|
QString type;
|
|
|
|
std::string name;
|
2020-03-10 15:22:49 +00:00
|
|
|
TunnelPane* tunnelPane;
|
2020-10-07 15:16:06 +00:00
|
|
|
int cryptoType;
|
2017-03-14 12:34:01 +00:00
|
|
|
public:
|
2020-10-07 15:16:06 +00:00
|
|
|
TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_, int cryptoType_):
|
|
|
|
type(type_), name(name_), cryptoType(cryptoType_), i2cpParameters(i2cpParameters_) {}
|
2017-04-02 19:39:24 +00:00
|
|
|
virtual ~TunnelConfig(){}
|
2017-03-14 12:34:01 +00:00
|
|
|
const QString& getType(){return type;}
|
|
|
|
const std::string& getName(){return name;}
|
2020-10-07 15:16:06 +00:00
|
|
|
int getcryptoType(){return cryptoType;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setType(const QString& type_){type=type_;}
|
|
|
|
void setName(const std::string& name_){name=name_;}
|
|
|
|
I2CPParameters& getI2cpParameters(){return i2cpParameters;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void saveHeaderToStringStream(std::stringstream& out);
|
|
|
|
void saveI2CPParametersToStringStream(std::stringstream& out);
|
|
|
|
virtual void saveToStringStream(std::stringstream& out)=0;
|
2017-03-14 12:34:01 +00:00
|
|
|
virtual ClientTunnelConfig* asClientTunnelConfig()=0;
|
|
|
|
virtual ServerTunnelConfig* asServerTunnelConfig()=0;
|
2020-03-10 15:22:49 +00:00
|
|
|
void setTunnelPane(TunnelPane* tp){this->tunnelPane = tp;}
|
|
|
|
TunnelPane* getTunnelPane() {return tunnelPane;}
|
2020-10-07 15:16:06 +00:00
|
|
|
void setcryptoType(int cryptoType_){cryptoType=cryptoType_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
private:
|
|
|
|
I2CPParameters i2cpParameters;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
# mandatory parameters:
|
|
|
|
std::string dest;
|
|
|
|
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)
|
|
|
|
dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION);
|
|
|
|
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
|
|
|
# optional parameters (may be omitted)
|
|
|
|
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
|
|
|
|
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
|
|
|
|
int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
|
|
|
|
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
|
|
|
# * keys -- our identity, if unset, will be generated on every startup,
|
|
|
|
# if set and file missing, keys will be generated and placed to this file
|
|
|
|
# * address -- local interface to bind
|
|
|
|
# * signaturetype -- signature type for new destination. 0 (DSA/SHA1), 1 (EcDSA/SHA256) or 7 (EdDSA/SHA512)
|
|
|
|
[somelabel]
|
|
|
|
type = client
|
|
|
|
address = 127.0.0.1
|
|
|
|
port = 6668
|
|
|
|
destination = irc.postman.i2p
|
|
|
|
keys = irc-keys.dat
|
|
|
|
*/
|
|
|
|
class ClientTunnelConfig : public TunnelConfig {
|
|
|
|
std::string dest;
|
|
|
|
int port;
|
|
|
|
std::string keys;
|
|
|
|
std::string address;
|
|
|
|
int destinationPort;
|
|
|
|
i2p::data::SigningKeyType sigType;
|
|
|
|
public:
|
|
|
|
ClientTunnelConfig(std::string name_, QString type_, I2CPParameters& i2cpParameters_,
|
|
|
|
std::string dest_,
|
|
|
|
int port_,
|
|
|
|
std::string keys_,
|
|
|
|
std::string address_,
|
|
|
|
int destinationPort_,
|
2020-10-07 15:16:06 +00:00
|
|
|
i2p::data::SigningKeyType sigType_,
|
|
|
|
int cryptoType_): TunnelConfig(name_, type_, i2cpParameters_, cryptoType_),
|
2017-03-14 12:34:01 +00:00
|
|
|
dest(dest_),
|
|
|
|
port(port_),
|
|
|
|
keys(keys_),
|
|
|
|
address(address_),
|
2017-04-03 13:45:56 +00:00
|
|
|
destinationPort(destinationPort_),
|
2020-10-07 15:16:06 +00:00
|
|
|
sigType(sigType_) {}
|
2017-03-14 12:34:01 +00:00
|
|
|
std::string& getdest(){return dest;}
|
|
|
|
int getport(){return port;}
|
|
|
|
std::string & getkeys(){return keys;}
|
|
|
|
std::string & getaddress(){return address;}
|
|
|
|
int getdestinationPort(){return destinationPort;}
|
|
|
|
i2p::data::SigningKeyType getsigType(){return sigType;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void setdest(const std::string& dest_){dest=dest_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setport(int port_){port=port_;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void setkeys(const std::string & keys_){keys=keys_;}
|
|
|
|
void setaddress(const std::string & address_){address=address_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setdestinationPort(int destinationPort_){destinationPort=destinationPort_;}
|
|
|
|
void setsigType(i2p::data::SigningKeyType sigType_){sigType=sigType_;}
|
2017-06-02 14:59:13 +00:00
|
|
|
virtual void saveToStringStream(std::stringstream& out);
|
2017-03-14 12:34:01 +00:00
|
|
|
virtual ClientTunnelConfig* asClientTunnelConfig(){return this;}
|
|
|
|
virtual ServerTunnelConfig* asServerTunnelConfig(){return nullptr;}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
# mandatory parameters:
|
|
|
|
# * host -- ip address of our service
|
|
|
|
# * port -- port of our service
|
|
|
|
# * keys -- file with LeaseSet of address in i2p
|
|
|
|
std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST);
|
|
|
|
int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT);
|
|
|
|
std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS);
|
|
|
|
# optional parameters (may be omitted)
|
|
|
|
int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0);
|
|
|
|
std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, "");
|
|
|
|
std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, "");
|
|
|
|
std::string webircpass = section.second.get<std::string> (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, "");
|
|
|
|
bool gzip = section.second.get (I2P_SERVER_TUNNEL_GZIP, true);
|
|
|
|
i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
|
|
|
std::string address = section.second.get<std::string> (I2P_SERVER_TUNNEL_ADDRESS, "127.0.0.1");
|
|
|
|
bool isUniqueLocal = section.second.get(I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
|
|
|
|
# * inport -- optional, i2p service port, if unset - the same as 'port'
|
|
|
|
# * accesslist -- comma-separated list of i2p addresses, allowed to connect
|
|
|
|
# every address is b32 without '.b32.i2p' part
|
|
|
|
[somelabel]
|
|
|
|
type = server
|
|
|
|
host = 127.0.0.1
|
|
|
|
port = 6667
|
|
|
|
keys = irc.dat
|
|
|
|
*/
|
|
|
|
class ServerTunnelConfig : public TunnelConfig {
|
|
|
|
std::string host;
|
|
|
|
int port;
|
|
|
|
std::string keys;
|
|
|
|
int inPort;
|
|
|
|
std::string accessList;
|
|
|
|
std::string hostOverride;
|
|
|
|
std::string webircpass;
|
|
|
|
bool gzip;
|
|
|
|
i2p::data::SigningKeyType sigType;
|
|
|
|
std::string address;
|
|
|
|
bool isUniqueLocal;
|
|
|
|
public:
|
|
|
|
ServerTunnelConfig(std::string name_, QString type_, I2CPParameters& i2cpParameters_,
|
|
|
|
std::string host_,
|
|
|
|
int port_,
|
|
|
|
std::string keys_,
|
|
|
|
int inPort_,
|
|
|
|
std::string accessList_,
|
|
|
|
std::string hostOverride_,
|
|
|
|
std::string webircpass_,
|
|
|
|
bool gzip_,
|
|
|
|
i2p::data::SigningKeyType sigType_,
|
|
|
|
std::string address_,
|
2020-10-07 15:16:06 +00:00
|
|
|
bool isUniqueLocal_,
|
|
|
|
int cryptoType_): TunnelConfig(name_, type_, i2cpParameters_, cryptoType_),
|
2017-03-14 12:34:01 +00:00
|
|
|
host(host_),
|
|
|
|
port(port_),
|
|
|
|
keys(keys_),
|
|
|
|
inPort(inPort_),
|
|
|
|
accessList(accessList_),
|
|
|
|
hostOverride(hostOverride_),
|
|
|
|
webircpass(webircpass_),
|
|
|
|
gzip(gzip_),
|
|
|
|
sigType(sigType_),
|
2017-07-28 01:21:25 +00:00
|
|
|
address(address_),
|
|
|
|
isUniqueLocal(isUniqueLocal_) {}
|
2017-03-14 12:34:01 +00:00
|
|
|
std::string& gethost(){return host;}
|
|
|
|
int getport(){return port;}
|
|
|
|
std::string& getkeys(){return keys;}
|
|
|
|
int getinPort(){return inPort;}
|
|
|
|
std::string& getaccessList(){return accessList;}
|
|
|
|
std::string& gethostOverride(){return hostOverride;}
|
|
|
|
std::string& getwebircpass(){return webircpass;}
|
|
|
|
bool getgzip(){return gzip;}
|
|
|
|
i2p::data::SigningKeyType getsigType(){return sigType;}
|
|
|
|
std::string& getaddress(){return address;}
|
|
|
|
bool getisUniqueLocal(){return isUniqueLocal;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void sethost(const std::string& host_){host=host_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setport(int port_){port=port_;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void setkeys(const std::string& keys_){keys=keys_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setinPort(int inPort_){inPort=inPort_;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void setaccessList(const std::string& accessList_){accessList=accessList_;}
|
|
|
|
void sethostOverride(const std::string& hostOverride_){hostOverride=hostOverride_;}
|
|
|
|
void setwebircpass(const std::string& webircpass_){webircpass=webircpass_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setgzip(bool gzip_){gzip=gzip_;}
|
|
|
|
void setsigType(i2p::data::SigningKeyType sigType_){sigType=sigType_;}
|
2017-06-02 14:59:13 +00:00
|
|
|
void setaddress(const std::string& address_){address=address_;}
|
2017-03-14 12:34:01 +00:00
|
|
|
void setisUniqueLocal(bool isUniqueLocal_){isUniqueLocal=isUniqueLocal_;}
|
2017-06-02 14:59:13 +00:00
|
|
|
virtual void saveToStringStream(std::stringstream& out);
|
2017-03-14 12:34:01 +00:00
|
|
|
virtual ClientTunnelConfig* asClientTunnelConfig(){return nullptr;}
|
|
|
|
virtual ServerTunnelConfig* asServerTunnelConfig(){return this;}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TUNNELCONFIG_H
|