| 18 | } |
| 19 | |
| 20 | FUZZ_TARGET_INIT(i2p, initialize_i2p) |
| 21 | { |
| 22 | FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; |
| 23 | |
| 24 | // Mock CreateSock() to create FuzzedSock. |
| 25 | auto CreateSockOrig = CreateSock; |
| 26 | CreateSock = [&fuzzed_data_provider](const CService&) { |
| 27 | return std::make_unique<FuzzedSock>(fuzzed_data_provider); |
| 28 | }; |
| 29 | |
| 30 | const CService sam_proxy; |
| 31 | CThreadInterrupt interrupt; |
| 32 | |
| 33 | i2p::sam::Session sess{gArgs.GetDataDirNet() / "fuzzed_i2p_private_key", sam_proxy, &interrupt}; |
| 34 | |
| 35 | i2p::Connection conn; |
| 36 | |
| 37 | if (sess.Listen(conn)) { |
| 38 | if (sess.Accept(conn)) { |
| 39 | try { |
| 40 | (void)conn.sock->RecvUntilTerminator('\n', 10ms, interrupt, i2p::sam::MAX_MSG_SIZE); |
| 41 | } catch (const std::runtime_error&) { |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | const CService to; |
| 47 | bool proxy_error; |
| 48 | |
| 49 | if (sess.Connect(to, conn, proxy_error)) { |
| 50 | try { |
| 51 | conn.sock->SendComplete("verack\n", 10ms, interrupt); |
| 52 | } catch (const std::runtime_error&) { |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | CreateSock = CreateSockOrig; |
| 57 | } |
nothing calls this directly
no test coverage detected