Commit 04282c7e authored by levlam's avatar levlam

Improve logging.Z

parent 6d1ac2da
...@@ -2094,7 +2094,7 @@ void mtfront_pre_loop (void) { ...@@ -2094,7 +2094,7 @@ void mtfront_pre_loop (void) {
assert (LC); assert (LC);
CONN_INFO(LC)->window_clamp = window_clamp; CONN_INFO(LC)->window_clamp = window_clamp;
if (setsockopt (http_sfd[i], IPPROTO_TCP, TCP_WINDOW_CLAMP, &window_clamp, 4) < 0) { if (setsockopt (http_sfd[i], IPPROTO_TCP, TCP_WINDOW_CLAMP, &window_clamp, 4) < 0) {
vkprintf (0, "error while setting window size for socket %d to %d: %m\n", http_sfd[i], window_clamp); vkprintf (0, "error while setting window size for socket #%d to %d: %m\n", http_sfd[i], window_clamp);
} }
} }
// create_all_outbound_connections (); // create_all_outbound_connections ();
......
...@@ -602,7 +602,7 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening ...@@ -602,7 +602,7 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
unsigned flags; unsigned flags;
if ((flags = fcntl (cfd, F_GETFL, 0) < 0) || fcntl (cfd, F_SETFL, flags | O_NONBLOCK) < 0) { if ((flags = fcntl (cfd, F_GETFL, 0) < 0) || fcntl (cfd, F_SETFL, flags | O_NONBLOCK) < 0) {
kprintf ("cannot set O_NONBLOCK on accepted socket %d: %m\n", cfd); kprintf ("cannot set O_NONBLOCK on accepted socket #%d: %m\n", cfd);
MODULE_STAT->accept_nonblock_set_failed ++; MODULE_STAT->accept_nonblock_set_failed ++;
close (cfd); close (cfd);
return NULL; return NULL;
...@@ -697,9 +697,9 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening ...@@ -697,9 +697,9 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
//c->out_packet_queue = alloc_mp_queue_w (); //c->out_packet_queue = alloc_mp_queue_w ();
if (basic_type == ct_outbound) { if (basic_type == ct_outbound) {
vkprintf (1, "New connection %s:%d -> %s:%d\n", show_our_ip (C), c->our_port, show_remote_ip (C), c->remote_port); vkprintf (1, "New outbound connection #%d %s:%d -> %s:%d\n", c->fd, show_our_ip (C), c->our_port, show_remote_ip (C), c->remote_port);
} else { } else {
vkprintf (1, "New connection %s:%d -> %s:%d\n", show_remote_ip (C), c->remote_port, show_our_ip (C), c->our_port); vkprintf (1, "New inbound connection #%d %s:%d -> %s:%d\n", c->fd, show_remote_ip (C), c->remote_port, show_our_ip (C), c->our_port);
} }
...@@ -750,13 +750,13 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening ...@@ -750,13 +750,13 @@ connection_job_t alloc_new_connection (int cfd, conn_target_job_t CTJ, listening
} }
if (c->window_clamp) { if (c->window_clamp) {
if (setsockopt (cfd, IPPROTO_TCP, TCP_WINDOW_CLAMP, &c->window_clamp, 4) < 0) { if (setsockopt (cfd, IPPROTO_TCP, TCP_WINDOW_CLAMP, &c->window_clamp, 4) < 0) {
vkprintf (0, "error while setting window size for socket %d to %d: %m\n", cfd, c->window_clamp); vkprintf (0, "error while setting window size for socket #%d to %d: %m\n", cfd, c->window_clamp);
} else { } else {
int t1 = -1, t2 = -1; int t1 = -1, t2 = -1;
socklen_t s1 = 4, s2 = 4; socklen_t s1 = 4, s2 = 4;
getsockopt (cfd, IPPROTO_TCP, TCP_WINDOW_CLAMP, &t1, &s1); getsockopt (cfd, IPPROTO_TCP, TCP_WINDOW_CLAMP, &t1, &s1);
getsockopt (cfd, SOL_SOCKET, SO_RCVBUF, &t2, &s2); getsockopt (cfd, SOL_SOCKET, SO_RCVBUF, &t2, &s2);
vkprintf (2, "window clamp for socket %d is %d, receive buffer is %d\n", cfd, t1, t2); vkprintf (2, "window clamp for socket #%d is %d, receive buffer is %d\n", cfd, t1, t2);
} }
} }
...@@ -1132,7 +1132,7 @@ int net_server_socket_read_write_gateway (int fd, void *data, event_t *ev) /* {{ ...@@ -1132,7 +1132,7 @@ int net_server_socket_read_write_gateway (int fd, void *data, event_t *ev) /* {{
return EVA_REMOVE; return EVA_REMOVE;
} }
if (ev->epoll_ready & (EPOLLHUP | EPOLLERR | EPOLLRDHUP | EPOLLPRI)) { if (ev->epoll_ready & (EPOLLHUP | EPOLLERR | EPOLLRDHUP | EPOLLPRI)) {
vkprintf (!(ev->epoll_ready & EPOLLPRI), "socket %d: disconnected (epoll_ready=%02x), cleaning\n", c->fd, ev->epoll_ready); vkprintf (!(ev->epoll_ready & EPOLLPRI), "socket #%d: disconnected (epoll_ready=%02x), cleaning\n", c->fd, ev->epoll_ready);
job_signal (JOB_REF_CREATE_PASS (C), JS_ABORT); job_signal (JOB_REF_CREATE_PASS (C), JS_ABORT);
return EVA_REMOVE; return EVA_REMOVE;
...@@ -1720,12 +1720,14 @@ int create_new_connections (conn_target_job_t CTJ) /* {{{ */ { ...@@ -1720,12 +1720,14 @@ int create_new_connections (conn_target_job_t CTJ) /* {{{ */ {
} }
while (CT->outbound_connections < need_c) { while (CT->outbound_connections < need_c) {
int cfd = -1;
if (CT->target.s_addr) { if (CT->target.s_addr) {
vkprintf (1, "Creating NEW connection to %s:%d\n", inet_ntoa (CT->target), CT->port); cfd = client_socket (CT->target.s_addr, CT->port, 0);
vkprintf (1, "Created NEW connection #%d to %s:%d\n", cfd, inet_ntoa (CT->target), CT->port);
} else { } else {
vkprintf (1, "Creating NEW ipv6 connection to [%s]:%d\n", show_ipv6 (CT->target_ipv6), CT->port); cfd = client_socket_ipv6 (CT->target_ipv6, CT->port, SM_IPV6);
vkprintf (1, "Created NEW ipv6 connection #%d to [%s]:%d\n", cfd, show_ipv6 (CT->target_ipv6), CT->port);
} }
int cfd = CT->target.s_addr ? client_socket (CT->target.s_addr, CT->port, 0) : client_socket_ipv6 (CT->target_ipv6, CT->port, SM_IPV6);
if (cfd < 0) { if (cfd < 0) {
if (CT->target.s_addr) { if (CT->target.s_addr) {
vkprintf (1, "error connecting to %s:%d: %m\n", inet_ntoa (CT->target), CT->port); vkprintf (1, "error connecting to %s:%d: %m\n", inet_ntoa (CT->target), CT->port);
......
...@@ -103,7 +103,8 @@ conn_type_t ct_proxy_pass = { ...@@ -103,7 +103,8 @@ conn_type_t ct_proxy_pass = {
}; };
int tcp_proxy_pass_connected (connection_job_t C) { int tcp_proxy_pass_connected (connection_job_t C) {
vkprintf (1, "proxy pass connected'n"); struct connection_info *c = CONN_INFO(C);
vkprintf (1, "proxy pass connected #%d %s:%d -> %s:%d\n", c->fd, show_our_ip (C), c->our_port, show_remote_ip (C), c->remote_port);
return 0; return 0;
} }
...@@ -119,15 +120,15 @@ int tcp_proxy_pass_parse_execute (connection_job_t C) { ...@@ -119,15 +120,15 @@ int tcp_proxy_pass_parse_execute (connection_job_t C) {
struct raw_message *r = malloc (sizeof (*r)); struct raw_message *r = malloc (sizeof (*r));
rwm_move (r, &c->in); rwm_move (r, &c->in);
rwm_init (&c->in, 0); rwm_init (&c->in, 0);
vkprintf (3, "proxying %d bytes to %s\n", r->total_bytes, show_remote_ip (E)); vkprintf (3, "proxying %d bytes to %s:%d\n", r->total_bytes, show_remote_ip (E), e->remote_port);
mpq_push_w (e->out_queue, PTR_MOVE(r), 0); mpq_push_w (e->out_queue, PTR_MOVE(r), 0);
job_signal (JOB_REF_PASS (E), JS_RUN); job_signal (JOB_REF_PASS (E), JS_RUN);
return 0; return 0;
} }
int tcp_proxy_pass_close (connection_job_t C, int who) { int tcp_proxy_pass_close (connection_job_t C, int who) {
vkprintf (1, "closing proxy pass conn\n");
struct connection_info *c = CONN_INFO(C); struct connection_info *c = CONN_INFO(C);
vkprintf (1, "closing proxy pass connection #%d %s:%d -> %s:%d\n", c->fd, show_our_ip (C), c->our_port, show_remote_ip (C), c->remote_port);
if (c->extra) { if (c->extra) {
job_t E = PTR_MOVE (c->extra); job_t E = PTR_MOVE (c->extra);
fail_connection (E, -23); fail_connection (E, -23);
...@@ -151,19 +152,6 @@ void tcp_rpcs_set_ext_secret (unsigned char secret[16]) { ...@@ -151,19 +152,6 @@ void tcp_rpcs_set_ext_secret (unsigned char secret[16]) {
memcpy (ext_secret[ext_secret_cnt ++], secret, 16); memcpy (ext_secret[ext_secret_cnt ++], secret, 16);
} }
/*
struct tcp_rpc_server_functions default_tcp_rpc_ext_server = {
.execute = tcp_rpcs_default_execute,
.check_ready = server_check_ready,
.flush_packet = tcp_rpc_flush_packet,
.rpc_wakeup = tcp_rpcs_do_wakeup,
.rpc_alarm = tcp_rpcs_do_wakeup,
.rpc_check_perm = tcp_rpcs_default_check_perm,
.rpc_init_crypto = tcp_rpcs_init_crypto,
.rpc_ready = server_noop,
};
*/
static int allow_only_tls; static int allow_only_tls;
struct domain_info { struct domain_info {
...@@ -861,7 +849,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info) ...@@ -861,7 +849,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
return 0; return 0;
} }
int port = c->remote_port == 80 ? 80 : 443; int port = c->our_port == 80 ? 80 : 443;
int cfd = -1; int cfd = -1;
if (info->target.s_addr) { if (info->target.s_addr) {
...@@ -871,7 +859,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info) ...@@ -871,7 +859,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
} }
if (cfd < 0) { if (cfd < 0) {
kprintf ("failed to create proxy pass conn: %d (%m)", errno); kprintf ("failed to create proxy pass connection: %d (%m)", errno);
fail_connection (C, -27); fail_connection (C, -27);
return 0; return 0;
} }
...@@ -881,7 +869,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info) ...@@ -881,7 +869,7 @@ static int proxy_connection (connection_job_t C, const struct domain_info *info)
job_t EJ = alloc_new_connection (cfd, NULL, NULL, ct_outbound, &ct_proxy_pass, C, ntohl (*(int *)&info->target.s_addr), (void *)info->target_ipv6, port); job_t EJ = alloc_new_connection (cfd, NULL, NULL, ct_outbound, &ct_proxy_pass, C, ntohl (*(int *)&info->target.s_addr), (void *)info->target_ipv6, port);
if (!EJ) { if (!EJ) {
kprintf ("failed to create proxy pass conn (2)"); kprintf ("failed to create proxy pass connection (2)");
job_decref_f (C); job_decref_f (C);
fail_connection (C, -37); fail_connection (C, -37);
return 0; return 0;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "net/net-connections.h" #include "net/net-connections.h"
extern conn_type_t ct_tcp_rpc_ext_server; extern conn_type_t ct_tcp_rpc_ext_server;
// extern struct tcp_rpc_server_functions default_tcp_rpc_server;
int tcp_rpcs_compact_parse_execute (connection_job_t c); int tcp_rpcs_compact_parse_execute (connection_job_t c);
......
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