MCPcopy Create free account
hub / github.com/apache/trafficserver / accept

Method accept

src/proxy/http2/Http2SessionAccept.cc:42–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40Http2SessionAccept::~Http2SessionAccept() = default;
41
42bool
43Http2SessionAccept::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
85int
86Http2SessionAccept::mainEvent(int event, void *data)

Callers 1

mainEventMethod · 0.95

Calls 12

this_ethreadFunction · 0.85
setThreadAffinityMethod · 0.80
matchFunction · 0.70
ats_ip_ntopFunction · 0.50
ats_ip_nptopFunction · 0.50
get_remote_addrMethod · 0.45
isValidMethod · 0.45
onMethod · 0.45
new_connectionMethod · 0.45

Tested by

no test coverage detected