| 40 | Http2SessionAccept::~Http2SessionAccept() = default; |
| 41 | |
| 42 | bool |
| 43 | Http2SessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferReader *reader) |
| 44 | { |
| 45 | sockaddr const *client_ip = netvc->get_remote_addr(); |
| 46 | |
| 47 | for (int i = 0; i < IpAllow::Subject::MAX_SUBJECTS; ++i) { |
| 48 | if (IpAllow::Subject::PEER == IpAllow::subjects[i]) { |
| 49 | client_ip = netvc->get_effective_remote_addr(); |
| 50 | break; |
| 51 | } else if (IpAllow::Subject::PROXY == IpAllow::subjects[i] && |
| 52 | netvc->get_proxy_protocol_version() != ProxyProtocolVersion::UNDEFINED) { |
| 53 | client_ip = netvc->get_proxy_protocol_src_addr(); |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | IpAllow::ACL session_acl = IpAllow::match(client_ip, IpAllow::SRC_ADDR); |
| 59 | if (!session_acl.isValid()) { |
| 60 | ip_port_text_buffer ipb; |
| 61 | Warning("HTTP/2 client '%s' prohibited by ip-allow policy", ats_ip_ntop(client_ip, ipb, sizeof(ipb))); |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | netvc->attributes = this->options.transport_type; |
| 66 | |
| 67 | if (dbg_ctl_http2_seq.on()) { |
| 68 | ip_port_text_buffer ipb; |
| 69 | |
| 70 | DbgPrint(dbg_ctl_http2_seq, "[HttpSessionAccept2:mainEvent %p] accepted connection from %s transport type = %d", netvc, |
| 71 | ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes); |
| 72 | } |
| 73 | |
| 74 | Http2ClientSession *new_session = THREAD_ALLOC_INIT(http2ClientSessionAllocator, this_ethread()); |
| 75 | new_session->acl = std::move(session_acl); |
| 76 | new_session->accept_options = &options; |
| 77 | |
| 78 | // Pin session to current ET_NET thread |
| 79 | new_session->setThreadAffinity(this_ethread()); |
| 80 | new_session->new_connection(netvc, iobuf, reader); |
| 81 | |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | int |
| 86 | Http2SessionAccept::mainEvent(int event, void *data) |
no test coverage detected