mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 03:37:49 +02:00
I2P -> .NET
This commit is contained in:
parent
f176f1909b
commit
fdb0ce6703
272 changed files with 5702 additions and 8931 deletions
|
@ -4,12 +4,12 @@
|
|||
#include "QString"
|
||||
#include <string>
|
||||
|
||||
#include "../../libi2pd_client/ClientContext.h"
|
||||
#include "../../libi2pd/Destination.h"
|
||||
#include "../../libdotnet_client/ClientContext.h"
|
||||
#include "../../libdotnet/Destination.h"
|
||||
#include "TunnelsPageUpdateListener.h"
|
||||
|
||||
|
||||
class I2CPParameters{
|
||||
class DNCPParameters{
|
||||
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
|
||||
|
@ -17,7 +17,7 @@ class I2CPParameters{
|
|||
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
|
||||
public:
|
||||
I2CPParameters(): inbound_length(),
|
||||
DNCPParameters(): inbound_length(),
|
||||
outbound_length(),
|
||||
inbound_quantity(),
|
||||
outbound_quantity(),
|
||||
|
@ -42,48 +42,48 @@ class ClientTunnelConfig;
|
|||
class ServerTunnelConfig;
|
||||
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";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_CLIENT[] = "client";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_SERVER[] = "server";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_HTTP[] = "http";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_IRC[] = "irc";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_UDPCLIENT[] = "udpclient";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_UDPSERVER[] = "udpserver";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_SOCKS[] = "socks";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_WEBSOCKS[] = "websocks";
|
||||
const char DOTNET_TUNNELS_SECTION_TYPE_HTTPPROXY[] = "httpproxy";
|
||||
*/
|
||||
QString type;
|
||||
std::string name;
|
||||
public:
|
||||
TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_):
|
||||
type(type_), name(name_), i2cpParameters(i2cpParameters_) {}
|
||||
TunnelConfig(std::string name_, QString& type_, DNCPParameters& dncpParameters_):
|
||||
type(type_), name(name_), dncpParameters(dncpParameters_) {}
|
||||
virtual ~TunnelConfig(){}
|
||||
const QString& getType(){return type;}
|
||||
const std::string& getName(){return name;}
|
||||
void setType(const QString& type_){type=type_;}
|
||||
void setName(const std::string& name_){name=name_;}
|
||||
I2CPParameters& getI2cpParameters(){return i2cpParameters;}
|
||||
DNCPParameters& getI2cpParameters(){return dncpParameters;}
|
||||
void saveHeaderToStringStream(std::stringstream& out);
|
||||
void saveI2CPParametersToStringStream(std::stringstream& out);
|
||||
void saveDNCPParametersToStringStream(std::stringstream& out);
|
||||
virtual void saveToStringStream(std::stringstream& out)=0;
|
||||
virtual ClientTunnelConfig* asClientTunnelConfig()=0;
|
||||
virtual ServerTunnelConfig* asServerTunnelConfig()=0;
|
||||
|
||||
private:
|
||||
I2CPParameters i2cpParameters;
|
||||
DNCPParameters dncpParameters;
|
||||
};
|
||||
|
||||
/*
|
||||
# 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);
|
||||
if (type == DOTNET_TUNNELS_SECTION_TYPE_CLIENT || type == DOTNET_TUNNELS_SECTION_TYPE_UDPCLIENT)
|
||||
dest = section.second.get<std::string> (DOTNET_CLIENT_TUNNEL_DESTINATION);
|
||||
int port = section.second.get<int> (DOTNET_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);
|
||||
std::string keys = section.second.get (DOTNET_CLIENT_TUNNEL_KEYS, "");
|
||||
std::string address = section.second.get (DOTNET_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
|
||||
int destinationPort = section.second.get (DOTNET_CLIENT_TUNNEL_DESTINATION_PORT, 0);
|
||||
dotnet::data::SigningKeyType sigType = section.second.get (DOTNET_CLIENT_TUNNEL_SIGNATURE_TYPE, dotnet::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
|
||||
|
@ -92,7 +92,7 @@ private:
|
|||
type = client
|
||||
address = 127.0.0.1
|
||||
port = 6668
|
||||
destination = irc.postman.i2p
|
||||
destination = irc.postman.dotnet
|
||||
keys = irc-keys.dat
|
||||
*/
|
||||
class ClientTunnelConfig : public TunnelConfig {
|
||||
|
@ -101,15 +101,15 @@ class ClientTunnelConfig : public TunnelConfig {
|
|||
std::string keys;
|
||||
std::string address;
|
||||
int destinationPort;
|
||||
i2p::data::SigningKeyType sigType;
|
||||
dotnet::data::SigningKeyType sigType;
|
||||
public:
|
||||
ClientTunnelConfig(std::string name_, QString type_, I2CPParameters& i2cpParameters_,
|
||||
ClientTunnelConfig(std::string name_, QString type_, DNCPParameters& dncpParameters_,
|
||||
std::string dest_,
|
||||
int port_,
|
||||
std::string keys_,
|
||||
std::string address_,
|
||||
int destinationPort_,
|
||||
i2p::data::SigningKeyType sigType_): TunnelConfig(name_, type_, i2cpParameters_),
|
||||
dotnet::data::SigningKeyType sigType_): TunnelConfig(name_, type_, dncpParameters_),
|
||||
dest(dest_),
|
||||
port(port_),
|
||||
keys(keys_),
|
||||
|
@ -121,13 +121,13 @@ public:
|
|||
std::string & getkeys(){return keys;}
|
||||
std::string & getaddress(){return address;}
|
||||
int getdestinationPort(){return destinationPort;}
|
||||
i2p::data::SigningKeyType getsigType(){return sigType;}
|
||||
dotnet::data::SigningKeyType getsigType(){return sigType;}
|
||||
void setdest(const std::string& dest_){dest=dest_;}
|
||||
void setport(int port_){port=port_;}
|
||||
void setkeys(const std::string & keys_){keys=keys_;}
|
||||
void setaddress(const std::string & address_){address=address_;}
|
||||
void setdestinationPort(int destinationPort_){destinationPort=destinationPort_;}
|
||||
void setsigType(i2p::data::SigningKeyType sigType_){sigType=sigType_;}
|
||||
void setsigType(dotnet::data::SigningKeyType sigType_){sigType=sigType_;}
|
||||
virtual void saveToStringStream(std::stringstream& out);
|
||||
virtual ClientTunnelConfig* asClientTunnelConfig(){return this;}
|
||||
virtual ServerTunnelConfig* asServerTunnelConfig(){return nullptr;}
|
||||
|
@ -137,22 +137,22 @@ public:
|
|||
# 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);
|
||||
# * keys -- file with LeaseSet of address in dotnet
|
||||
std::string host = section.second.get<std::string> (DOTNET_SERVER_TUNNEL_HOST);
|
||||
int port = section.second.get<int> (DOTNET_SERVER_TUNNEL_PORT);
|
||||
std::string keys = section.second.get<std::string> (DOTNET_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
|
||||
int inPort = section.second.get (DOTNET_SERVER_TUNNEL_INPORT, 0);
|
||||
std::string accessList = section.second.get (DOTNET_SERVER_TUNNEL_ACCESS_LIST, "");
|
||||
std::string hostOverride = section.second.get (DOTNET_SERVER_TUNNEL_HOST_OVERRIDE, "");
|
||||
std::string webircpass = section.second.get<std::string> (DOTNET_SERVER_TUNNEL_WEBIRC_PASSWORD, "");
|
||||
bool gzip = section.second.get (DOTNET_SERVER_TUNNEL_GZIP, true);
|
||||
dotnet::data::SigningKeyType sigType = section.second.get (DOTNET_SERVER_TUNNEL_SIGNATURE_TYPE, dotnet::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
||||
std::string address = section.second.get<std::string> (DOTNET_SERVER_TUNNEL_ADDRESS, "127.0.0.1");
|
||||
bool isUniqueLocal = section.second.get(DOTNET_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL, true);
|
||||
# * inport -- optional, dotnet service port, if unset - the same as 'port'
|
||||
# * accesslist -- comma-separated list of dotnet addresses, allowed to connect
|
||||
# every address is b32 without '.b32.dotnet' part
|
||||
[somelabel]
|
||||
type = server
|
||||
host = 127.0.0.1
|
||||
|
@ -168,11 +168,11 @@ class ServerTunnelConfig : public TunnelConfig {
|
|||
std::string hostOverride;
|
||||
std::string webircpass;
|
||||
bool gzip;
|
||||
i2p::data::SigningKeyType sigType;
|
||||
dotnet::data::SigningKeyType sigType;
|
||||
std::string address;
|
||||
bool isUniqueLocal;
|
||||
public:
|
||||
ServerTunnelConfig(std::string name_, QString type_, I2CPParameters& i2cpParameters_,
|
||||
ServerTunnelConfig(std::string name_, QString type_, DNCPParameters& dncpParameters_,
|
||||
std::string host_,
|
||||
int port_,
|
||||
std::string keys_,
|
||||
|
@ -181,9 +181,9 @@ public:
|
|||
std::string hostOverride_,
|
||||
std::string webircpass_,
|
||||
bool gzip_,
|
||||
i2p::data::SigningKeyType sigType_,
|
||||
dotnet::data::SigningKeyType sigType_,
|
||||
std::string address_,
|
||||
bool isUniqueLocal_): TunnelConfig(name_, type_, i2cpParameters_),
|
||||
bool isUniqueLocal_): TunnelConfig(name_, type_, dncpParameters_),
|
||||
host(host_),
|
||||
port(port_),
|
||||
keys(keys_),
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
std::string& gethostOverride(){return hostOverride;}
|
||||
std::string& getwebircpass(){return webircpass;}
|
||||
bool getgzip(){return gzip;}
|
||||
i2p::data::SigningKeyType getsigType(){return sigType;}
|
||||
dotnet::data::SigningKeyType getsigType(){return sigType;}
|
||||
std::string& getaddress(){return address;}
|
||||
bool getisUniqueLocal(){return isUniqueLocal;}
|
||||
void sethost(const std::string& host_){host=host_;}
|
||||
|
@ -214,7 +214,7 @@ public:
|
|||
void sethostOverride(const std::string& hostOverride_){hostOverride=hostOverride_;}
|
||||
void setwebircpass(const std::string& webircpass_){webircpass=webircpass_;}
|
||||
void setgzip(bool gzip_){gzip=gzip_;}
|
||||
void setsigType(i2p::data::SigningKeyType sigType_){sigType=sigType_;}
|
||||
void setsigType(dotnet::data::SigningKeyType sigType_){sigType=sigType_;}
|
||||
void setaddress(const std::string& address_){address=address_;}
|
||||
void setisUniqueLocal(bool isUniqueLocal_){isUniqueLocal=isUniqueLocal_;}
|
||||
virtual void saveToStringStream(std::stringstream& out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue