Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Autoproxy behind a corporate firewall that uses a website to configure proxy

22 views
Skip to first unread message

jal...@gmail.com

unread,
Jun 25, 2008, 11:19:03 PM6/25/08
to
Hello,

I am a tcl user behind a corporate firewall. I'd like to develop an
app that communicates with a server outside of the firewall, and I'd
like to write this app in tcl. The only problem is that autoproxy
does not work because my company stores proxy info on a website. IE
knows the url and uses it just fine, but autoproxy seems unable to do
so. Is there anyway to grab the proxy info from that site and
configure the http package accordingly?

Sincerely,

Joshua Litt

Alexandre Ferrieux

unread,
Jun 26, 2008, 4:59:57 AM6/26/08
to

If you are in the same case as I am, you're out of luck :-)
Indeed all the logic is written in Javascript to be executed by the
client (the browser)... In my case the workaround is to identify the
proxy to use for the "outside" which is (in my company) constant for a
given location of the client machine (my company is multi-site). Yes,
it's awfully inelegant, but taming a SpiderMonkey just for that was
contrary to my religion ;-)

-Alex

Pat Thoyts

unread,
Jun 26, 2008, 7:18:14 AM6/26/08
to
jal...@gmail.com writes:

A general solution to this is to use IE or the XMLHttpRequest object
via its automation interface as these IE objects already know how to
read such proxy information. Using libcurl might be another solution.

In http://www.patthoyts.tk/programming/tclole05src.zip there is a
rough re-implementation of the http package using MSXML.XMLHTTP as the
transport to work with proxies on windows like this. It may be worth
examining (library/http.tcl and demo/*)

--
Pat Thoyts http://www.patthoyts.tk/
To reply, rot13 the return address or read the X-Address header.
PGP fingerprint 2C 6E 98 07 2C 59 C8 97 10 CE 11 E6 04 E0 B9 DD

Alexandre Ferrieux

unread,
Jun 26, 2008, 8:33:07 AM6/26/08
to
On Jun 26, 1:18 pm, Pat Thoyts <cnggub...@hfref.fbheprsbetr.arg>
wrote:

>
> Using libcurl might be another solution.
>

I'm interested ! But how is libcurl supposed to handle the Javascript
encoding the logic ?

-Alex

Glenn Jackman

unread,
Jun 26, 2008, 9:57:13 AM6/26/08
to

Mine does too: http://proxy.company.com/proxy.pac

Have a look at the page. Mine has a FindProxyForURL function that
performs various tests to determine if the URL is internal. If yes, it
returns "DIRECT", otherwise it returns a string like
"PROXY proxy-abc1.company.com:8080"

Use that hostname and port for your proxy.

You might have to supply a username and password.

--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous

jal...@gmail.com

unread,
Jun 26, 2008, 2:49:02 PM6/26/08
to
Thanks for all the prompt replys. Pat, I'm curious as to how libcurl
might be used to solve this problem? I'd hate to have all that nasty
code for dealing with windows objects embedded forever in my tcl
code. I'm not against making the user enter a url if autoproxy cannot
discover proxy information from system standard places.

Glenn, my corporate firewall returns a similar .pac file with a
similar FindProxyForURL function. How can this function be called
from tcl?

Sincerely,

Joshua Litt

Alexandre Ferrieux

unread,
Jun 27, 2008, 9:08:55 AM6/27/08
to
Pat, would you be so kind as to answer my question on libcurl ?

-Alex

Glenn Jackman

unread,
Jun 27, 2008, 11:39:20 AM6/27/08
to
At 2008-06-26 02:49PM, "jal...@gmail.com" wrote:
> Glenn, my corporate firewall returns a similar .pac file with a
> similar FindProxyForURL function. How can this function be called
> from tcl?

I don't know -- is there a javascript interpreter written in Tcl?

However, fetching and parsing it is simple:

package require http
set get [http::geturl http://proxy.example.com/proxy.pac]
set contents [http::data $get]
http::cleanup $get
regexp {PROXY (\S+):(\d+)} $contents -> proxy_host proxy_port

Alexandre Ferrieux

unread,
Jun 27, 2008, 12:09:46 PM6/27/08
to
On Jun 27, 5:39 pm, Glenn Jackman <gle...@ncf.ca> wrote:
> At 2008-06-26 02:49PM, "jal...@gmail.com" wrote:
>
> > Glenn, my corporate firewall returns a similar .pac file with a
> > similar FindProxyForURL function. How can this function be called
> > from tcl?
>
> I don't know -- is there a javascript interpreter written in Tcl?

Nope. That's why I mentioned taming Spidermonkey.

> However, fetching and parsing it is simple:

> regexp {PROXY (\S+):(\d+)} $contents -> proxy_host proxy_port

This doesn't work when non-trivial decisions are made by the
Javascript code. Which is my case.

-Alex

jal...@gmail.com

unread,
Jun 27, 2008, 2:17:15 PM6/27/08
to
Okay, taming spidermonkey is one possibility. I also found -
http://browsex.com/jstcl.html , which might be able to do the trick.
The source is available from the site. Maybe I'll get a chance to
play around with that or spidermonkey in the near future. I think
that developing a method of HTTP access behind these large corporate
firewalls would be an asset to the community.

Sincerely,

Joshua Litt

marc spitzer

unread,
Jun 29, 2008, 8:35:57 PM6/29/08
to
On 2008-06-27, Alexandre Ferrieux <alexandre...@gmail.com> wrote:
> Pat, would you be so kind as to answer my question on libcurl ?
>
> -Alex

I am not pat, but with that said, libcurl does not handle javascript.
But it may help you get through the proxies after you use tcl to
strip out the bits needed from the JS you downloaded with libcurl
is my guess.

Thanks,

marc

--
ms4...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Alexandre Ferrieux

unread,
Jun 30, 2008, 2:28:29 AM6/30/08
to
On Jun 30, 2:35 am, marc spitzer <ms4...@sdf.lonestar.org> wrote:

> On 2008-06-27, Alexandre Ferrieux <alexandre.ferri...@gmail.com> wrote:
>
> > Pat, would you be so kind as to answer my question on libcurl ?
>
> > -Alex
>
> I am not pat, but with that said, libcurl does not handle javascript.
> But it may help you get through the proxies after you use tcl to
> strip out the bits needed from the JS you downloaded with libcurl
> is my guess.

Well, that would be orthogonal to the question. Tclcurl and the Tcl's
http package are equally capable in that respect. Only strong
performance requirements and/or specific bugs of the bundled package
may force you to depend on an extension.

-Alex

Neil Madden

unread,
Jul 2, 2008, 4:12:00 PM7/2/08
to

I've also wanted easy access to JavaScript from Tcl before (web-scraping
needs it more and more these days). Well, I didn't feel like hacking
around with SpiderMonkey (the install instructions seemed to start with
a dozen or so dependencies, like most Mozilla stuff...), so I instead
opted to quickly wrap the NJS JavaScript interpreter library
(http://www.njs-javascript.org/), which is lightweight and pretty
decent. I've put the result up at: http://www.cs.nott.ac.uk/~nem/tcl/ as
the "tcljs" package. Note: it's LGPL as that is the license NJS uses
(fine for me). Usage:

package require tcljs 1.0
tcljs js ;# create interpreter instance
js eval {
function foo(a, b) { return a * b; }
foo(12, 23)
}

Should make things pretty simple :-) Note though, that NJS does mention
that it is not an entirely standards-compliant interpreter, so possibly
might fail on some things. Should be fine for proxy .pac files, I'd
guess, though.

I was thinking about adding some more features to this, but then I
remembered that TkHTML also has a JavaScript library -- this time to the
SEE lib. See http://tkhtml.tcl.tk/hv3.html and the file hv3see.c for
details. So, it looks like we are now spoiled for choice of JS
interpreter bindings in Tcl... :-)

Cheers,

-- Neil

Neil Madden

unread,
Jul 2, 2008, 7:34:00 PM7/2/08
to
Neil Madden wrote:
> jal...@gmail.com wrote:
>> Okay, taming spidermonkey is one possibility. I also found -
>> http://browsex.com/jstcl.html , which might be able to do the trick.
>> The source is available from the site. Maybe I'll get a chance to
>> play around with that or spidermonkey in the near future. I think
>> that developing a method of HTTP access behind these large corporate
>> firewalls would be an asset to the community.
>
> I've also wanted easy access to JavaScript from Tcl before (web-scraping
> needs it more and more these days). Well, I didn't feel like hacking
> around with SpiderMonkey (the install instructions seemed to start with
> a dozen or so dependencies, like most Mozilla stuff...), so I instead
> opted to quickly wrap the NJS JavaScript interpreter library
> (http://www.njs-javascript.org/), which is lightweight and pretty
> decent. I've put the result up at: http://www.cs.nott.ac.uk/~nem/tcl/ as
> the "tcljs" package. Note: it's LGPL as that is the license NJS uses
> (fine for me). Usage:
>
> package require tcljs 1.0
> tcljs js ;# create interpreter instance
> js eval {
> function foo(a, b) { return a * b; }
> foo(12, 23)
> }

Turns out, as well as the JS interpreter, you also need to provide some
basic functions for a proxy.pac file (see
http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html).
I've updated the code (same URL as before) to allow registering Tcl
commands as global javascript methods, and then written a simple
proxypac.tcl script (in library/) that has the beginnings of making this
work (seems to work ok on the examples I have at hand).

Hope that is helpful.

Cheers,

Neil

0 new messages