ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2009年2月3日 星期二

Git behind proxy

在公司用 git,因為有 proxy,所以找了一下,大部分都是說加上 http_proxy 環境變數後,原來是 git:// 的,改為 http:// 就可以了。 但是 這個是 repo,所以不能這樣用。 找到一篇:repo behine proxy copy 一下內容:
Basically the steps are:
1 - sudo apt-get install socket
2 - in your home directory, put a shell script called "proxy-cmd.sh"
containing (replace YOUR_PROXY and YOUR_PROXY_PORT with your own proxy
parameters):
#! /bin/bash
(echo "CONNECT $1:$2 HTTP/1.0"; echo; cat ) | socket YOUR_PROXY
YOUR_PROXY_PORT | (read a; read a; cat )
3 - chmod +x proxy-cmd.sh
4 - export GIT_PROXY_COMMAND=<PATH TO YOUR SCRIPT>/proxy-cmd.sh

Enjoy,
Matthieu

PS: you can export GIT_PROXY_COMMAND in your ~/.bashrc file to make
this permanent 
還沒確認有沒有效...
這一篇有說明 socket command : git via a proxy server
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Date: 2006-05-18 18:31:32

On Wed, 2006-05-17 20:44:28 -0700, Sam Song <samlinuxkernel@yahoo.com> wrote:
> Petr Vandrovec <petr@vmware.com> wrote:
> > Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> > > Well, install some package to have `socket'
> > > available? Debian calls
> > > the packet `socket', too, so I guess Fedora may
> > > have something similar.
> >
> > Surprisingly they do not...  You should be able to
> > replace 'socket' with
> > 'netcat' - and I believe that netcat/nc package is
> > available for Fedora.  For
> > this purpose they have same command line & behavior.
>
> Ummm, I am trying on that. nc is avaiable for Fedora.
> But what could be the replacement for CONNECT in
> Fedora? :-)

Erm, you haven't understood what you're doing there, have you?

With the GIT_PROXY_COMMAND helper, you're expected to create a clean
tunnel which in turn git can use to transfer its data.

You've only got some limited internet connectivity via a HTTP proxy
available, so you need to use this. This means:

 * The proxy administrator needs to allos outgoing connections for
   the CONNECT method with git's TCP port.
 * You need to have some minimalistic program to initially speak HTTP
   with the proxy and later on just stream the raw git protocol
   through the link.
 * You may or may not need to strip anything that came into the git
   stream by accident because you tunnled it through a HTTP proxy. A
   reply message from the proxy server is an example for this.

So this little script (using "CONNECT" and netcat or socket) does the
first part: it talks in the language HTTP with the proxy server. It
may be enough to just use CONNECT, but you may need to speak some more
lines, eg. for proxy authorization.

The first `cat' in there is just for pushing the git protocol though the
HTTP proxy connection later on (hopefully after the proxy was made to
accept the the CONNECT request.)  Once the proxy accepted it, it'll
send you a HTTP/200 message (or something like that) and an empty
line. This is what the two reads are for; the next `cat' simply again
transfers all the rest (the git protocol).

To draw the line, there's not _one_ solution to HTTP proxy tunneling,
there are many, and you'll need to design one that fits your network.
It should be quite simple, given that you've got nice tools like
`strace' and `tcpdump', which will help you to understand how the
proxy reacts and so on.

MfG, JBG

--
Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


結果...
charles-chang@rbtlegacy:~/android-eee$ repo init -u git://android.git.kernel.org/platform/manifest.git
Getting repo ...
   from git://android.git.kernel.org/tools/repo.git
fatal: protocol error: bad line length character
所以是 Fail... 不知道是不是公司的squid proxy 不允許 CONNECT 這個 operation. 同樣的一篇有說:
Note: most HTTP proxy servers allow CONNECT method to a very limited
range of ports, and administrators will need to enable the git port
(9418) explicitly. 
所以要問 MIS 有沒有 允許 CONNECT method和開啟 git 要用的 9418 port。

沒有留言:

標籤

網誌存檔