MCPcopy Create free account
hub / github.com/ElementsProject/elements / ThreadI2PAcceptIncoming

Method ThreadI2PAcceptIncoming

src/net.cpp:2361–2398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2359}
2360
2361void CConnman::ThreadI2PAcceptIncoming()
2362{
2363 static constexpr auto err_wait_begin = 1s;
2364 static constexpr auto err_wait_cap = 5min;
2365 auto err_wait = err_wait_begin;
2366
2367 bool advertising_listen_addr = false;
2368 i2p::Connection conn;
2369
2370 while (!interruptNet) {
2371
2372 if (!m_i2p_sam_session->Listen(conn)) {
2373 if (advertising_listen_addr && conn.me.IsValid()) {
2374 RemoveLocal(conn.me);
2375 advertising_listen_addr = false;
2376 }
2377
2378 interruptNet.sleep_for(err_wait);
2379 if (err_wait < err_wait_cap) {
2380 err_wait *= 2;
2381 }
2382
2383 continue;
2384 }
2385
2386 if (!advertising_listen_addr) {
2387 AddLocal(conn.me, LOCAL_MANUAL);
2388 advertising_listen_addr = true;
2389 }
2390
2391 if (!m_i2p_sam_session->Accept(conn)) {
2392 continue;
2393 }
2394
2395 CreateNodeFromAcceptedSocket(std::move(conn.sock), NetPermissionFlags::None,
2396 CAddress{conn.me, NODE_NONE}, CAddress{conn.peer, NODE_NONE});
2397 }
2398}
2399
2400bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, NetPermissionFlags permissions)
2401{

Callers

nothing calls this directly

Calls 6

RemoveLocalFunction · 0.85
AddLocalFunction · 0.85
ListenMethod · 0.80
sleep_forMethod · 0.80
IsValidMethod · 0.45
AcceptMethod · 0.45

Tested by

no test coverage detected