rtoss

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/ @ 348  →  / @ 349
/httptunnel/common.h
@@ -115,6 +115,7 @@
ssize_t n, m;
char *wdata = data;
 
// log_annoying ("write (%s, %d) ...", wdata, len);
for (n = 0; n < len; n += m)
{
log_annoying ("write (%d, %p, %d) ...", fd, wdata + n, len - n);
/httptunnel/tunnel.c
@@ -1337,6 +1337,7 @@
tunnel->dest.proxy_port = proxy_port;
tunnel->dest.proxy_authorization = NULL;
tunnel->dest.user_agent = NULL;
tunnel->dest.uri = NULL;
/* -1 to allow for TUNNEL_DISCONNECT */
tunnel->content_length = content_length - 1;
tunnel->buf_ptr = tunnel->buf;
@@ -1441,6 +1442,24 @@
return -1;
}
}
else if (strcmp (opt, "uri") == 0)
{
if (get_flag)
{
if (tunnel->dest.uri == NULL)
*(char **)data = NULL;
else
*(char **)data = strdup (tunnel->dest.uri);
}
else
{
if (tunnel->dest.uri != NULL)
free ((char *)tunnel->dest.uri);
tunnel->dest.uri = strdup ((char *)data);
if (tunnel->dest.uri == NULL)
return -1;
}
}
else
{
errno = EINVAL;
/httptunnel/htc.c
@@ -40,6 +40,7 @@
int max_connection_age;
char *proxy_authorization;
char *user_agent;
char *uri;
} Arguments;
 
#define NO_PROXY_BUFFER 0
@@ -85,6 +86,7 @@
" -T, --timeout TIME timeout, in milliseconds, before sending\n"
" padding to a buffering proxy\n"
" -U, --user-agent STRING specify User-Agent value in HTTP requests\n"
" -i, --uri STRING specify URI in HTTP request (default: index.html?crap)\n"
" -V, --version output version information and exit\n"
" -w, --no-daemon don't fork into the background\n"
"\n"
@@ -137,6 +139,7 @@
arg->max_connection_age = DEFAULT_CONNECTION_MAX_TIME;
arg->proxy_authorization = NULL;
arg->user_agent = NULL;
arg->uri = NULL;
 
for (;;)
{
@@ -158,6 +161,7 @@
{ "timeout", required_argument, 0, 'T' },
{ "keep-alive", required_argument, 0, 'k' },
{ "user-agent", required_argument, 0, 'U' },
{ "uri", required_argument, 0, 'i' },
{ "forward-port", required_argument, 0, 'F' },
{ "content-length", required_argument, 0, 'c' },
{ "strict-content-length", no_argument, 0, 'S' },
@@ -168,7 +172,7 @@
{ 0, 0, 0, 0 }
};
 
static const char *short_options = "A:B:c:d:F:hk:M:P:sST:U:Vwz:"
static const char *short_options = "A:B:c:d:F:hk:M:P:sST:U:i:Vwz:"
#ifdef DEBUG_MODE
"D:l:"
#endif
@@ -229,6 +233,10 @@
arg->forward_port = atoi (optarg);
break;
 
case 'i':
arg->uri = optarg;
break;
 
case 'k':
arg->keep_alive = atoi (optarg);
break;
@@ -444,6 +452,7 @@
log_notice (" proxy_authorization = %s",
arg.proxy_authorization ? arg.proxy_authorization : "(null)");
log_notice (" user_agent = %s", arg.user_agent ? arg.user_agent : "(null)");
log_notice (" uri = %s", arg.uri ? arg.uri : "index.html?crap");
log_notice (" debug_level = %d", debug_level);
 
 
@@ -599,6 +608,13 @@
strerror (errno));
}
 
if (arg.uri != NULL)
{
if (tunnel_setopt (tunnel, "uri", arg.uri) == -1)
log_error ("tunnel_setopt uri error: %s",
strerror (errno));
}
 
if (tunnel_connect (tunnel) == -1)
{
log_error ("couldn't open tunnel: %s", strerror (errno));
/httptunnel/http.c
@@ -31,13 +31,14 @@
n = 0;
if (dest->proxy_name != NULL)
n = sprintf (str, "http://%s:%d", dest->host_name, dest->host_port);
sprintf (str + n, "/index.html?crap=%ld", time (NULL));
sprintf (str + n, "/%s=%ld", ((dest->uri != NULL) ? dest->uri : "index.html?crap"), time (NULL));
 
request = http_create_request (method, str, 1, 1);
if (request == NULL)
return -1;
 
sprintf (str, "%s:%d", dest->host_name, dest->host_port);
// sprintf (str, "%s:%d", dest->host_name, dest->host_port);
sprintf (str, "%s", dest->host_name);
http_add_header (&request->header, "Host", str);
 
if (length >= 0)
/httptunnel/http.h
@@ -53,6 +53,7 @@
int proxy_port;
const char *proxy_authorization;
const char *user_agent;
const char *uri;
} Http_destination;
 
extern ssize_t http_get (int fd, Http_destination *dest);