forked from 0xFireWolf/STUNExternalIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
48 lines (39 loc) · 1.32 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// main.c
// STUNExternalIP
//
// Created by FireWolf on 2017-02-24.
// Copyright © 2017 FireWolf. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "STUNExternalIP.h"
int main(int argc, const char * argv[])
{
struct STUNServer servers[14] = {
{"stun.l.google.com" , 19302}, {"stun.l.google.com" , 19305},
{"stun1.l.google.com", 19302}, {"stun1.l.google.com", 19305},
{"stun2.l.google.com", 19302}, {"stun2.l.google.com", 19305},
{"stun3.l.google.com", 19302}, {"stun3.l.google.com", 19305},
{"stun4.l.google.com", 19302}, {"stun4.l.google.com", 19305},
{"stun.wtfismyip.com", 3478 }, {"stun.bcs2005.net" , 3478 },
{"numb.viagenie.ca" , 3478 }, {"173.194.202.127" , 19302}};
for (int index = 0; index < 14; index++)
{
char* address = malloc(sizeof(char) * 100);
bzero(address, 100);
struct STUNServer server = servers[index];
int retVal = getPublicIPAddress(server, address);
if (retVal != 0)
{
printf("%s: Failed. Error: %d\n", server.address, retVal);
}
else
{
printf("%s: Public IP: %s\n", server.address, address);
}
free(address);
}
return 0;
}