diff --git a/STUNExternalIP.c b/STUNExternalIP.c index 41e372e..b1cc46a 100644 --- a/STUNExternalIP.c +++ b/STUNExternalIP.c @@ -249,6 +249,7 @@ int getPublicIPAddress(struct STUNServer server, char* address) struct STUNXORMappedIPv4Address* xorAddress = (struct STUNXORMappedIPv4Address*) pointer; + unsigned short nat_port = htons(xorAddress->port)^0x2112A442; unsigned int numAddress = htonl(xorAddress->address)^0x2112A442; // Parse the IP address @@ -257,7 +258,7 @@ int getPublicIPAddress(struct STUNServer server, char* address) (numAddress >> 16) & 0xFF, (numAddress >> 8) & 0xFF, numAddress & 0xFF); - + printf("%s: Public IP: %s and port: %d\n", server.address, address, nat_port); free(localAddress); free(hints); diff --git a/main.c b/main.c index be9f91b..52d6169 100644 --- a/main.c +++ b/main.c @@ -36,10 +36,6 @@ int main(int argc, const char * argv[]) { printf("%s: Failed. Error: %d\n", server.address, retVal); } - else - { - printf("%s: Public IP: %s\n", server.address, address); - } free(address); }