Explorar el Código

Finished DNSBL, Although untested, It's simple code and should work fine.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6543 54d463be-8e91-2dee-dedb-b68131a5f0ec
Zido hace 19 años
padre
commit
b467a6bfbc
Se han modificado 4 ficheros con 39 adiciones y 35 borrados
  1. 3 0
      Changelog-Trunk.txt
  2. 3 0
      conf-tmpl/login_athena.conf
  3. 17 18
      src/login/login.c
  4. 16 17
      src/login_sql/login.c

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/05/10
+	* Users are now able to use their own dnsbl servers (login_athena) [Zido]
+
 2006/05/09
 	* Rewrote/cleaned up trade.c for a more clean trading implementation.
 	  [Skotlex]

+ 3 - 0
conf-tmpl/login_athena.conf

@@ -182,4 +182,7 @@ dynamic_account_ban_class: 0
 //DNS Blacklist Blocking (on: 1, off: 0)
 use_dnsbl: 0
 
+//DNS Servers (seperated by a comma)
+dnsbl_servers: dnsbl.deltaanime.net
+
 import: conf/import/login_conf.txt

+ 17 - 18
src/login/login.c

@@ -69,7 +69,8 @@ struct _subnet {
 
 int subnet_count = 0;
 
-int use_dnsbl=0;
+int use_dnsbl=0; // [Zido]
+char dnsbl_servs[1024]; // [Zido]
 
 char account_filename[1024] = "save/account.txt";
 char GM_account_filename[1024] = "conf/GM_account.txt";
@@ -1143,6 +1144,7 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) {
 // Check/authentification of a connection
 //---------------------------------------
 int mmo_auth(struct mmo_account* account, int fd) {
+	char *dnsbl_serv;
 	unsigned int i;
 	time_t raw_time;
 	char tmpstr[256];
@@ -1163,27 +1165,22 @@ int mmo_auth(struct mmo_account* account, int fd) {
 	// Start DNS Blacklist check [Zido]
 	if(use_dnsbl) {
 		sprintf(r_ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]);
-		
-		sprintf(ip_dnsbl,"%s.opm.blitzed.org",r_ip);
-		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
-			return 3;
-		}
-		sprintf(ip_dnsbl,"%s.sbl.deltaanime.net",r_ip);
-		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
-			return 3;
-		}
-		sprintf(ip_dnsbl,"%s.dnsbl.njabl.org",r_ip);
+
+		dnsbl_serv=strtok(dnsbl_servs,",");
+		sprintf(ip_dnsbl,"%s.%s",r_ip,dnsbl_serv);
 		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",ip);
 			return 3;
 		}
-		sprintf(ip_dnsbl,"%s.sbl-xbl.spamhaus.org",r_ip);
-		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
-			return 3;
+
+		while((dnsbl_serv=strtok(dnsbl_servs,","))!=NULL) {
+			sprintf(ip_dnsbl,"%s.%s",r_ip,dnsbl_serv);
+			if(gethostbyname(ip_dnsbl)!=NULL) {
+				ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",ip);
+				return 3;
+			}
 		}
+
 	}
 	// End DNS Blacklist check [Zido]
 
@@ -3774,6 +3771,8 @@ int login_config_read(const char *cfgName) {
 				login_config_read(w2);
 			} else if(strcmpi(w1,"use_dnsbl")==0) { // [Zido]
 				use_dnsbl=atoi(w2);
+			} else if(strcmpi(w1,"dnsbl_servers")==0) { // [Zido]
+				strcpy(dnsbl_servs,w2);
 			}
 		}
 	}

+ 16 - 17
src/login_sql/login.c

@@ -65,6 +65,7 @@ void Gettimeofday(struct timeval *timenow)
 // global variable
 //-----------------------------------------------------
 int use_dnsbl=0; // [Zido]
+char dnsbl_servs[1024];
 int server_num;
 int new_account_flag = 0; //Set from config too XD [Sirius]
 int bind_ip_set_ = 0;
@@ -576,6 +577,7 @@ int mmo_auth( struct mmo_account* account , int fd){
 	char tmpstr[256];
 	char t_uid[256], t_pass[256];
 	char user_password[256];
+	char *dnsbl_serv;
 
 	//added for account creation _M _F
 	int len;
@@ -595,27 +597,22 @@ int mmo_auth( struct mmo_account* account , int fd){
 	// Start DNS Blacklist check [Zido]
 	if(use_dnsbl) {
 		sprintf(r_ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]);
-		
-		sprintf(ip_dnsbl,"%s.opm.blitzed.org",r_ip);
-		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
-			return 3;
-		}
-		sprintf(ip_dnsbl,"%s.sbl.deltaanime.net",r_ip);
-		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
-			return 3;
-		}
-		sprintf(ip_dnsbl,"%s.dnsbl.njabl.org",r_ip);
+
+		dnsbl_serv=strtok(dnsbl_servs,",");
+		sprintf(ip_dnsbl,"%s.%s",r_ip,dnsbl_serv);
 		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",ip);
 			return 3;
 		}
-		sprintf(ip_dnsbl,"%s.sbl-xbl.spamhaus.org",r_ip);
-		if(gethostbyname(ip_dnsbl)!=NULL) {
-			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
-			return 3;
+
+		while((dnsbl_serv=strtok(dnsbl_servs,","))!=NULL) {
+			sprintf(ip_dnsbl,"%s.%s",r_ip,dnsbl_serv);
+			if(gethostbyname(ip_dnsbl)!=NULL) {
+				ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",ip);
+				return 3;
+			}
 		}
+
 	}
 	// End DNS Blacklist check [Zido]
 
@@ -2171,6 +2168,8 @@ int login_config_read(const char *cfgName){
 			login_config_read(w2);
 		} else if(strcmpi(w1,"use_dnsbl")==0) { // [Zido]
 			use_dnsbl=atoi(w2);
+		} else if(strcmpi(w1,"dnsbl_servers")==0) { // [Zido]
+				strcpy(dnsbl_servs,w2);
 		}
  	}
 	fclose(fp);