MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ClientDestination

Method ClientDestination

libi2pd/Destination.cpp:971–1096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969 }
970
971 ClientDestination::ClientDestination (boost::asio::io_context& service, const i2p::data::PrivateKeys& keys,
972 bool isPublic, const i2p::util::Mapping * params):
973 LeaseSetDestination (service, isPublic, params),
974 m_Keys (keys), m_PreferredCryptoType (0), m_StreamingAckDelay (DEFAULT_INITIAL_ACK_DELAY),
975 m_StreamingOutboundSpeed (DEFAULT_MAX_OUTBOUND_SPEED),
976 m_StreamingInboundSpeed (DEFAULT_MAX_INBOUND_SPEED),
977 m_StreamingMaxConcurrentStreams (DEFAULT_MAX_CONCURRENT_STREAMS),
978 m_StreamingMaxConnsPerMinute (DEFAULT_MAX_CONNS_PER_MINUTE),
979 m_StreamingMaxWindowSize (i2p::stream::MAX_WINDOW_SIZE),
980 m_StreamingMaxResends (i2p::stream::MAX_NUM_RESEND_ATTEMPTS),
981 m_IsStreamingAnswerPings (DEFAULT_ANSWER_PINGS), m_IsStreamingDontSign (DEFAULT_DONT_SIGN),
982 m_LastPort (0), m_DatagramDestination (nullptr), m_RefCounter (0),
983 m_LastPublishedTimestamp (0), m_ReadyChecker(service)
984 {
985 if (keys.IsOfflineSignature () && GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_LEASESET)
986 SetLeaseSetType (i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2); // offline keys can be published with LS2 only
987
988 // extract encryption type params for LS2
989 std::set<i2p::data::CryptoKeyType> encryptionKeyTypes;
990 if (params)
991 {
992 auto encryptionTypesStr = (*params)[I2CP_PARAM_LEASESET_ENCRYPTION_TYPE];
993 if (!encryptionTypesStr.empty ())
994 {
995 // comma-separated values
996 std::vector<std::string> values;
997 boost::split(values, encryptionTypesStr, boost::is_any_of(","));
998 for (auto& it1: values)
999 {
1000 try
1001 {
1002 i2p::data::CryptoKeyType cryptoType = std::stoi(it1);
1003#if !OPENSSL_PQ
1004 if (cryptoType <= i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD) // skip PQ keys if not supported
1005#endif
1006 {
1007 if (!m_PreferredCryptoType && cryptoType)
1008 m_PreferredCryptoType = cryptoType; // first non-zero in the list
1009 encryptionKeyTypes.insert (cryptoType);
1010 }
1011 }
1012 catch (std::exception& ex)
1013 {
1014 LogPrint (eLogInfo, "Destination: Unexpected crypto type ", it1, ". ", ex.what ());
1015 continue;
1016 }
1017 }
1018 }
1019 }
1020 // if no encryption type specified use 0,4 or 0,4,6 if post quantum
1021 if (encryptionKeyTypes.empty ())
1022 {
1023 encryptionKeyTypes.insert ( { GetIdentity ()->GetCryptoKeyType (),
1024#if OPENSSL_PQ
1025 i2p::data::CRYPTO_KEY_TYPE_ECIES_MLKEM768_X25519_AEAD,
1026#endif
1027 i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD });
1028#if OPENSSL_PQ

Callers

nothing calls this directly

Calls 7

stoiFunction · 0.85
LogPrintFunction · 0.85
IsOfflineSignatureMethod · 0.80
GetCryptoKeyTypeMethod · 0.80
GenerateKeysMethod · 0.45
CreateDecryptorMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected