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, 08 Aug 2010 18:37:41 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       10/08/08 18:37:41

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonOptions.ml 
        src/utils/net  : http_client.ml http_client.mli 
                         tcpBufferedSocket.ml tcpBufferedSocket.mli 

Log message:
        patch #7267

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1456&r2=1.1457
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.233&r2=1.234
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/http_client.ml?cvsroot=mldonkey&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/http_client.mli?cvsroot=mldonkey&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/tcpBufferedSocket.ml?cvsroot=mldonkey&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/tcpBufferedSocket.mli?cvsroot=mldonkey&r1=1.19&r2=1.20

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1456
retrieving revision 1.1457
diff -u -b -r1.1456 -r1.1457
--- distrib/ChangeLog   7 Aug 2010 14:52:34 -0000       1.1456
+++ distrib/ChangeLog   8 Aug 2010 18:37:41 -0000       1.1457
@@ -14,7 +14,12 @@
 ChangeLog
 =========
 
-2010/08/07:
+2010/08/08
+7267: http proxy authentication support (ygrek)
+- new options http_proxy_login and http_proxy_password control authentication
+  for TCP CONNECT and plain HTTP requests through http proxy
+
+2010/08/07
 7273: Fix compile errors on Debian/kFreeBSD
 7272: Configure: Use Ocaml 3.12.0 as default compiler
 7269: Fix typos (glondu)

Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -b -r1.233 -r1.234
--- src/daemon/common/commonOptions.ml  7 Aug 2010 14:51:15 -0000       1.233
+++ src/daemon/common/commonOptions.ml  8 Aug 2010 18:37:41 -0000       1.234
@@ -1130,13 +1130,19 @@
   "Port of HTTP proxy"
     port_option 8080
 
+let http_proxy_login = define_option current_section ["http_proxy_login"]
+  "HTTP proxy login (leave empty if proxy doesn't require authentication)"
+    string_option ""
+
+let http_proxy_password = define_option current_section ["http_proxy_password"]
+  "HTTP proxy password"
+    string_option ""
+
 let http_proxy_tcp = define_option current_section ["http_proxy_tcp"]
   "Direct TCP connections to HTTP proxy (the proxy should support CONNECT)"
     bool_option false
 
 
-
-
 (*************************************************************************)
 (*                                                                       *)
 (*                         Mail section                                  *)
@@ -2052,14 +2058,20 @@
 
 let _ =
   let proxy_update _ =
+    let auth = match !!http_proxy_login with
+    | "" -> None
+    | _ -> Some (!!http_proxy_login, !!http_proxy_password)
+    in
     http_proxy :=
     (match !!http_proxy_server with
-        "" -> None
-      | _  -> Some (!!http_proxy_server, !!http_proxy_port));
+      | "" -> None
+      | _  -> Some (!!http_proxy_server, !!http_proxy_port, auth));
     http_proxy_tcp_update ()
   in
   option_hook http_proxy_server proxy_update;
   option_hook http_proxy_port proxy_update;
+  option_hook http_proxy_login proxy_update;
+  option_hook http_proxy_password proxy_update;
   option_hook http_proxy_tcp http_proxy_tcp_update
 
 let _ =

Index: src/utils/net/http_client.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/http_client.ml,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- src/utils/net/http_client.ml        1 Aug 2010 13:49:31 -0000       1.42
+++ src/utils/net/http_client.ml        8 Aug 2010 18:37:41 -0000       1.43
@@ -44,7 +44,7 @@
     req_headers : ( string * string ) list;
     req_user_agent : string;
     req_accept : string;
-    req_proxy : (string * int) option;
+    req_proxy : (string * int * (string * string) option) option; (* 
(host,port,(login,password)) *)
     mutable req_url : url;
     mutable req_save_to_file_time : float;
     req_request : http_request;
@@ -106,9 +106,15 @@
   Printf.bprintf res "User-Agent: %s\r\n" r.req_user_agent;
   Printf.bprintf res "Accept: %s\r\n" r.req_accept;
   Printf.bprintf res "Connection: close\r\n";
- (match r.req_referer with None -> ()
-    | Some url -> 
-        Printf.bprintf res "Referer: %s\r\n" (Url.to_string_no_args url));
+  begin match r.req_referer with 
+  | None -> ()
+  | Some url -> Printf.bprintf res "Referer: %s\r\n" (Url.to_string_no_args 
url)
+  end;
+  begin match r.req_proxy with
+  | Some (_,_,Some (login,password)) ->
+      Printf.bprintf res "Proxy-Authorization: Basic %s\n" (Base64.encode 
(login ^ ":" ^ password))
+  | _ -> ()
+  end;
   if url.user <> "" then begin
     let userpass = Printf.sprintf "%s:%s" url.user url.passwd in
     Printf.bprintf res "Authorization: Basic %s\r\n" (Base64.encode userpass)
@@ -225,7 +231,7 @@
     let server, port =
       match r.req_proxy with
       | None -> url.server, url.port
-      | Some (s, p) -> s, p
+      | Some (s, p, _) -> s, p
     in
 (*    lprintf "async_ip ...\n"; *)
     Ip.async_ip server (fun ip ->

Index: src/utils/net/http_client.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/http_client.mli,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- src/utils/net/http_client.mli       28 Jul 2010 16:25:45 -0000      1.10
+++ src/utils/net/http_client.mli       8 Aug 2010 18:37:41 -0000       1.11
@@ -35,7 +35,7 @@
     req_headers : ( string * string ) list;
     req_user_agent : string;
     req_accept : string;
-    req_proxy : (string * int) option;
+    req_proxy : (string * int * (string * string) option) option; (** 
(host,port,(login,password)) *)
     mutable req_url : Url.url;
     mutable req_save_to_file_time : float;
 (* re-download a saved file only if newer *)

Index: src/utils/net/tcpBufferedSocket.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/tcpBufferedSocket.ml,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- src/utils/net/tcpBufferedSocket.ml  28 Jul 2010 16:25:45 -0000      1.49
+++ src/utils/net/tcpBufferedSocket.ml  8 Aug 2010 18:37:41 -0000       1.50
@@ -1044,8 +1044,8 @@
       f
     else
     match !http_proxy with
-      None -> f
-    | Some (h, p) ->
+    | None -> f
+    | Some _ ->
         fun sock nread ->
 (* HTTP/1.0 200 OK\n\n *)
           let b = buf sock in
@@ -1328,10 +1328,10 @@
     let s = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
     if !bind_address <> Unix.inet_addr_any then
       Unix.bind s (Unix.ADDR_INET (!bind_address, 0));
-    let proxy_ip, proxy_port =
+    let proxy_ip, proxy_port, proxy_auth =
       match !http_proxy with
-        None -> Ip.null, 0
-      | Some (h, p) -> Ip.from_name h, p
+      | None -> Ip.null, 0, None
+      | Some (h, p, auth) -> Ip.from_name h, p, auth
     in
     let ip = Ip.of_inet_addr host in
     let use_proxy = proxy_ip <> Ip.null && proxy_ip <> ip in
@@ -1347,7 +1347,11 @@
         Printf.bprintf buf "Cache-Control: no-cache\n";
         Printf.bprintf buf "Connection: Keep-Alive\n";
         Printf.bprintf buf "Proxy-Connection: Keep-Alive\n";
-(*Printf.bprintf buf "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 
NT; Hotbar 2.0)\n";*)
+        begin match proxy_auth with
+        | Some (login,password) ->
+            Printf.bprintf buf "Proxy-Authorization: Basic %s\n" 
(Base64.encode (login ^ ":" ^ password))
+        | None -> () 
+        end;
         Printf.bprintf buf "User-Agent: MLdonkey/%s\n" 
Autoconf.current_version;
         Printf.bprintf buf "\n";
         ignore (MlUnix.write s (Buffer.contents buf) 0 (Buffer.length buf))

Index: src/utils/net/tcpBufferedSocket.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/tcpBufferedSocket.mli,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- src/utils/net/tcpBufferedSocket.mli 28 Jul 2010 16:25:45 -0000      1.19
+++ src/utils/net/tcpBufferedSocket.mli 8 Aug 2010 18:37:41 -0000       1.20
@@ -146,7 +146,7 @@
   
 val get_rtimeout : t -> float * float
   
-val http_proxy : (string * int) option ref
+val http_proxy : (string * int * (string * string) option) option ref (* 
(host, port, (login, password)) *)
 val copy_read_buffer : bool ref
   
 type connection_manager



reply via email to

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