hi,
i just tried running xenofarm on one of my machines in vienna, then i noticed that there is a problem because i am behind a http proxy. setting $http_proxy does not seem to be enough, and grepping through the source i could not find any reference to proxy support either.
what does it take to get xenofarm to run behind a http proxy?
greetings, martin.
1) Check out the source code to put.c from CVS. 2) Implement proxy support. 3) Send patch to ZinO.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-11-15 22:34: Subject: xenofarm proxy
hi,
i just tried running xenofarm on one of my machines in vienna, then i noticed that there is a problem because i am behind a http proxy. setting $http_proxy does not seem to be enough, and grepping through the source i could not find any reference to proxy support either.
what does it take to get xenofarm to run behind a http proxy?
greetings, martin.
/ Brevbäraren
ok, i hacked something together. it should be working, at least it generates a correct request:
Resending rescue_default/SunNov16090932MET2003/xenofarm_result.tar.gz. Proxy: http://proxy Realhost: pike.ida.liu.se Host: proxy File: generated/pikefarm/packages/7.5/result Port: 1110 flen: 5482 IP : 192.168.0.41 Connecting...done sending request..Request: PUT http://pike.ida.liu.se/generated/pikefarm/packages/7.5/result HTTP/1.0 Host: pike.ida.liu.se User-Agent: simple-put Content-Type: application/octet-stream Content-Length: 5482
done sending data..done Reading reply...Timeout Failed to resend. Resending in the next client run.
the question is, why is there no reply coming back? can someone check what happened on your end? (i tried testing on my own server, but caudium sends back HTTP/1.1 100 Continue which this simple put does not cope with.
greetings, martin.
Index: put.c =================================================================== RCS file: /cvsroot/xenofarm/xenofarm/client/put.c,v retrieving revision 1.14 diff -u -r1.14 put.c --- put.c 12 Jan 2003 21:14:16 -0000 1.14 +++ put.c 16 Nov 2003 17:25:49 -0000 @@ -54,7 +54,7 @@ void put_file( char *url, int len ) { int i, port=80, fd; - char *host, *file, *id, buffer[4711], buffer2[1024], *p; + char *host, *file, *id, buffer[4711], buffer2[1024], *p, *proxy, *realhost; struct hostent *hent; struct sockaddr_in addr; if( strncmp( url, "http://", 7 ) ) @@ -62,14 +62,32 @@ printf("Only HTTP urls are supported\n"); exit(1); } + + proxy=getenv("http_proxy"); + id = 0; - host = url + 7; - for( i = 0; i<strlen(host); i++ ) - if( host[i] == '/' ) - { - file = host+i+1; - host[i]=0; - } + if(strlen(proxy)>7) + { + host = proxy + 7; + realhost = url + 7; + for( i = 0; i<strlen(realhost); i++ ) + if( realhost[i] == '/' ) + { + file = realhost+i+1; + realhost[i]=0; + } + } + else + { + host = url + 7; + + for( i = 0; i<strlen(host); i++ ) + if( host[i] == '/' ) + { + file = host+i+1; + host[i]=0; + } + }
for( i = 0; i<strlen(host); i++ ) if( host[i] == '@' ) @@ -88,6 +106,8 @@ break; }
+ printf("Proxy: %s\n", proxy ); + printf("Realhost: %s\n", realhost ); printf("Host: %s\n", host ); printf("File: %s\n", file ); printf("Port: %d\n", port ); @@ -148,16 +168,26 @@ printf("sending request.." ); fflush(stdout);
- sprintf( buffer, + if(strlen(proxy)>7) + sprintf( buffer, + "PUT http://%s/%s HTTP/1.0\r\n" + "Host: %s\r\n%s" + "User-Agent: simple-put\r\n" + "Content-Type: application/octet-stream\r\n" + "Content-Length: %d\r\n" + "\r\n", + realhost, file, realhost, buffer2, len ); + else + sprintf( buffer, "PUT /%s HTTP/1.0\r\n" "Host: %s:%d\r\n%s" "User-Agent: simple-put\r\n" "Content-Type: application/octet-stream\r\n" "Content-Length: %d\r\n" "\r\n", - file, host, port, buffer2, len );
+ printf("Request:\n%s\n", buffer);
i = strlen(buffer); p = buffer;
- proxy=getenv("http_proxy");
Ok, so if $http_proxy is not set, then proxy will be NULL.
- if(strlen(proxy)>7)
But then you can't call strlen() on it here.
- printf("Proxy: %s\n", proxy );
Or print it here.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-11-16 18:29: Subject: Re: xenofarm proxy patch
Index: put.c
RCS file: /cvsroot/xenofarm/xenofarm/client/put.c,v retrieving revision 1.14 diff -u -r1.14 put.c --- put.c 12 Jan 2003 21:14:16 -0000 1.14 +++ put.c 16 Nov 2003 17:25:49 -0000 @@ -54,7 +54,7 @@ void put_file( char *url, int len ) { int i, port=80, fd;
- char *host, *file, *id, buffer[4711], buffer2[1024], *p;
- char *host, *file, *id, buffer[4711], buffer2[1024], *p, *proxy, *realhost; struct hostent *hent; struct sockaddr_in addr; if( strncmp( url, "http://", 7 ) )
@@ -62,14 +62,32 @@ printf("Only HTTP urls are supported\n"); exit(1); }
- proxy=getenv("http_proxy");
- id = 0;
- host = url + 7;
- for( i = 0; i<strlen(host); i++ )
- if( host[i] == '/' )
- {
file = host+i+1;
host[i]=0;
- }
if(strlen(proxy)>7)
{
host = proxy + 7;
realhost = url + 7;
for( i = 0; i<strlen(realhost); i++ )
if( realhost[i] == '/' )
{
file = realhost+i+1;
realhost[i]=0;
}
}
else
{
host = url + 7;
for( i = 0; i<strlen(host); i++ )
if( host[i] == '/' )
{
file = host+i+1;
host[i]=0;
}
}
for( i = 0; i<strlen(host); i++ ) if( host[i] == '@' )
@@ -88,6 +106,8 @@ break; }
- printf("Proxy: %s\n", proxy );
- printf("Realhost: %s\n", realhost ); printf("Host: %s\n", host ); printf("File: %s\n", file ); printf("Port: %d\n", port );
@@ -148,16 +168,26 @@ printf("sending request.." ); fflush(stdout);
- sprintf( buffer,
- if(strlen(proxy)>7)
- sprintf( buffer,
"PUT http://%s/%s HTTP/1.0\r\n"
"Host: %s\r\n%s"
"User-Agent: simple-put\r\n"
"Content-Type: application/octet-stream\r\n"
"Content-Length: %d\r\n"
"\r\n",
realhost, file, realhost, buffer2, len );
- else
- sprintf( buffer, "PUT /%s HTTP/1.0\r\n" "Host: %s:%d\r\n%s" "User-Agent: simple-put\r\n" "Content-Type: application/octet-stream\r\n" "Content-Length: %d\r\n" "\r\n",
file, host, port, buffer2, len );
printf("Request:\n%s\n", buffer);
i = strlen(buffer); p = buffer;
/ Brevbäraren
it has been at least 5 or 6 years since i last touched c. can i test just test
if(proxy)
?
greetings, martin.
good then simply remove strlen from the check, and remove that unchecked printf (it's not needed anyways)
greetings, martin.
pike-devel@lists.lysator.liu.se