Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1 resolved #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion STUNExternalIP.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down