debug: add NAT category logging to self-detect, init_resp nat update, and NAT_INFO receive paths
This commit is contained in:
1 parent
0738dcfd5a
commit
eea0ed0a48
2 files changed
+17
-5
No files matched your search
+13
-2
@@ -1295,6 +1295,10 @@ static void send_init_response(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pk
|
||||
}
|
||||
}
|
||||
/* Self-detection: if my IP is non-local, I'm on a public IP */
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NAT, "self-detect check: socket=%s type=%d nat_type=%d if_addr=%s local_addr=%s",
|
||||
e_sock->name, e_sock->type, e_sock->nat_type,
|
||||
sockaddr_storage_to_str(&e_sock->interface_addr).str,
|
||||
sockaddr_storage_to_str(&e_sock->local_addr).str);
|
||||
if (e_sock->nat_type != NAT_VERIFIED_DIRECT && e_sock->interface_addr.ss_family == AF_INET) {
|
||||
uint32_t my_ip = ((struct sockaddr_in*)&e_sock->interface_addr)->sin_addr.s_addr;
|
||||
if (my_ip != 0 && !is_local_subnet(my_ip)) {
|
||||
@@ -1317,8 +1321,9 @@ static void send_init_response(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pk
|
||||
}
|
||||
}
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "Self-detected PUBLIC IP: %s on socket %s (id=%d)",
|
||||
ip_to_str(&my_ip, AF_INET).str, e_sock->name, e_sock->sock_id);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NAT, "Self-detected PUBLIC: socket=%s ip=%s port=%u sock_id=%d",
|
||||
e_sock->name, ip_to_str(&my_ip, AF_INET).str,
|
||||
ntohs(nat_sin->sin_port), e_sock->sock_id);
|
||||
}
|
||||
}
|
||||
pkt->noencrypt_len=0;
|
||||
@@ -1423,11 +1428,17 @@ static int handle_init_response_client(struct ETCP_SOCKET* e_sock, struct ETCP_D
|
||||
|
||||
// Update socket NAT address (only if not already verified)
|
||||
{
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NAT, "init_resp nat: socket=%s nat_type=%d new_ip=%s new_port=%u",
|
||||
e_sock->name, e_sock->nat_type,
|
||||
ip_to_str(&new_nat_ip, AF_INET).str, new_nat_port);
|
||||
if (e_sock->nat_type < NAT_VERIFIED_UNKNOWN) {
|
||||
struct sockaddr_in* sin = (struct sockaddr_in*)&e_sock->nat_addr;
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_addr.s_addr = new_nat_ip;
|
||||
sin->sin_port = htons(new_nat_port);
|
||||
} else {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NAT, "init_resp nat update SKIPPED (already verified): socket=%s nat_type=%d",
|
||||
e_sock->name, e_sock->nat_type);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+4
-3
@@ -1080,10 +1080,11 @@ static void route_bgp_handle_nat_info(struct ROUTE_BGP* bgp, struct ETCP_CONN* f
|
||||
struct ETCP_LINK* l = from_conn->links;
|
||||
while (l) { l->nat_type = info->nat_type; l = l->next; }
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_BGP, "NAT_INFO from %s: socket_id=%u type=%s ip=%s port=%u",
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NAT, "NAT_INFO from %s: sock_id=%u type=%s ip=%s port=%u matched_sock=%s old_nat_type=%d",
|
||||
from_conn->log_name, socket_id,
|
||||
info->nat_type == NAT_TYPE_EIM ? "EIM" : "STRICT",
|
||||
ip_to_str(info->nat_ip, AF_INET).str, (unsigned)nat_port);
|
||||
info->nat_type == NAT_TYPE_EIM ? "EIM" : info->nat_type == NAT_TYPE_DIRECT ? "DIRECT" : "STRICT",
|
||||
ip_to_str(info->nat_ip, AF_INET).str, (unsigned)nat_port,
|
||||
es ? es->name : "none", es ? (int)es->nat_type : -1);
|
||||
}
|
||||
|
||||
static void route_bgp_handle_nat_check_req(struct ROUTE_BGP* bgp, struct ETCP_CONN* from_conn, const uint8_t* data, size_t len) {// поиск нужного линка и запуск nat_check
|
||||
|
||||
Reference in new issue
Block a user