| 1 |
|
#include "Flatline.h" |
| 2 |
|
#include "Flatline_Server.h" |
| 3 |
|
#include <Windows.h> |
| 4 |
< |
|
| 4 |
> |
#include "PortForwardWrapper.h" |
| 5 |
|
//I hereby apologize for the uglyness of the below code. |
| 6 |
|
//It was never intended to be "final" code, much less shared with anyone |
| 7 |
|
|
| 374 |
|
break; |
| 375 |
|
} |
| 376 |
|
return true; |
| 377 |
< |
} |
| 377 |
> |
} |
| 378 |
> |
|
| 379 |
> |
|
| 380 |
> |
|
| 381 |
> |
bool FLrServer_Run() |
| 382 |
> |
{ |
| 383 |
> |
HRESULT ret; |
| 384 |
> |
PortMappingContainer_C PMC = |
| 385 |
> |
{ |
| 386 |
> |
"", |
| 387 |
> |
"27777", |
| 388 |
> |
"27777", |
| 389 |
> |
"UDP", |
| 390 |
> |
"", |
| 391 |
> |
"", |
| 392 |
> |
"Flatline!" |
| 393 |
> |
}; |
| 394 |
> |
// Get the local hostname |
| 395 |
> |
char szHostName[255]; |
| 396 |
> |
struct hostent *host_entry; |
| 397 |
> |
gethostname(szHostName, 255); |
| 398 |
> |
|
| 399 |
> |
host_entry=gethostbyname(szHostName); |
| 400 |
> |
|
| 401 |
> |
strcpy( PMC.InternalClient, inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list) ); |
| 402 |
> |
ret = uPnP_Forward( &PMC ); |
| 403 |
> |
if(!ret) |
| 404 |
> |
{ |
| 405 |
> |
DDrConsole_Print( "Port Forwarded" ); |
| 406 |
> |
} |
| 407 |
> |
else |
| 408 |
> |
{ |
| 409 |
> |
LPSTR Message; |
| 410 |
> |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, &ret,0,0,&Message,0,NULL); |
| 411 |
> |
DDrConsole_Print( Message ); |
| 412 |
> |
} |
| 413 |
> |
|
| 414 |
> |
DDrConsole_PrintF("Server started at %s...", inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list)); |
| 415 |
> |
return NetUDPServer_Listen(27777, FLrServer_PacketCallback); |
| 416 |
> |
} |