This commit is contained in:
Jeff Becker 2017-04-08 15:14:47 -04:00
parent 89dfe2b763
commit 2fe71782a7
3 changed files with 29 additions and 29 deletions

View File

@ -35,7 +35,7 @@ namespace client
const char I2P_CLIENT_TUNNEL_KEYS[] = "keys"; const char I2P_CLIENT_TUNNEL_KEYS[] = "keys";
const char I2P_CLIENT_TUNNEL_SIGNATURE_TYPE[] = "signaturetype"; const char I2P_CLIENT_TUNNEL_SIGNATURE_TYPE[] = "signaturetype";
const char I2P_CLIENT_TUNNEL_DESTINATION_PORT[] = "destinationport"; const char I2P_CLIENT_TUNNEL_DESTINATION_PORT[] = "destinationport";
const char I2P_CLIENT_TUNNEL_MATCH_TUNNELS[] = "matchtunnels"; const char I2P_CLIENT_TUNNEL_MATCH_TUNNELS[] = "matchtunnels";
const char I2P_SERVER_TUNNEL_HOST[] = "host"; const char I2P_SERVER_TUNNEL_HOST[] = "host";
const char I2P_SERVER_TUNNEL_HOST_OVERRIDE[] = "hostoverride"; const char I2P_SERVER_TUNNEL_HOST_OVERRIDE[] = "hostoverride";
const char I2P_SERVER_TUNNEL_PORT[] = "port"; const char I2P_SERVER_TUNNEL_PORT[] = "port";

View File

@ -7,29 +7,29 @@ namespace i2p
{ {
namespace client namespace client
{ {
/** /**
client tunnel that uses same OBEP as IBGW of each remote lease for a remote destination client tunnel that uses same OBEP as IBGW of each remote lease for a remote destination
*/ */
class MatchedTunnelDestination : public ClientDestination, public i2p::tunnel::ITunnelPeerSelector class MatchedTunnelDestination : public ClientDestination, public i2p::tunnel::ITunnelPeerSelector
{ {
public: public:
MatchedTunnelDestination(const i2p::data::PrivateKeys& keys, const std::string & remoteName, const std::map<std::string, std::string> * params = nullptr); MatchedTunnelDestination(const i2p::data::PrivateKeys& keys, const std::string & remoteName, const std::map<std::string, std::string> * params = nullptr);
bool Start(); bool Start();
bool Stop(); bool Stop();
bool SelectPeers(i2p::tunnel::Path & peers, int hops, bool inbound); bool SelectPeers(i2p::tunnel::Path & peers, int hops, bool inbound);
bool OnBuildResult(const i2p::tunnel::Path & peers, bool inbound, i2p::tunnel::TunnelBuildResult result); bool OnBuildResult(const i2p::tunnel::Path & peers, bool inbound, i2p::tunnel::TunnelBuildResult result);
private: private:
void ResolveCurrentLeaseSet(); void ResolveCurrentLeaseSet();
void HandleFoundCurrentLeaseSet(std::shared_ptr<const i2p::data::LeaseSet> ls); void HandleFoundCurrentLeaseSet(std::shared_ptr<const i2p::data::LeaseSet> ls);
private: private:
std::string m_RemoteName; std::string m_RemoteName;
i2p::data::IdentHash m_RemoteIdent; i2p::data::IdentHash m_RemoteIdent;
std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet; std::shared_ptr<const i2p::data::LeaseSet> m_RemoteLeaseSet;
std::shared_ptr<boost::asio::deadline_timer> m_ResolveTimer; std::shared_ptr<boost::asio::deadline_timer> m_ResolveTimer;
}; };
} }
} }

View File

@ -30,21 +30,21 @@ namespace tunnel
eBuildResultTimeout // tunnel build timed out eBuildResultTimeout // tunnel build timed out
}; };
typedef std::shared_ptr<const i2p::data::IdentityEx> Peer; typedef std::shared_ptr<const i2p::data::IdentityEx> Peer;
typedef std::vector<Peer> Path; typedef std::vector<Peer> Path;
/** interface for custom tunnel peer selection algorithm */ /** interface for custom tunnel peer selection algorithm */
struct ITunnelPeerSelector struct ITunnelPeerSelector
{ {
virtual ~ITunnelPeerSelector() {}; virtual ~ITunnelPeerSelector() {};
virtual bool SelectPeers(Path & peers, int hops, bool isInbound) = 0; virtual bool SelectPeers(Path & peers, int hops, bool isInbound) = 0;
virtual bool OnBuildResult(const Path & peers, bool isInbound, TunnelBuildResult result) = 0; virtual bool OnBuildResult(const Path & peers, bool isInbound, TunnelBuildResult result) = 0;
}; };
typedef std::function<std::shared_ptr<const i2p::data::RouterInfo>(std::shared_ptr<const i2p::data::RouterInfo>)> SelectHopFunc; typedef std::function<std::shared_ptr<const i2p::data::RouterInfo>(std::shared_ptr<const i2p::data::RouterInfo>)> SelectHopFunc;
// standard peer selection algorithm // standard peer selection algorithm
bool StandardSelectPeers(Path & path, int hops, bool inbound, SelectHopFunc nextHop); bool StandardSelectPeers(Path & path, int hops, bool inbound, SelectHopFunc nextHop);
class TunnelPool: public std::enable_shared_from_this<TunnelPool> // per local destination class TunnelPool: public std::enable_shared_from_this<TunnelPool> // per local destination
{ {
@ -95,8 +95,8 @@ namespace tunnel
void OnTunnelBuildResult(std::shared_ptr<Tunnel> tunnel, TunnelBuildResult result); void OnTunnelBuildResult(std::shared_ptr<Tunnel> tunnel, TunnelBuildResult result);
// for overriding tunnel peer selection // for overriding tunnel peer selection
std::shared_ptr<const i2p::data::RouterInfo> SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const; std::shared_ptr<const i2p::data::RouterInfo> SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const;
private: private: