|
|
|
@ -1362,7 +1362,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { |
|
|
|
uint16_t port = ntohs(sin->sin_port); |
|
|
|
uint16_t port = ntohs(sin->sin_port); |
|
|
|
ack_repl_hdr->peer_port[0] = port >> 8; |
|
|
|
ack_repl_hdr->peer_port[0] = port >> 8; |
|
|
|
ack_repl_hdr->peer_port[1] = port & 0xFF; |
|
|
|
ack_repl_hdr->peer_port[1] = port & 0xFF; |
|
|
|
link->nat_ip = ntohl(sin->sin_addr.s_addr); |
|
|
|
link->nat_ip = sin->sin_addr.s_addr; |
|
|
|
link->nat_port = port; |
|
|
|
link->nat_port = port; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// For IPv6, set to 0 (not supported for NAT traversal)
|
|
|
|
// For IPv6, set to 0 (not supported for NAT traversal)
|
|
|
|
@ -1453,8 +1453,8 @@ process_decrypted: |
|
|
|
|
|
|
|
|
|
|
|
// Parse NAT IP:port from response (new format includes 4+2 bytes)
|
|
|
|
// Parse NAT IP:port from response (new format includes 4+2 bytes)
|
|
|
|
if (pkt_len >= 19) { |
|
|
|
if (pkt_len >= 19) { |
|
|
|
uint32_t new_nat_ip = (pkt->data[offset] << 24) | (pkt->data[offset+1] << 16) |
|
|
|
|
uint32_t new_nat_ip = (pkt->data[offset+3] << 24) | (pkt->data[offset+2] << 16) |
|
|
|
|
(pkt->data[offset+2] << 8) | pkt->data[offset+3]; |
|
|
|
(pkt->data[offset+1] << 8) | pkt->data[offset+0]; |
|
|
|
offset += 4; |
|
|
|
offset += 4; |
|
|
|
uint16_t new_nat_port = (pkt->data[offset] << 8) | pkt->data[offset+1]; |
|
|
|
uint16_t new_nat_port = (pkt->data[offset] << 8) | pkt->data[offset+1]; |
|
|
|
offset += 2; |
|
|
|
offset += 2; |
|
|
|
@ -1471,15 +1471,15 @@ process_decrypted: |
|
|
|
} else if (link->nat_ip != new_nat_ip || link->nat_port != new_nat_port) { |
|
|
|
} else if (link->nat_ip != new_nat_ip || link->nat_port != new_nat_port) { |
|
|
|
// NAT address changed
|
|
|
|
// NAT address changed
|
|
|
|
struct in_addr old_addr, new_addr; |
|
|
|
struct in_addr old_addr, new_addr; |
|
|
|
old_addr.s_addr = htonl(link->nat_ip); |
|
|
|
old_addr.s_addr = link->nat_ip; |
|
|
|
new_addr.s_addr = htonl(new_nat_ip); |
|
|
|
new_addr.s_addr = new_nat_ip; |
|
|
|
|
|
|
|
|
|
|
|
link->nat_ip = new_nat_ip; |
|
|
|
link->nat_ip = new_nat_ip; |
|
|
|
link->nat_port = new_nat_port; |
|
|
|
link->nat_port = new_nat_port; |
|
|
|
link->nat_changes_count++; |
|
|
|
link->nat_changes_count++; |
|
|
|
|
|
|
|
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] NAT address changed: %s:%u -> %s:%u (change #%u)",
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] NAT address changed: %s:%u -> %s:%u (change #%u)",
|
|
|
|
link->etcp->log_name, ip_to_str(&old_addr, AF_INET).str, link->nat_port, ip_to_str(&new_addr, AF_INET).str, new_nat_port,
|
|
|
|
link->etcp->log_name, ip_to_str(&old_addr.s_addr, AF_INET).str, link->nat_port, ip_to_str(&new_addr.s_addr, AF_INET).str, new_nat_port,
|
|
|
|
link->nat_changes_count); |
|
|
|
link->nat_changes_count); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|