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

Method mainEvent

src/traffic_server/SocksProxy.cc:192–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192int
193SocksProxy::mainEvent(int event, void *data)
194{
195 int ret = EVENT_DONE;
196
197 recursion++;
198
199 switch (event) {
200 case VC_EVENT_READ_READY:
201 case VC_EVENT_READ_COMPLETE:
202 case VC_EVENT_WRITE_READY:
203 case VC_EVENT_WRITE_COMPLETE:
204 if (vc_handler) {
205 ret = (this->*vc_handler)(event, data);
206 } else {
207 Dbg(dbg_ctl_SocksProxy, "Ignore event = %s state = %d", get_vc_event_name(event), state);
208 }
209 break;
210
211 case NET_EVENT_OPEN: {
212 pending_action = nullptr;
213 ink_assert(state == SERVER_TUNNEL);
214 Dbg(dbg_ctl_SocksProxy, "open to Socks server succeeded");
215
216 NetVConnection *serverVC;
217 serverVC = (NetVConnection *)data;
218
219 OneWayTunnel *c_to_s = OneWayTunnel::OneWayTunnel_alloc();
220 OneWayTunnel *s_to_c = OneWayTunnel::OneWayTunnel_alloc();
221
222 c_to_s->init(clientVC, serverVC, nullptr, clientVIO, reader);
223 s_to_c->init(serverVC, clientVC, /*aCont = */ nullptr, 0 /*best guess */, c_to_s->mutex.get());
224
225 OneWayTunnel::SetupTwoWayTunnel(c_to_s, s_to_c);
226
227 buf = nullptr; // do not free buf. Tunnel will do that.
228 state = ALL_DONE;
229 break;
230 }
231
232 case NET_EVENT_OPEN_FAILED:
233 pending_action = nullptr;
234 vc_handler = &SocksProxy::state_send_socks_reply;
235 sendResp(false);
236 state = RESP_TO_CLIENT;
237 Dbg(dbg_ctl_SocksProxy, "open to Socks server failed");
238 break;
239
240 case EVENT_INTERVAL:
241 timeout = nullptr;
242 Dbg(dbg_ctl_SocksProxy, "SocksProxy timeout, state = %d", state);
243 state = SOCKS_ERROR;
244 break;
245
246 case VC_EVENT_EOS:
247 case VC_EVENT_ERROR:
248 case VC_EVENT_INACTIVITY_TIMEOUT:
249 case VC_EVENT_ACTIVE_TIMEOUT:

Callers

nothing calls this directly

Calls 5

get_vc_event_nameFunction · 0.85
initMethod · 0.45
getMethod · 0.45
cancelMethod · 0.45
do_io_closeMethod · 0.45

Tested by

no test coverage detected