2009-10-30 00:46:36 +00:00
|
|
|
//this file use miniupnp
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2019-04-24 23:56:38 +02:00
|
|
|
#include <upnp/upnphandler.h>
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
int id = argc % 3;
|
|
|
|
|
|
|
|
/*********
|
|
|
|
char *fhash1 = "3509426505463458576487";
|
|
|
|
char *hash2 = "1549879882341985914515";
|
|
|
|
char *hash3 = "8743598543269526505434";
|
|
|
|
|
|
|
|
int port1 = 8754;
|
|
|
|
int port2 = 2355;
|
|
|
|
int port3 = 6621;
|
|
|
|
**********/
|
|
|
|
|
|
|
|
std::cerr << "Starting dhttest Id: " << id << std::endl;
|
|
|
|
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
|
|
#ifndef WINDOWS_SYS
|
|
|
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
|
|
#else
|
|
|
|
// Windows Networking Init.
|
|
|
|
WORD wVerReq = MAKEWORD(2,2);
|
|
|
|
WSADATA wsaData;
|
|
|
|
|
|
|
|
if (0 != WSAStartup(wVerReq, &wsaData))
|
|
|
|
{
|
|
|
|
std::cerr << "Failed to Startup Windows Networking";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "Started Windows Networking";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
|
|
|
|
|
|
#ifdef PTW32_STATIC_LIB
|
|
|
|
pthread_win32_process_attach_np();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
upnphandler upnp;
|
|
|
|
|
2008-01-25 07:25:05 +00:00
|
|
|
upnp.setInternalPort(12122);
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
for(int i = 0; 1; i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
|
|
#ifndef WINDOWS_SYS
|
|
|
|
sleep(1);
|
|
|
|
#else
|
|
|
|
|
|
|
|
Sleep(1000);
|
|
|
|
#endif
|
|
|
|
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
|
|
|
|
2008-04-09 12:54:15 +00:00
|
|
|
if (i % 120 == 10)
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
|
|
|
/* start up a forward */
|
2008-08-16 15:02:24 +00:00
|
|
|
upnp.enable(true);
|
2007-11-15 03:18:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-04-09 12:54:15 +00:00
|
|
|
if (i % 120 == 60)
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
|
|
|
/* shutdown a forward */
|
2008-08-16 15:02:24 +00:00
|
|
|
upnp.restart();
|
2007-11-15 03:18:48 +00:00
|
|
|
}
|
|
|
|
|
2008-04-09 12:54:15 +00:00
|
|
|
if (i % 120 == 100)
|
|
|
|
{
|
|
|
|
/* shutdown a forward */
|
2008-08-16 15:02:24 +00:00
|
|
|
upnp.shutdown();
|
2008-04-09 12:54:15 +00:00
|
|
|
}
|
2007-11-15 03:18:48 +00:00
|
|
|
|
2008-01-25 07:25:05 +00:00
|
|
|
}
|
2007-11-15 03:18:48 +00:00
|
|
|
}
|
|
|
|
|