summaryrefslogtreecommitdiff
path: root/src/login_sql
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-27 17:02:59 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-27 17:02:59 +0000
commit12f444137f5000c76f4a46ac7689ae8edc30d626 (patch)
tree0ddb63b1ea62a0c748b37d322638fe464135f0f4 /src/login_sql
parent036bbfd9ae5a4a77031fb33a87264e58214c2ba0 (diff)
downloadhercules-12f444137f5000c76f4a46ac7689ae8edc30d626.tar.gz
hercules-12f444137f5000c76f4a46ac7689ae8edc30d626.tar.bz2
hercules-12f444137f5000c76f4a46ac7689ae8edc30d626.tar.xz
hercules-12f444137f5000c76f4a46ac7689ae8edc30d626.zip
- Cleaned up the IP sync code to...
- Use charif_sendallwos rather than manually altering the buffers of each server. - Use the id variable for identifying current char-server instead of scanning the connected servers for it (it's doing the same work twice) - Added config setting sync_ip_interval to specify how long to go before updating ip. Defaults to 0 (disabled) - Sending ip update packets will only be done when the ip changed now. - Removed dns_str variables, and now char_ip_str/login_ip_str/map_ip_str will hold the unresolved dns address (as these variables have no use otherwise) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7360 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/login_sql')
-rw-r--r--src/login_sql/login.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index 180ac9c08..7bc4d124e 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -85,6 +85,7 @@ int check_ip_flag = 1; // It's to check IP of a player between login-server and
int check_client_version = 0; //Client version check ON/OFF .. (sirius)
int client_version_to_connect = 20; //Client version needed to connect ..(sirius)
static int online_check=1; //When set to 1, login server rejects incoming players that are already registered as online. [Skotlex]
+static int ip_sync_interval = 0;
MYSQL mysql_handle;
@@ -194,14 +195,10 @@ int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data)
}
static int sync_ip_addresses(int tid, unsigned int tick, int id, int data){
- int i;
+ unsigned char buf[2];
ShowInfo("IP Sync in progress...\n");
- for(i = 0; i < MAX_SERVERS; i++) {
- if (server_fd[i] >= 0) {
- WFIFOW(server_fd[i], 0) = 0x2735;
- WFIFOSET(server_fd[i],2);
- }
- }
+ WBUFW(buf,0) = 0x2735;
+ charif_sendallwos(-1, buf, 2);
return 0;
}
@@ -1396,12 +1393,12 @@ int parse_fromchar(int fd){
break;
case 0x2736: // WAN IP update from char-server
- for(i = 0; i < MAX_SERVERS; i++) {
- if (server_fd[i] == fd) {
- ShowInfo("IP Sync (Server #%d %d.%d.%d.%d) successful.\n",i,(int)RFIFOB(fd,2),(int)RFIFOB(fd,3),(int)RFIFOB(fd,4),(int)RFIFOB(fd,5));
- server[i].ip = RFIFOL(fd,2);
- }
- }
+ if (RFIFOREST(fd) < 6)
+ return 0;
+ ShowInfo("Updated IP of Server #%d to %d.%d.%d.%d.\n",i,
+ (int)RFIFOB(fd,2),(int)RFIFOB(fd,3),
+ (int)RFIFOB(fd,4),(int)RFIFOB(fd,5));
+ server[id].ip = RFIFOL(fd,2);
RFIFOSKIP(fd,6);
break;
default:
@@ -2182,6 +2179,8 @@ int login_config_read(const char *cfgName){
use_dnsbl=atoi(w2);
} else if(strcmpi(w1,"dnsbl_servers")==0) { // [Zido]
strcpy(dnsbl_servs,w2);
+ } else if(strcmpi(w1,"ip_sync_interval")==0) {
+ ip_sync_interval = 1000*60*atoi(w2); //w2 comes in minutes.
}
}
fclose(fp);
@@ -2340,9 +2339,10 @@ int do_init(int argc,char **argv){
add_timer_func_list(online_data_cleanup, "online_data_cleanup");
add_timer_interval(gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000); // every 10 minutes cleanup online account db.
- add_timer_func_list(sync_ip_addresses, "sync_ip_addresses");
- add_timer_interval(gettick() + 600*1000, sync_ip_addresses, 0, 0, 600*1000); // Every 10 minutes to sync IPs.
-
+ if (ip_sync_interval) {
+ add_timer_func_list(sync_ip_addresses, "sync_ip_addresses");
+ add_timer_interval(gettick() + ip_sync_interval, sync_ip_addresses, 0, 0, ip_sync_interval);
+ }
if (console) {
set_defaultconsoleparse(parse_console);