From: Joel Becker <Joel.Becker@oracle.com>
To: Junio C Hamano <junkio@cox.net>
Cc: lamikr <lamikr@cc.jyu.fi>, git@vger.kernel.org
Subject: Re: undoing changes with git-checkout -f
Date: Mon, 9 Jan 2006 22:32:47 -0800 [thread overview]
Message-ID: <20060110063247.GP18439@ca-server1.us.oracle.com> (raw)
In-Reply-To: <7vk6d8aaln.fsf@assigned-by-dhcp.cox.net>
[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]
On Mon, Jan 09, 2006 at 09:57:40PM -0800, Junio C Hamano wrote:
> Joel Becker <Joel.Becker@oracle.com> writes:
> > Can we teach the git:// fetch program to use CONNECT over HTTP
> > proxies? rsync can do this, but git:// cannot, so firewalls that block
> > 9418 mean we use rsync://
> > I'm mostly offline this week or I'd take a stab at it.
>
> It's been there for quite some time, although I never liked the
> way it interfaces with the outside world.
>
Ugly snipped...
> It is a bit inconvenient that "git clone" wrapper cannot be used
> on an existing repository, and without an existing repository
> you cannot have .git/config. You could have the config file in
> your site-wide template area, but admittably it is a bit
> awkward.
Here's what I did. I modified the usual
ssh-tunnel-over-SSL-CONNECT script to honor http_proxy. I've attached
it. With this, I do as so:
# cp git-tunnel.pl /usr/local/bin
# export http_proxy="http://my-proxy.my.com:80/"
# GIT_PROXY_COMMAND="/usr/local/bin/git-tunnel.pl" git clone git://git.kernel.org/pub/scm/... localsource
# cd localsource
# vi .git/config
[core]
gitproxy = /usr/local/bin/git-tunnel.pl
This is working for me. I'd really rather have the tunneling
code be part of connect.c, and have core.proxymethod=external use the
current core.gitproxy method and core.proxymethod=http use $http_proxy.
But this will suffice for now :-)
Joel
--
Life's Little Instruction Book #198
"Feed a stranger's expired parking meter."
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
[-- Attachment #2: git-tunnel.pl --]
[-- Type: text/x-perl, Size: 2667 bytes --]
#!/usr/bin/perl
#
# git-tunnel.pl
#
# Usage: git-tunnel.pl ssl-proxy port destination_host port
#
# This script can be used by git as a "core.gitproxy" to
# traverse a www-proxy/firewall that supports the http CONNECT
# command described in
# http://home.netscape.com/newsref/std/tunneling_ssl.html
#
# It uses the http_proxy (or HTTP_PROXY) variable to determine the
# proxy to connect to. Put the path to this script in the environment
# variable GIT_PROXY_COMMAND, or better yet, insert the core.gitproxy
# definition in .git/config.
#
# .
# .
# [core]
# gitproxy = /path/to/git-tunnel.pl
# .
# .
#
# Written by Urban Kaveus <urban@statt.ericsson.se>
# Modified to use http_proxy by Joel Becker <joel.becker@oracle.com>
use Socket;
# Parse command line arguments
if ( $#ARGV != 1 ) {
print STDERR "Usage: $0 destination port\n";
print STDERR $#ARGV, "\n";
exit(1);
}
$proxy_url = $ENV{'http_proxy'};
if (!$proxy_url) {
$proxy_url = $ENV{'HTTP_PROXY'};
}
$proxyport = 80;
if ($proxy_url =~ /^https?:\/\/([^:]+)\/$/) {
$sslproxy = $1;
} elsif ($proxy_url =~ /^https?:\/\/([^:]+):([1-9][0-9]*)\/$/) {
$sslproxy = $1;
$proxyport = $2;
} else {
print STDERR "Invalid proxy specification: \"$proxy_url\"\n";
exit(1);
}
$destination = shift;
$destport = shift;
# Set up network communication
($protocol) = (getprotobyname("tcp"))[2];
($proxyip) = (gethostbyname($sslproxy))[4];
$localaddr = pack('S n a4 x8', &AF_INET, 0, "\0\0\0\0");
$proxyaddr = pack('S n a4 x8', &AF_INET, $proxyport, $proxyip);
socket (PROXY, &AF_INET, &SOCK_STREAM, $protocol) or
die("Failed to create cocket");
bind (PROXY, $localaddr) or
die("Failed to bind socket");
connect (PROXY, $proxyaddr) or
die("Failed to connect to $sslproxy port $proxyport");
# Force flushing of socket buffers
select (PROXY); $| = 1;
select (STDOUT); $| = 1;
# Send a "CONNECT" command to proxy:
print PROXY "CONNECT $destination:$destport HTTP/1.1\r\n\r\n";
# Wait for HTTP status code, bail out if you don't get back a 2xx code.
$_ = <PROXY>;
($status) = (split())[1];
die("Received a bad status code \"$status\" from proxy server")
if ( int($status/100) != 2 );
# Skip through remaining part of MIME header
while(<PROXY>) {
chomp; # Strip <LF>
last if /^[\r]*$/; # Empty line or a single <CR> left
}
# Start copying packets in both directions.
if($child = fork) { # Parent process
while (sysread(STDIN,$_,4096)) {
print PROXY;
}
sleep 2;
kill(15,$child) if $child;
}
else { # Child process
while (sysread(PROXY,$_,4096)) {
print STDOUT;
}
}
next prev parent reply other threads:[~2006-01-10 6:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-09 21:16 undoing changes with git-checkout -f lamikr
2006-01-09 21:46 ` Junio C Hamano
2006-01-09 22:52 ` lamikr
2006-01-10 4:55 ` Joel Becker
2006-01-10 5:57 ` Junio C Hamano
2006-01-10 6:32 ` Joel Becker [this message]
2006-01-10 7:18 ` Joel Becker
2006-01-10 7:42 ` Junio C Hamano
2006-01-10 8:16 ` Joel Becker
2006-01-10 14:51 ` Johannes Schindelin
2006-01-10 16:17 ` Alex Riesen
2006-01-10 16:45 ` Johannes Schindelin
2006-01-10 17:32 ` Alex Riesen
[not found] ` <Pine.LNX.4.64.0601091321390.5588@g5.osdl.org>
2006-01-09 22:36 ` lamikr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060110063247.GP18439@ca-server1.us.oracle.com \
--to=joel.becker@oracle.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=lamikr@cc.jyu.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.