summaryrefslogtreecommitdiff
path: root/src/common/socket.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-05 14:32:04 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-05 14:32:04 +0000
commit573c40f53e1d0fe29c72117fc4ca2d931b274d8c (patch)
tree1c8afefbc96da8878fc94bfc3edd32486b80875f /src/common/socket.c
parent6acbd82fb5b77315853f42a9a31b7439a7e58bb9 (diff)
downloadhercules-573c40f53e1d0fe29c72117fc4ca2d931b274d8c.tar.gz
hercules-573c40f53e1d0fe29c72117fc4ca2d931b274d8c.tar.bz2
hercules-573c40f53e1d0fe29c72117fc4ca2d931b274d8c.tar.xz
hercules-573c40f53e1d0fe29c72117fc4ca2d931b274d8c.zip
* Added SERVER_TYPE to core for future plugins support
* Added support for the UPNP plugin to release port mappings and re-close firewall ports on shutdown * Updated showmsg git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1409 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 2daf00764..64f660a11 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -54,7 +54,10 @@ int (*upnp_init)();
int (*upnp_final)();
int (*firewall_addport)(char *desc, int port);
int (*upnp_addport)(char *desc, char *ip, int port);
-extern char server_type[24];
+extern char *argp;
+
+int release_mappings = 1;
+int close_ports = 1;
#else
#error This doesnt work with non-Windows yet
#endif
@@ -327,10 +330,10 @@ int make_listen_bind(long ip,int port)
char buf[16];
sprintf(buf, "%d.%d.%d.%d", natip[0], natip[1], natip[2], natip[3]);
//printf("natip=%d.%d.%d.%d\n", natip[0], natip[1], natip[2], natip[3]);
- if (firewall_addport(server_type, port))
+ if (firewall_addport(argp, port))
printf ("Firewall port %d successfully opened\n", port);
if (natip[0] == 192 && natip[1] == 168) {
- if (upnp_addport(server_type, natip, port))
+ if (upnp_addport(argp, natip, port))
printf ("Upnp mappings successfull\n");
else printf ("Upnp mapping failed\n");
}
@@ -845,6 +848,20 @@ int socket_config_read(const char *cfgName) {
else if(strcmpi(w2,"no")==0)
access_debug = 0;
else access_debug = atoi(w2);
+ #ifdef UPNP
+ } else if(!strcmpi(w1,"release_mappings")){
+ if(strcmpi(w2,"yes")==0)
+ release_mappings = 1;
+ else if(strcmpi(w2,"no")==0)
+ release_mappings = 0;
+ else release_mappings = atoi(w2);
+ } else if(!strcmpi(w1,"close_ports")){
+ if(strcmpi(w2,"yes")==0)
+ close_ports = 1;
+ else if(strcmpi(w2,"no")==0)
+ close_ports = 0;
+ else close_ports = atoi(w2);
+ #endif
} else if (strcmpi(w1, "import") == 0)
socket_config_read(w2);
}
@@ -957,6 +974,9 @@ int Net_Init(void)
// not implemented yet ^^;
void do_init_upnp(void)
{
+ int *_release_mappings;
+ int *_close_ports;
+
upnp_dll = DLL_OPEN ("upnp.dll");
if (!upnp_dll) {
printf ("Cannot open upnp.dll: %s\n", dlerror());
@@ -972,6 +992,14 @@ void do_init_upnp(void)
upnp_dll = NULL;
return;
}
+
+ DLL_SYM (_release_mappings, upnp_dll, "release_mappings");
+ DLL_SYM (_close_ports, upnp_dll, "close_ports");
+ if (release_mappings && _release_mappings)
+ *_release_mappings = release_mappings;
+ if (close_ports && _close_ports)
+ *_close_ports = close_ports;
+
if (upnp_init() == 0) {
printf ("Error initialising upnp.dll, unloading...\n");
DLL_CLOSE (upnp_dll);