0
0
mirror of https://github.com/hufrea/byedpi.git synced 2025-06-29 18:21:14 +00:00

Fix logging on Android

This commit is contained in:
ruti 2025-02-24 19:11:13 +03:00
parent 90d8cd7b7a
commit 02c1918621
3 changed files with 6 additions and 4 deletions

View File

@ -504,7 +504,7 @@ ssize_t desync(struct poolhd *pool,
ssize_t skip = val->pair->round_sent;
unsigned int part_skip = val->pair->part_sent;
if (!skip && params.debug) {
if (!skip && LOG_ENABLED) {
init_proto_info(buffer, *np, &info);
if (info.host_pos) {
@ -668,7 +668,7 @@ ssize_t desync_udp(int sfd, char *buffer,
{
struct desync_params *dp = &params.dp[dp_c];
if (params.debug) {
if (LOG_ENABLED) {
INIT_HEX_STR(buffer, (n > 16 ? 16 : n));
LOG(LOG_S, "bytes: %s (%zd)\n", HEX_STR, n);
}

View File

@ -63,6 +63,7 @@ static int unie(int e)
#define LOG_L ANDROID_LOG_VERBOSE
#define LOG(s, str, ...) \
__android_log_print(s, "proxy", str, ##__VA_ARGS__)
#define LOG_ENABLED 1
#else
#define LOG_E -1
#define LOG_S 1
@ -75,6 +76,7 @@ static int unie(int e)
va_end(args);
}
}
#define LOG_ENABLED (params.debug >= LOG_S)
#endif
#define INIT_ADDR_STR(dst) \

View File

@ -430,7 +430,7 @@ int create_conn(struct poolhd *pool,
close(sfd);
return -1;
}
if (params.debug) {
if (LOG_ENABLED) {
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));
@ -516,7 +516,7 @@ static int udp_associate(struct poolhd *pool,
close(cfd);
return -1;
}
if (params.debug) {
if (LOG_ENABLED) {
INIT_ADDR_STR((*dst));
LOG(LOG_S, "udp associate: fds=%d,%d,%d addr=%s:%d\n",
ufd, cfd, val->fd, ADDR_STR, ntohs(dst->in.sin_port));