[racket] PLaneT and proxies

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Sun Jun 20 15:46:32 EDT 2010

Robby, hello.

On 2010 Jun 20, at 17:28, Robby Findler wrote:

> I'm not really familiar with proxy setups and how to simulate them,
> but if you wanted to submit a patch that worked for you, I'm pretty
> sure that I could verify/adjust enough of it to be confident that it
> wouldn't break others stuff and I'd put it in....

No probs.

The following should basically work:

% diff -c resolver.rkt{-orig,}
*** resolver.rkt-orig	2010-06-06 11:19:13.000000000 +0100
--- resolver.rkt	2010-06-20 20:27:30.000000000 +0100
***************
*** 217,222 ****
--- 217,232 ----
           exn:fail:planet?
           make-exn:fail:planet)
  
+ ;; This is not the correct place for this...
+ (define (parse-proxy-string proxy-url-string)
+   (cond ((regexp-match #rx"^http://([a-zA-Z0-9.-]+):([0-9]+)" proxy-url-string)
+            => (λ (l) `(("http" ,(cadr l) ,(string->number (caddr l))))))
+         ((regexp-match #rx"^http://([a-zA-Z0-9.-]+)" proxy-url-string)
+            => (λ (l) `(("http" ,(cadr l) 80))))
+         (else (error (format "Can't parse proxy URL ~a" proxy-url-string)))))
+ (when (getenv "http_proxy")
+       (current-proxy-servers (parse-proxy-string (getenv "http_proxy"))))
+ 
  ;; if #f, will not install packages and instead raise a exn:fail:install? error
  (define install? (make-parameter #t))
  ;; if #f, will not download packages and instead raise a exn:fail:install? error

(and attached as a patch file in case there's any list trouble).

That sets the net/url proxy whenever the http_proxy environment variable is set.

  * It works for me.
  * This is clearly not the ideal place for this.
  * I presume something slightly different should happen on Windows -- I'll leave that to others
  * That regexp should match any sane hostname, but there can be in principle semi-pathological hostnames that it wouldn't match (but if anyone's doing that, they probably have other problems).

Any comments on style cheerfully received.

Best wishes,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resolver.patch
Type: application/octet-stream
Size: 951 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100620/29713792/attachment.obj>

Posted on the users mailing list.