| 26 | namespace client |
| 27 | { |
| 28 | LeaseSetDestination::LeaseSetDestination (boost::asio::io_context& service, |
| 29 | bool isPublic, const i2p::util::Mapping * params): |
| 30 | m_Service (service), m_IsPublic (isPublic), m_PublishReplyToken (0), |
| 31 | m_LastSubmissionTime (0), m_PublishConfirmationTimer (m_Service), |
| 32 | m_PublishVerificationTimer (m_Service), m_PublishDelayTimer (m_Service), m_CleanupTimer (m_Service), |
| 33 | m_LeaseSetType (DEFAULT_LEASESET_TYPE), m_AuthType (i2p::data::ENCRYPTED_LEASESET_AUTH_TYPE_NONE) |
| 34 | { |
| 35 | int inLen = DEFAULT_INBOUND_TUNNEL_LENGTH; |
| 36 | int inQty = DEFAULT_INBOUND_TUNNELS_QUANTITY; |
| 37 | int outLen = DEFAULT_OUTBOUND_TUNNEL_LENGTH; |
| 38 | int outQty = DEFAULT_OUTBOUND_TUNNELS_QUANTITY; |
| 39 | int inVar = DEFAULT_INBOUND_TUNNELS_LENGTH_VARIANCE; |
| 40 | int outVar = DEFAULT_OUTBOUND_TUNNELS_LENGTH_VARIANCE; |
| 41 | int numTags = DEFAULT_TAGS_TO_SEND; |
| 42 | bool isHighBandwidth = true; |
| 43 | std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers; |
| 44 | std::string_view explicitPeersStr, trustedRoutersStr; |
| 45 | try |
| 46 | { |
| 47 | if (params) |
| 48 | { |
| 49 | params->Get (I2CP_PARAM_INBOUND_TUNNEL_LENGTH, inLen); |
| 50 | params->Get (I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, outLen); |
| 51 | params->Get (I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, inQty); |
| 52 | params->Get (I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, outQty); |
| 53 | params->Get (I2CP_PARAM_INBOUND_TUNNELS_LENGTH_VARIANCE, inVar); |
| 54 | params->Get (I2CP_PARAM_OUTBOUND_TUNNELS_LENGTH_VARIANCE, outVar); |
| 55 | params->Get (I2CP_PARAM_TAGS_TO_SEND, numTags); |
| 56 | LogPrint (eLogInfo, "Destination: Parameters for tunnel set to: ", inQty, " inbound (", inLen, " hops), ", outQty, " outbound (", outLen, " hops), ", numTags, " tags"); |
| 57 | int ratchetsInboundTags = 0; |
| 58 | if (params->Get (I2CP_PARAM_RATCHET_INBOUND_TAGS, ratchetsInboundTags)) |
| 59 | { |
| 60 | if (ratchetsInboundTags && ratchetsInboundTags < i2p::garlic::ECIESX25519_MIN_NUM_GENERATED_TAGS) |
| 61 | ratchetsInboundTags = i2p::garlic::ECIESX25519_MIN_NUM_GENERATED_TAGS; |
| 62 | SetNumRatchetInboundTags (ratchetsInboundTags); |
| 63 | } |
| 64 | explicitPeersStr = (*params)[I2CP_PARAM_EXPLICIT_PEERS]; |
| 65 | trustedRoutersStr = (*params)[I2CP_PARAM_TRUSTED_ROUTERS]; |
| 66 | m_Nickname = (*params)[I2CP_PARAM_INBOUND_NICKNAME]; |
| 67 | if (m_Nickname.empty ()) // try outbound |
| 68 | m_Nickname = (*params)[I2CP_PARAM_OUTBOUND_NICKNAME]; |
| 69 | // otherwise we set default nickname in Start when we know local address |
| 70 | bool dontPublishLeaseSet = true; |
| 71 | if (params->Get (I2CP_PARAM_DONT_PUBLISH_LEASESET, dontPublishLeaseSet)) |
| 72 | m_IsPublic = !dontPublishLeaseSet; // override isPublic |
| 73 | params->Get (I2CP_PARAM_LEASESET_TYPE, m_LeaseSetType); |
| 74 | if (m_LeaseSetType == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) |
| 75 | { |
| 76 | // authentication for encrypted LeaseSet |
| 77 | int authType = 0; |
| 78 | if (params->Get (I2CP_PARAM_LEASESET_AUTH_TYPE, authType)) |
| 79 | { |
| 80 | if (authType >= i2p::data::ENCRYPTED_LEASESET_AUTH_TYPE_NONE && authType <= i2p::data::ENCRYPTED_LEASESET_AUTH_TYPE_PSK) |
| 81 | m_AuthType = authType; |
| 82 | else |
| 83 | LogPrint (eLogError, "Destination: Unknown auth type: ", authType); |
| 84 | } |
| 85 | } |
nothing calls this directly
no test coverage detected