mldonkey-bugs
[Top][All Lists]
Advanced

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

[Mldonkey-bugs] [PATCH] Bittorrent http fetch recections due to no refer


From: Charlie Brej
Subject: [Mldonkey-bugs] [PATCH] Bittorrent http fetch recections due to no referer (suprnova)
Date: Wed, 29 Sep 2004 02:25:50 +0100
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

This patch allows you to set fake referrers when fetching initial .torrent files from a site dependent on the file's address. An example is included in the bTOptions.ml file (which should be removed before adding to cvs. The first argument is the standard expression to match against the torrent address. The second is the fake referrer address. e.g.
[(".*suprnova.*", "http://www.suprnova.org/";)]

as suprnova files contain
http://66.90.75.92/suprnova//torrents/2645/mame86to87.7z.torrent
                   ^^^^^^^^

WARNING: This is my first attempt at coding ocaml so I may have done silly. (but it does seem to work for me)

--
        Charlie Brej
APT Group, Dept. Computer Science, University of Manchester
Web: http://www.cs.man.ac.uk/~brejc8/ Tel: +44 161 275 6844
Mail: IT302, Manchester University, Manchester, M13 9PL, UK
Index: networks/bittorrent/bTInteractive.ml
===================================================================
RCS file: /cvsroot/mldonkey/mldonkey/src/networks/bittorrent/bTInteractive.ml,v
retrieving revision 1.35
diff -u -3 -p -r1.35 bTInteractive.ml
--- networks/bittorrent/bTInteractive.ml        19 Aug 2004 07:56:53 -0000      
1.35
+++ networks/bittorrent/bTInteractive.ml        29 Sep 2004 01:14:37 -0000
@@ -289,6 +289,13 @@ let _ =
                 H.req_proxy = !CommonOptions.http_proxy;
                 H.req_user_agent = 
                 Printf.sprintf "MLdonkey/%s" Autoconf.current_version;
+        H.req_referer = (
+           let referers = !!BTOptions.referers in
+           let (rule_search,rule_value) = try (List.find(fun 
(rule_search,rule_value) ->
+                           Str.string_match (Str.regexp rule_search) url 0
+                           ) referers )
+                           with Not_found -> ("",url) in
+                Some (Url.of_string rule_value) ); 
                H.req_headers = try
                  let cookies = List.assoc u.Url.server !!BTOptions.cookies in
                  [ ( "Cookie", List.fold_left (fun res (key, value) ->
@@ -489,4 +496,4 @@ let gui_message s =
   | opcode -> failwith (Printf.sprintf "BT: Unknown message opcode %d" opcode)
   
 let _ =
-  network.op_network_gui_message <- gui_message
\ No newline at end of file
+  network.op_network_gui_message <- gui_message
Index: networks/bittorrent/bTOptions.ml
===================================================================
RCS file: /cvsroot/mldonkey/mldonkey/src/networks/bittorrent/bTOptions.ml,v
retrieving revision 1.13
diff -u -3 -p -r1.13 bTOptions.ml
--- networks/bittorrent/bTOptions.ml    4 Aug 2004 16:59:26 -0000       1.13
+++ networks/bittorrent/bTOptions.ml    29 Sep 2004 01:14:37 -0000
@@ -101,3 +101,8 @@ let _ =
 let cookies = define_option bittorrent_section ["cookies"]
     "Cookies send with http request to get .torrent file"
     (list_option (tuple2_option (string_option, list_option (tuple2_option 
(string_option, string_option))))) []
+
+let referers = define_option bittorrent_section ["referers"]
+    "Referer sent with http request to get .torrent file" 
+    (list_option (tuple2_option (string_option, string_option))) 
[(".*suprnova.*", "http://www.suprnova.org/";)]
+    

reply via email to

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