Commit d0c1257c authored by vvaltman's avatar vvaltman

ext-server: timeout on inbound connections

parent b93e44b8
...@@ -66,19 +66,21 @@ ...@@ -66,19 +66,21 @@
*/ */
int tcp_rpcs_compact_parse_execute (connection_job_t c); int tcp_rpcs_compact_parse_execute (connection_job_t c);
int tcp_rpcs_ext_alarm (connection_job_t c);
int tcp_rpcs_ext_init_accepted (connection_job_t c);
conn_type_t ct_tcp_rpc_ext_server = { conn_type_t ct_tcp_rpc_ext_server = {
.magic = CONN_FUNC_MAGIC, .magic = CONN_FUNC_MAGIC,
.flags = C_RAWMSG, .flags = C_RAWMSG,
.title = "rpc_ext_server", .title = "rpc_ext_server",
.init_accepted = tcp_rpcs_init_accepted_nohs, .init_accepted = tcp_rpcs_ext_init_accepted,
.parse_execute = tcp_rpcs_compact_parse_execute, .parse_execute = tcp_rpcs_compact_parse_execute,
.close = tcp_rpcs_close_connection, .close = tcp_rpcs_close_connection,
.flush = tcp_rpc_flush, .flush = tcp_rpc_flush,
.write_packet = tcp_rpc_write_packet_compact, .write_packet = tcp_rpc_write_packet_compact,
.connected = server_failed, .connected = server_failed,
.wakeup = tcp_rpcs_wakeup, .wakeup = tcp_rpcs_wakeup,
.alarm = tcp_rpcs_alarm, .alarm = tcp_rpcs_ext_alarm,
.crypto_init = aes_crypto_ctr128_init, .crypto_init = aes_crypto_ctr128_init,
.crypto_free = aes_crypto_free, .crypto_free = aes_crypto_free,
.crypto_encrypt_output = cpu_tcp_aes_crypto_ctr128_encrypt_output, .crypto_encrypt_output = cpu_tcp_aes_crypto_ctr128_encrypt_output,
...@@ -980,12 +982,29 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info) ...@@ -980,12 +982,29 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
return c->type->parse_execute (C); return c->type->parse_execute (C);
} }
int tcp_rpcs_ext_alarm (connection_job_t C) {
struct tcp_rpc_data *D = TCP_RPC_DATA (C);
if (D->in_packet_num == -3) {
return proxy_connection (C, default_domain_info);
} else {
return 0;
}
}
int tcp_rpcs_ext_init_accepted (connection_job_t C) {
job_timer_insert (C, precise_now + 10);
return tcp_rpcs_init_accepted_nohs (C);
}
int tcp_rpcs_compact_parse_execute (connection_job_t C) { int tcp_rpcs_compact_parse_execute (connection_job_t C) {
#define RETURN_TLS_ERROR(info) \ #define RETURN_TLS_ERROR(info) \
return proxy_connection (C, info); return proxy_connection (C, info);
struct tcp_rpc_data *D = TCP_RPC_DATA (C); struct tcp_rpc_data *D = TCP_RPC_DATA (C);
if (D->crypto_flags & RPCF_COMPACT_OFF) { if (D->crypto_flags & RPCF_COMPACT_OFF) {
if (D->in_packet_num != -3) {
job_timer_remove (C);
}
return tcp_rpcs_parse_execute (C); return tcp_rpcs_parse_execute (C);
} }
...@@ -995,6 +1014,9 @@ int tcp_rpcs_compact_parse_execute (connection_job_t C) { ...@@ -995,6 +1014,9 @@ int tcp_rpcs_compact_parse_execute (connection_job_t C) {
vkprintf (4, "%s. in_total_bytes = %d\n", __func__, c->in.total_bytes); vkprintf (4, "%s. in_total_bytes = %d\n", __func__, c->in.total_bytes);
while (1) { while (1) {
if (D->in_packet_num != -3) {
job_timer_remove (C);
}
if (c->flags & C_ERROR) { if (c->flags & C_ERROR) {
return NEED_MORE_BYTES; return NEED_MORE_BYTES;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment