mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...
Date: Sun, 17 Jun 2007 01:20:19 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       07/06/17 01:20:19

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonBlocking.ml 
        src/networks/bittorrent: bTClients.ml 

Log message:
        patch #5992

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1275&r2=1.1276
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonBlocking.ml?cvsroot=mldonkey&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTClients.ml?cvsroot=mldonkey&r1=1.92&r2=1.93

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1275
retrieving revision 1.1276
diff -u -b -r1.1275 -r1.1276
--- distrib/ChangeLog   3 Jun 2007 13:17:02 -0000       1.1275
+++ distrib/ChangeLog   17 Jun 2007 01:20:19 -0000      1.1276
@@ -14,6 +14,9 @@
 ChangeLog
 =========
 
+2007/06/17
+5992: BT/IP block: Fix country-based IP blocking
+-------------------------------------------------------------------------------
 2007/06/03: version 2.8.7 = tag release-2-8-7
 5988: BT: Completely parse handshake packet of newer BT clients (thx to Berni)
 - this patch should fix the serious performance problem with BT downloads

Index: src/daemon/common/commonBlocking.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonBlocking.ml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- src/daemon/common/commonBlocking.ml 2 Jun 2007 16:14:07 -0000       1.6
+++ src/daemon/common/commonBlocking.ml 17 Jun 2007 01:20:19 -0000      1.7
@@ -44,12 +44,12 @@
 let geoip_hit cbl ip cc =
   let index =
     match cc with
-    | None -> 0
+    | None -> Geoip.get_country_code ip
     | Some cc -> if cc = 0 then Geoip.get_country_code ip else cc
   in
   if not (Geoip.active ()) || !country_blocking_string_list_copy = [] then None
   else if cbl.(index) then
-    Some (Printf.sprintf "IPs from %s are currently blocked"
+    Some (Printf.sprintf "IPs from country %s are currently blocked"
       Geoip.country_name_array.(index))
   else None
 

Index: src/networks/bittorrent/bTClients.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTClients.ml,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -b -r1.92 -r1.93
--- src/networks/bittorrent/bTClients.ml        3 Jun 2007 13:13:17 -0000       
1.92
+++ src/networks/bittorrent/bTClients.ml        17 Jun 2007 01:20:19 -0000      
1.93
@@ -461,17 +461,20 @@
     let file = Hashtbl.find files_by_uid file_id in
     if !verbose_msg_clients then
       lprintf_file_nl (as_file file) "file found";
+    let ccc, cc_country_code = !cc in
     let c =
-      match !cc with
+      match ccc with
         None ->
-          let c = new_client file Sha1.null (TcpBufferedSocket.peer_addr sock) 
None in
+          let c = new_client file Sha1.null (TcpBufferedSocket.peer_addr sock) 
cc_country_code in
           if !verbose_connect then lprintf_file_nl (as_file file) "Client %d: 
incoming connection" (client_num c);
-          cc := Some c;
+          cc := (Some c), cc_country_code;
           c
       | Some c ->
           (* Does it happen that this c was already used to connect 
successfully?
              If yes then this must happen: *)
           c.client_received_peer_id <- false;
+          if cc_country_code <> None && c.client_country_code = None then
+            c.client_country_code <- cc_country_code;
           c
           (* client could have had Sha1.null as peer_id/uid *)
           (* this is to be done, later
@@ -1087,8 +1090,10 @@
        None -> true
      | Some reason ->
          if !verbose_connect then
-           lprintf_nl "%s:%d blocked: %s"
-             (Ip.to_string ip) port reason;
+           lprintf_nl "%s:%d (%s), blocked: %s"
+             (Ip.to_string ip) port
+             (fst (Geoip.get_country_code_name c.client_country_code))
+             reason;
          false)
   then
   match c.client_sock with
@@ -1148,7 +1153,7 @@
                     be parsed
                   *)
                   set_bt_sock sock !verbose_msg_clients
-                    (BTHeader (client_parse_header !counter (ref (Some c)) 
true))
+                    (BTHeader (client_parse_header !counter (ref ((Some c), 
c.client_country_code)) true))
                 end
             with e ->
                 lprintf_nl "Exception %s while connecting to client"
@@ -1180,6 +1185,7 @@
                 to connect to us
               *)
               let ip = (Ip.of_inet_addr from_ip) in
+              let cc = Geoip.get_country_code_option ip in
               if !verbose_sources > 1 then lprintf_nl "CONNECTION RECEIVED 
FROM %s"
                 (Ip.to_string (Ip.of_inet_addr from_ip))
               ;
@@ -1187,12 +1193,14 @@
                 to bypass the max_connection parameter
               *)
               if can_open_connection connection_manager &&
-                (match !Ip.banned (ip, None) with
+                (match !Ip.banned (ip, cc) with
                    None -> true
                  | Some reason ->
                      if !verbose_connect then
-                       lprintf_nl "%s:%d blocked: %s"
-                         (Ip.to_string ip) from_port reason;
+                       lprintf_nl "%s:%d (%s) blocked: %s"
+                         (Ip.to_string ip) from_port
+                         (fst (Geoip.get_country_code_name cc))
+                         reason;
                      false)
               then
                 begin
@@ -1212,9 +1220,9 @@
                   TcpBufferedSocket.set_read_controler sock download_control;
                   TcpBufferedSocket.set_write_controler sock upload_control;
 
-                  let c = ref None in
+                  let c = ref (None, cc) in
                   TcpBufferedSocket.set_closer sock (fun _ r ->
-                      match !c with
+                      match fst !c with
                         Some c ->  begin
                             match c.client_sock with
                             | Connection s when s == sock ->




reply via email to

[Prev in Thread] Current Thread [Next in Thread]