[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-commits] mldonkey config/Makefile.in distrib/ChangeLog s...
From: |
mldonkey-commits |
Subject: |
[Mldonkey-commits] mldonkey config/Makefile.in distrib/ChangeLog s... |
Date: |
Wed, 29 Mar 2006 15:41:34 +0000 |
CVSROOT: /sources/mldonkey
Module name: mldonkey
Branch:
Changes by: spiralvoice <address@hidden> 06/03/29 15:41:33
Modified files:
config : Makefile.in
distrib : ChangeLog
src/daemon/common: commonComplexOptions.ml commonOptions.ml
commonServer.ml guiEncoding.ml
src/daemon/driver: driverCommands.ml driverInteractive.ml
driverMain.ml
src/networks/bittorrent: bTClients.ml
src/networks/donkey: donkeyClient.ml donkeyGlobals.ml
donkeyInteractive.ml donkeyServers.ml
src/utils/net : geoip.ml http_server.ml ip.ml ip.mli ip_set.ml
Added files:
src/daemon/common: commonBlocking.ml
Log message:
patch #4931
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/config/Makefile.in.diff?tr1=1.152&tr2=1.153&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/distrib/ChangeLog.diff?tr1=1.776&tr2=1.777&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonBlocking.ml?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonComplexOptions.ml.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonOptions.ml.diff?tr1=1.135&tr2=1.136&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonServer.ml.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/guiEncoding.ml.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml.diff?tr1=1.133&tr2=1.134&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml.diff?tr1=1.71&tr2=1.72&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverMain.ml.diff?tr1=1.103&tr2=1.104&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/networks/bittorrent/bTClients.ml.diff?tr1=1.65&tr2=1.66&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml.diff?tr1=1.86&tr2=1.87&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/networks/donkey/donkeyGlobals.ml.diff?tr1=1.76&tr2=1.77&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml.diff?tr1=1.94&tr2=1.95&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/networks/donkey/donkeyServers.ml.diff?tr1=1.53&tr2=1.54&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/utils/net/geoip.ml.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/utils/net/http_server.ml.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/utils/net/ip.ml.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/utils/net/ip.mli.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/utils/net/ip_set.ml.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
Patches:
Index: mldonkey/config/Makefile.in
diff -u mldonkey/config/Makefile.in:1.152 mldonkey/config/Makefile.in:1.153
--- mldonkey/config/Makefile.in:1.152 Wed Mar 8 20:58:22 2006
+++ mldonkey/config/Makefile.in Wed Mar 29 15:41:33 2006
@@ -250,12 +250,13 @@
$(COMMON)/commonFile.ml \
$(COMMON)/commonNetwork.ml \
$(COMMON)/commonResult.ml \
+ $(COMMON)/commonWeb.ml \
+ $(COMMON)/commonBlocking.ml \
$(COMMON)/commonComplexOptions.ml \
$(COMMON)/commonShared.ml \
$(COMMON)/commonRoom.ml \
$(COMMON)/commonSearch.ml \
$(COMMON)/commonMultimedia.ml \
- $(COMMON)/commonWeb.ml \
$(COMMON)/commonInteractive.ml \
$(COMMON)/commonChunks.ml \
$(COMMON)/commonSwarming.ml \
Index: mldonkey/distrib/ChangeLog
diff -u mldonkey/distrib/ChangeLog:1.776 mldonkey/distrib/ChangeLog:1.777
--- mldonkey/distrib/ChangeLog:1.776 Wed Mar 29 14:23:10 2006
+++ mldonkey/distrib/ChangeLog Wed Mar 29 15:41:33 2006
@@ -15,6 +15,14 @@
=========
2006/03/29
+4931: CommonBlocking: Block/allow IPs by country codes (requires GeoIP) (pango)
+- new options:
+ - ip_blocking_countries, insert country codes here
+ - ip_blocking_countries_block true|false
+ false: use ip_blocking_countries as block list,
+ all other countries are allowed
+ true: use ip_blocking_countries as allow list,
+ all other countries are blocked
4995: HTML: Fix friends filelist display
4996: HTML: Add/remove for web_infos (vwi), update old contact.dat URL
- web_infos, rename command add_url to urladd, new command urlremove
Index: mldonkey/src/daemon/common/commonComplexOptions.ml
diff -u mldonkey/src/daemon/common/commonComplexOptions.ml:1.50
mldonkey/src/daemon/common/commonComplexOptions.ml:1.51
--- mldonkey/src/daemon/common/commonComplexOptions.ml:1.50 Sun Mar 19
17:38:08 2006
+++ mldonkey/src/daemon/common/commonComplexOptions.ml Wed Mar 29 15:41:33 2006
@@ -1096,13 +1096,24 @@
lprintf_nl () "Options backup as %s correctly saved" format
let _ =
+ CommonBlocking.add_update_hook CommonServer.check_blocked_servers;
+ CommonBlocking.add_update_hook CommonServer.server_must_update_all;
option_hook ip_blocking (fun _ ->
- (try
- Ip_set.bl := if !!ip_blocking <> "" then
- Ip_set.load !!ip_blocking
- else Ip_set.bl_empty
- with _ -> ());
- CommonServer.check_blocked_servers ()
+ try
+ CommonBlocking.set_ip_blocking_list !!ip_blocking
+ with _ -> ()
+ );
+ option_hook ip_blocking_countries (fun _ ->
+ CommonBlocking.set_ip_blocking_countries !!ip_blocking_countries
+ );
+ option_hook ip_blocking_countries_block (fun _ ->
+ CommonBlocking.set_ip_blocking_countries_block
!!ip_blocking_countries_block;
+ CommonBlocking.set_ip_blocking_countries !!ip_blocking_countries
+ );
+ option_hook geoip_dat (fun _ ->
+ try
+ CommonBlocking.set_geoip_dat !!geoip_dat
+ with _ -> ()
);
option_hook max_opened_connections (fun _ ->
if !verbose then lprintf_nl ()
Index: mldonkey/src/daemon/common/commonOptions.ml
diff -u mldonkey/src/daemon/common/commonOptions.ml:1.135
mldonkey/src/daemon/common/commonOptions.ml:1.136
--- mldonkey/src/daemon/common/commonOptions.ml:1.135 Wed Mar 29 14:22:08 2006
+++ mldonkey/src/daemon/common/commonOptions.ml Wed Mar 29 15:41:33 2006
@@ -266,6 +266,8 @@
let int_list_option = list_option int_option
+let country_list_option = list_option string_option
+
let allow_browse_share_option = define_option_class "Integer"
(fun v ->
match v with
@@ -301,7 +303,10 @@
(fun s ->
let list = String2.tokens s in
List.map (fun i -> int_of_string i) list
- )
+ );
+ Options.set_string_wrappers country_list_option
+ (String.concat " ")
+ String2.tokens
let is_not_spam = ref (fun _ -> true)
@@ -857,6 +862,17 @@
Zip files must contain either a file named guarding.p2p or
guarding_full.p2p."
string_option ""
+let ip_blocking_countries = define_expert_option current_section
["ip_blocking_countries"]
+ "List of countries to block connections from/to (requires Geoip).
+ Names are in ISO 3166 format, see http://www.maxmind.com/app/iso3166
+ You can also at your own risk use \"Unknown\" for IPs Geoip won't recognize."
+ country_list_option []
+
+let ip_blocking_countries_block = define_expert_option current_section
+ ["ip_blocking_countries_block"]
+ "false: use ip_blocking_countries as block list, all other countries are
allowed
+ true: use ip_blocking_countries as allow list, all other countries are
blocked" bool_option false
+
let geoip_dat = define_expert_option current_section ["geoip_dat"]
"Location of GeoIP.dat (Get one from
http://www.maxmind.com/download/geoip/database/)"
string_option ""
@@ -864,11 +880,6 @@
let _ =
option_hook ip_blocking_descriptions (fun _ ->
Ip_set.store_blocking_descriptions := !!ip_blocking_descriptions
- );
- option_hook geoip_dat (fun _ ->
- try
- Geoip.init (Geoip.unpack !!geoip_dat);
- with _ -> ()
)
let tcpip_packet_size = define_expert_option current_section
["tcpip_packet_size"]
Index: mldonkey/src/daemon/common/commonServer.ml
diff -u mldonkey/src/daemon/common/commonServer.ml:1.27
mldonkey/src/daemon/common/commonServer.ml:1.28
--- mldonkey/src/daemon/common/commonServer.ml:1.27 Sun Mar 5 10:41:50 2006
+++ mldonkey/src/daemon/common/commonServer.ml Wed Mar 29 15:41:33 2006
@@ -265,7 +265,7 @@
let server_blocked s =
let info = server_info s in
- Ip_set.ip_blocked (Ip.ip_of_addr info.G.server_addr)
+ !Ip.banned (Ip.ip_of_addr info.G.server_addr) <> None
let server_connect s =
if not (server_blocked s) then
Index: mldonkey/src/daemon/common/guiEncoding.ml
diff -u mldonkey/src/daemon/common/guiEncoding.ml:1.50
mldonkey/src/daemon/common/guiEncoding.ml:1.51
--- mldonkey/src/daemon/common/guiEncoding.ml:1.50 Mon Jan 16 16:05:14 2006
+++ mldonkey/src/daemon/common/guiEncoding.ml Wed Mar 29 15:41:33 2006
@@ -596,10 +596,7 @@
);
if proto > 33 then begin
let is_blocked =
- try
- Ip_set.ip_blocked (Ip.ip_of_addr addr)
- with _ ->
- false
+ !Ip.banned (Ip.ip_of_addr addr) <> None
in
buf_bool buf is_blocked
end
Index: mldonkey/src/daemon/driver/driverCommands.ml
diff -u mldonkey/src/daemon/driver/driverCommands.ml:1.133
mldonkey/src/daemon/driver/driverCommands.ml:1.134
--- mldonkey/src/daemon/driver/driverCommands.ml:1.133 Wed Mar 29 14:22:08 2006
+++ mldonkey/src/daemon/driver/driverCommands.ml Wed Mar 29 15:41:33 2006
@@ -1729,8 +1729,6 @@
strings_of_option auto_commit;
strings_of_option create_dir_mask;
strings_of_option create_file_sparse;
- strings_of_option ip_blocking;
- strings_of_option ip_blocking_descriptions;
strings_of_option log_file;
strings_of_option log_file_size;
strings_of_option log_size;
@@ -1783,9 +1781,10 @@
strings_of_option tcpip_packet_size;
strings_of_option mtu_packet_size;
strings_of_option minimal_packet_size;
- strings_of_option http_proxy_tcp;
- strings_of_option http_proxy_server;
- strings_of_option http_proxy_port;
+ strings_of_option ip_blocking;
+ strings_of_option ip_blocking_descriptions;
+ strings_of_option ip_blocking_countries;
+ strings_of_option ip_blocking_countries_block;
])
| 8 ->
[
@@ -3218,22 +3217,22 @@
if o.conn_output = HTML then
let mybuf = Buffer.create 1000 in
let mytable = ref [] in
- Ip_set.print_list mybuf !Ip_set.bl;
+ Ip_set.print_list mybuf !CommonBlocking.ip_blocking_list;
let listtmp = String2.split (Buffer.contents mybuf) '\n' in
(List.iter (fun s ->
mytable := !mytable @ [ ("", "srh", s); ]
) listtmp);
html_mods_table_one_col buf "serversTable" "servers" !mytable
else
- Ip_set.print_list buf !Ip_set.bl;
+ Ip_set.print_list buf !CommonBlocking.ip_blocking_list;
_s ""
), ":\t\t\t\tdisplay the list of blocked IP ranges that were hit";
"block_test", Arg_one (fun arg o ->
let ip = Ip.of_string arg in
- _s (match match_ip_aux !Ip_set.bl ip with
+ _s (match !Ip.banned ip with
None -> "Not blocked"
- | Some br ->
- Printf.sprintf "Blocked, %s\n" br.blocking_description)
+ | Some reason ->
+ Printf.sprintf "Blocked, %s\n" reason)
), "<ip> :\t\t\tcheck whether an IP is blocked";
]
Index: mldonkey/src/daemon/driver/driverInteractive.ml
diff -u mldonkey/src/daemon/driver/driverInteractive.ml:1.71
mldonkey/src/daemon/driver/driverInteractive.ml:1.72
--- mldonkey/src/daemon/driver/driverInteractive.ml:1.71 Wed Mar 29
14:23:10 2006
+++ mldonkey/src/daemon/driver/driverInteractive.ml Wed Mar 29 15:41:33 2006
@@ -1811,8 +1811,9 @@
^ "\nServer usage:\t " ^ (if !!enable_servers then "enabled" else
"disabled (you are not able to connect to ED2K Servers)")
^ "\nGeoip:\t\t " ^ (if !Geoip.active then "enabled, GeoLite data
created by MaxMind, available from http://maxmind.com/"
else dis_mess)
- ^ "\nIP blocking:\t " ^ (let r1,r2 = Ip_set.block_stats () in
- if r1 = 0 then dis_mess else Printf.sprintf "enabled, %d ranges
loaded - optimized to %d" r1 r2)
+ ^ (Printf.sprintf "\nIP blocking local: %d ranges, web: %d ranges"
+ (Ip_set.bl_length !CommonBlocking.ip_blocking_list)
+ (Ip_set.bl_length !CommonBlocking.web_ip_blocking_list))
^ (if not !dns_works then
Printf.sprintf "\nDNS:\t\t DNS resolution not available, web_infos
%s not work"
(if Autoconf.bittorrent = "yes" then "and BT does" else "do")
Index: mldonkey/src/daemon/driver/driverMain.ml
diff -u mldonkey/src/daemon/driver/driverMain.ml:1.103
mldonkey/src/daemon/driver/driverMain.ml:1.104
--- mldonkey/src/daemon/driver/driverMain.ml:1.103 Wed Mar 29 14:22:08 2006
+++ mldonkey/src/daemon/driver/driverMain.ml Wed Mar 29 15:41:33 2006
@@ -171,19 +171,7 @@
| e -> lprintf_nl () (_b "Error while reading motd.conf(%s): %s") filename
(Printexc2.to_string e);
close_in ic
- );
- CommonWeb.add_web_kind "guarding.p2p"
- "IP blocking lists (ipfilter and guardian v2 formats)"
- (fun _ filename ->
- Ip_set.bl := Ip_set.load filename;
-(* Ip_set.bl := Ip_set.load_merge !Ip_set.bl filename *)
- CommonServer.check_blocked_servers ()
- );
- CommonWeb.add_web_kind "geoip.dat" "IP to country mapping database"
- (fun _ filename ->
- Geoip.init (Geoip.unpack filename);
- CommonServer.server_must_update_all ())
-
+ )
let save_mlsubmit_reg () =
Index: mldonkey/src/networks/bittorrent/bTClients.ml
diff -u mldonkey/src/networks/bittorrent/bTClients.ml:1.65
mldonkey/src/networks/bittorrent/bTClients.ml:1.66
--- mldonkey/src/networks/bittorrent/bTClients.ml:1.65 Sat Feb 25 21:09:03 2006
+++ mldonkey/src/networks/bittorrent/bTClients.ml Wed Mar 29 15:41:33 2006
@@ -1082,12 +1082,12 @@
let connect_client c =
if can_open_connection connection_manager &&
(let (ip,port) = c.client_host in
- match Ip_set.match_ip !Ip_set.bl ip with
+ match !Ip.banned ip with
None -> true
- | Some br ->
+ | Some reason ->
if !verbose_connect then
lprintf_nl () "%s:%d blocked: %s"
- (Ip.to_string ip) port br.blocking_description;
+ (Ip.to_string ip) port reason;
false)
then
match c.client_sock with
@@ -1186,12 +1186,12 @@
to bypass the max_connection parameter
*)
if can_open_connection connection_manager &&
- (match Ip_set.match_ip !Ip_set.bl ip with
+ (match !Ip.banned ip with
None -> true
- | Some br ->
+ | Some reason ->
if !verbose_connect then
lprintf_nl () "%s:%d blocked: %s"
- (Ip.to_string ip) from_port br.blocking_description;
+ (Ip.to_string ip) from_port reason;
false)
then
begin
@@ -1407,12 +1407,12 @@
!peer_id <> !!client_uid &&
!peer_ip != Ip.null &&
!port <> 0 &&
- (match match_ip !Ip_set.bl !peer_ip with
+ (match !Ip.banned !peer_ip with
None -> true
- | Some br ->
+ | Some reason ->
if !verbose_connect then
lprintf_nl () "%s:%d blocked: %s"
- (Ip.to_string !peer_ip) !port
br.blocking_description;
+ (Ip.to_string !peer_ip) !port reason;
false)
then
let _ = new_client file !peer_id (!peer_ip,!port)
Index: mldonkey/src/networks/donkey/donkeyClient.ml
diff -u mldonkey/src/networks/donkey/donkeyClient.ml:1.86
mldonkey/src/networks/donkey/donkeyClient.ml:1.87
--- mldonkey/src/networks/donkey/donkeyClient.ml:1.86 Fri Feb 17 22:24:41 2006
+++ mldonkey/src/networks/donkey/donkeyClient.ml Wed Mar 29 15:41:33 2006
@@ -2442,7 +2442,7 @@
TcpServerSocket.CONNECTION (s, Unix.ADDR_INET (from_ip, from_port)) ->
let from_ip = Ip.of_inet_addr from_ip in
let s_from_ip = Ip.to_string from_ip in
- let is_ip_blocked = Ip_set.ip_blocked from_ip in
+ let is_ip_blocked = !Ip.banned from_ip <> None in
let too_many_indirect_connections =
!DonkeySources.indirect_connections >
!real_max_indirect_connections
Index: mldonkey/src/networks/donkey/donkeyGlobals.ml
diff -u mldonkey/src/networks/donkey/donkeyGlobals.ml:1.76
mldonkey/src/networks/donkey/donkeyGlobals.ml:1.77
--- mldonkey/src/networks/donkey/donkeyGlobals.ml:1.76 Mon Mar 6 17:59:45 2006
+++ mldonkey/src/networks/donkey/donkeyGlobals.ml Wed Mar 29 15:41:33 2006
@@ -459,11 +459,11 @@
(* lprintf "is black ="; *)
not (Ip.reachable ip) || (Ip.matches ip !!server_black_list) ||
(List.mem port !!port_black_list) ||
- (match Ip_set.match_ip !Ip_set.bl ip with
+ (match !Ip.banned ip with
None -> false
- | Some br ->
+ | Some reason ->
if !verbose_connect then
- lprintf_nl () "%s:%d blocked: %s" (Ip.to_string ip) port
br.Ip_set.blocking_description;
+ lprintf_nl () "%s:%d blocked: %s" (Ip.to_string ip) port reason;
true))
let new_server ip port score =
Index: mldonkey/src/networks/donkey/donkeyInteractive.ml
diff -u mldonkey/src/networks/donkey/donkeyInteractive.ml:1.94
mldonkey/src/networks/donkey/donkeyInteractive.ml:1.95
--- mldonkey/src/networks/donkey/donkeyInteractive.ml:1.94 Wed Mar 29
14:22:08 2006
+++ mldonkey/src/networks/donkey/donkeyInteractive.ml Wed Mar 29 15:41:33 2006
@@ -1144,7 +1144,7 @@
let cc,cn = Geoip.get_country ip in
(Ip.to_string ip),cc,cn
| _ ->
- let cc,cn = !Geoip.unknown_country in
+ let cc,cn = Geoip.unknown_country in
(string_of_client_addr c),cc,cn
with _ -> ("X","??","Country Error")
Index: mldonkey/src/networks/donkey/donkeyServers.ml
diff -u mldonkey/src/networks/donkey/donkeyServers.ml:1.53
mldonkey/src/networks/donkey/donkeyServers.ml:1.54
--- mldonkey/src/networks/donkey/donkeyServers.ml:1.53 Wed Mar 8 20:05:26 2006
+++ mldonkey/src/networks/donkey/donkeyServers.ml Wed Mar 29 15:41:33 2006
@@ -474,7 +474,7 @@
()
let connect_server s =
- if !!enable_servers && not (Ip_set.ip_blocked s.server_ip)
+ if !!enable_servers && not (!Ip.banned s.server_ip <> None)
&& (not !!connect_only_preferred_server || s.server_preferred)
then
match s.server_sock with
Index: mldonkey/src/utils/net/geoip.ml
diff -u mldonkey/src/utils/net/geoip.ml:1.3 mldonkey/src/utils/net/geoip.ml:1.4
--- mldonkey/src/utils/net/geoip.ml:1.3 Sun Jan 29 18:42:02 2006
+++ mldonkey/src/utils/net/geoip.ml Wed Mar 29 15:41:33 2006
@@ -115,7 +115,13 @@
"Satellite Provider";"Other";
|]
-let unknown_country = ref ("--", "N/A")
+let country_index = Hashtbl.create 10
+let _ =
+ Array.iteri (fun i cc ->
+ Hashtbl.add country_index cc i
+ ) country_code_array
+
+let unknown_country = ("--", "N/A")
let file = ref (Obj.magic 0)
let active = ref false
let database_type = ref databaseInfo_COUNTRY_EDITION
@@ -298,13 +304,12 @@
end
let get_country ip =
- if not !active then !unknown_country
+ if not !active then unknown_country
else begin
try
let ret = (seek_country ip) - country_begin in
- if ret = 0 then !unknown_country
+ if ret = 0 then unknown_country
else country_code_array.(ret), country_name_array.(ret);
with _ ->
- !unknown_country
+ unknown_country
end
-
Index: mldonkey/src/utils/net/http_server.ml
diff -u mldonkey/src/utils/net/http_server.ml:1.27
mldonkey/src/utils/net/http_server.ml:1.28
--- mldonkey/src/utils/net/http_server.ml:1.27 Fri Feb 17 22:24:41 2006
+++ mldonkey/src/utils/net/http_server.ml Wed Mar 29 15:41:33 2006
@@ -802,11 +802,11 @@
(* check here if ip is OK *)
let from_ip = Ip.of_inet_addr from_ip in
if Ip.matches from_ip config.addrs &&
- (match Ip_set.match_ip !Ip_set.bl from_ip with
+ (match !Ip.banned from_ip with
None -> true
- | Some br ->
+ | Some reason ->
lprintf_http_nl () "%s:%d blocked: %s\n"
- (Ip.to_string from_ip) from_port br.blocking_description;
+ (Ip.to_string from_ip) from_port reason;
false) then
let token = create_token unlimited_connection_manager in
let sock = TcpBufferedSocket.create_simple
Index: mldonkey/src/utils/net/ip.ml
diff -u mldonkey/src/utils/net/ip.ml:1.19 mldonkey/src/utils/net/ip.ml:1.20
--- mldonkey/src/utils/net/ip.ml:1.19 Wed Dec 14 21:17:47 2005
+++ mldonkey/src/utils/net/ip.ml Wed Mar 29 15:41:33 2006
@@ -141,6 +141,8 @@
else
(255,255,255,255) (* or exception ? *)
+let banned = ref (fun (ip:t) -> None)
+
let localhost = of_string "127.0.0.1"
let to_sockaddr ip port =
Index: mldonkey/src/utils/net/ip.mli
diff -u mldonkey/src/utils/net/ip.mli:1.6 mldonkey/src/utils/net/ip.mli:1.7
--- mldonkey/src/utils/net/ip.mli:1.6 Sat Sep 17 17:59:47 2005
+++ mldonkey/src/utils/net/ip.mli Wed Mar 29 15:41:33 2006
@@ -32,6 +32,7 @@
val local_ip : t -> bool
val reachable : t -> bool
val usable : t -> bool
+val banned : (t -> string option) ref
val resolve_one : t -> string
val matches : t -> t list -> bool
@@ -74,4 +75,4 @@
val addr_option : addr Options.option_class
val allow_local_network : bool ref
-
\ No newline at end of file
+
Index: mldonkey/src/utils/net/ip_set.ml
diff -u mldonkey/src/utils/net/ip_set.ml:1.24
mldonkey/src/utils/net/ip_set.ml:1.25
--- mldonkey/src/utils/net/ip_set.ml:1.24 Wed Mar 1 20:06:50 2006
+++ mldonkey/src/utils/net/ip_set.ml Wed Mar 29 15:41:33 2006
@@ -19,8 +19,6 @@
end)
let descriptions = H.create 13
-let ranges_1 = ref 0 (* ranges in blocklist file *)
-let ranges_2 = ref 0 (* ranges after optimization *)
let shared_description s =
(* Currently trims strings left and right;
@@ -112,8 +110,7 @@
Some br
let match_ip bl ip =
- let m = if Ip.local_ip ip then None else
- match_ip_aux bl ip in
+ let m = match_ip_aux bl ip in
(match m with
Some br ->
br.blocking_hits <- br.blocking_hits + 1
@@ -221,8 +218,6 @@
if remove then (try Sys.remove filename with _ -> ());
let optimized_bl = bl_optimize !bl in
lprintf_nl () "%d ranges loaded - optimized to %d" !nranges (bl_length
optimized_bl);
- ranges_1 := !nranges;
- ranges_2 := bl_length optimized_bl;
(* bl_optimizedp optimized_bl;
for i=0 to 999999 do
let random_ip = Ip.of_ints (Random.int 256, Random.int 256, Random.int
256, Random.int 256) in
@@ -345,20 +340,8 @@
let nright = print_list_aux right in
nleft + 1 + nright in
- ignore(print_list_aux bl);
- if !ranges_1 = 0 then
- Printf.bprintf buf "%d ranges loaded\n" !ranges_1
- else
- Printf.bprintf buf "%d ranges loaded - optimized to %d\n" !ranges_1
!ranges_2
-
-let bl = ref BL_Empty
-
-let ip_blocked ip =
- match match_ip !bl ip with
- None -> false
- | Some br -> true
-
-let block_stats () = (!ranges_1, !ranges_2)
+ let nranges = print_list_aux bl in
+ Printf.bprintf buf "%d ranges\n" nranges
(*
open Benchmark
@@ -385,7 +368,4 @@
Heap.add_memstat "Ip_set" (fun level buf ->
let counter = ref 0 in
H.iter (fun _ -> incr counter) descriptions;
- Printf.bprintf buf " descriptions: %d\n" !counter;
- Printf.bprintf buf " ranges: %d\n" (bl_length !bl);
- )
-
+ Printf.bprintf buf " descriptions: %d\n" !counter)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Mldonkey-commits] mldonkey config/Makefile.in distrib/ChangeLog s...,
mldonkey-commits <=