More details in logs

This commit is contained in:
ruti 2024-11-09 16:20:13 +03:00
parent 75671fa11c
commit 38f4fe169e
3 changed files with 18 additions and 11 deletions

View File

@ -446,6 +446,14 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
len, host, host - buffer);
host_pos = host - buffer;
}
else {
size_t s = n > 16 ? 16 : n - (n % 4);
char hex[s * 2 + 1], *b = buffer;
for (size_t i = 0; i < s; i += 4)
snprintf(hex + i * 2, sizeof(hex) - i * 2,
"%02x%02x%02x%02x", b[i],b[i+1],b[i+2],b[i+3]);
LOG(LOG_S, "bytes: %s (%zd)\n", s ? hex : "", n);
}
}
// modify packet
if (type == IS_HTTP && dp.mod_http) {

View File

@ -454,7 +454,7 @@ ssize_t tcp_send_hook(struct eval *remote,
skip = 1;
}
else {
LOG((m ? LOG_S : LOG_L), "desync TCP, m=%d, r=%d\n", m, r);
LOG(LOG_S, "desync TCP: group=%d, round=%d, fd=%d\n", m, r, remote->fd);
ssize_t offset = remote->pair->round_sent;
if (!offset && remote->round_count) offset = -1;
@ -541,7 +541,7 @@ ssize_t udp_hook(struct eval *val,
if (!check_round(params.dp[m].rounds, r)) {
return send(val->fd, buffer, n, 0);
}
LOG(LOG_S, "desync UDP, m=%d, r=%d\n", m, r);
LOG(LOG_S, "desync UDP: group=%d, round=%d, fd=%d\n", m, r, val->fd);
return desync_udp(val->fd, buffer, bfsize, n, &dst->sa, m);
}

17
proxy.c
View File

@ -407,6 +407,11 @@ int create_conn(struct poolhd *pool,
close(sfd);
return -1;
}
if (params.debug) {
INIT_ADDR_STR((*dst));
LOG(LOG_S, "new conn: fd=%d, pair=%d, addr=%s:%d\n",
sfd, val->fd, ADDR_STR, ntohs(dst->in.sin_port));
}
int status = connect(sfd, &addr.sa, SA_SIZE(&addr));
if (status == 0 && params.tfo) {
LOG(LOG_S, "TFO supported!\n");
@ -435,12 +440,6 @@ int create_conn(struct poolhd *pool,
#endif
pair->flag = FLAG_CONN;
//val->type = EV_IGNORE;
if (params.debug) {
INIT_ADDR_STR((*dst));
LOG(LOG_S, "new conn: fd=%d, addr=%s:%d\n",
val->pair->fd, ADDR_STR, ntohs(dst->in.sin_port));
}
return 0;
}
@ -496,8 +495,8 @@ int udp_associate(struct poolhd *pool,
}
if (params.debug) {
INIT_ADDR_STR((*dst));
LOG(LOG_S, "udp associate: fds=%d,%d addr=%s:%d\n",
ufd, cfd, ADDR_STR, ntohs(dst->in.sin_port));
LOG(LOG_S, "udp associate: fds=%d,%d,%d addr=%s:%d\n",
ufd, cfd, val->fd, ADDR_STR, ntohs(dst->in.sin_port));
}
val->type = EV_IGNORE;
val->pair = client;
@ -673,7 +672,7 @@ int on_tunnel(struct poolhd *pool, struct eval *val,
return -1;
}
if (sn < n) {
LOG(LOG_S, "send: %zd != %zd (fd: %d)\n", sn, n, pair->fd);
LOG(LOG_S, "send: %zd != %zd (fd=%d)\n", sn, n, pair->fd);
assert(!(val->buff.size || val->buff.offset));
val->buff.size = n - sn;