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

Method parse_socks_client_request

src/traffic_server/SocksProxy.cc:492–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492int
493SocksProxy::parse_socks_client_request(unsigned char *p)
494{
495 int ret = EVENT_DONE;
496
497 if (timeout) {
498 timeout->cancel(this);
499 timeout = nullptr;
500 }
501
502 if (port == netProcessor.socks_conf_stuff->http_port && p[1] == SOCKS_CONNECT) {
503 /* disable further reads */
504 clientVIO->nbytes = clientVIO->ndone;
505
506 ret = setupHttpRequest(p);
507 vc_handler = &SocksProxy::state_handing_over_http_request;
508 sendResp(true);
509 state = HTTP_REQ;
510 } else {
511 SOCKSPROXY_INC_STAT(socksproxy_tunneled_connections_stat);
512 Dbg(dbg_ctl_SocksProxy, "Tunnelling the connection for port %d", port);
513
514 if (clientVC->socks_addr.type != SOCKS_ATYPE_IPV4) {
515 // We dont support other kinds of addresses for tunnelling
516 // if this is a hostname we could do host look up here
517 ret = mainEvent(NET_EVENT_OPEN_FAILED, nullptr);
518 } else {
519 uint32_t ip;
520 struct sockaddr_in addr;
521
522 memcpy(&ip, &p[4], 4);
523 ats_ip4_set(&addr, ip, htons(port));
524
525 // Ignore further reads
526 vc_handler = nullptr;
527
528 state = SERVER_TUNNEL;
529
530 // tunnel the connection.
531
532 NetVCOptions vc_options;
533 vc_options.socks_support = p[1];
534 vc_options.socks_version = version;
535
536 Action *action = netProcessor.connect_re(this, ats_ip_sa_cast(&addr), vc_options);
537 if (action != ACTION_RESULT_DONE) {
538 ink_release_assert(pending_action == nullptr);
539 pending_action = action;
540 }
541 }
542 }
543
544 return ret;
545}
546
547int
548SocksProxy::state_handing_over_http_request(int event, [[maybe_unused]] void *data)

Callers

nothing calls this directly

Calls 5

ats_ip4_setFunction · 0.85
ats_ip_sa_castFunction · 0.85
memcpyFunction · 0.50
cancelMethod · 0.45
connect_reMethod · 0.45

Tested by

no test coverage detected