Closed
Bug 497198
Opened 16 years ago
Closed 16 years ago
POP3/SMTP/IMAP/NNTP through proxy
Categories
(Thunderbird :: General, enhancement)
Thunderbird
General
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 264981
People
(Reporter: lenik, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10
Build Identifier: 2.0.0.21
As in the RFC2817, article 5.2, it is possible to connect to the various network services through proxy using HTTS CONNECT method.
At this time Thunderbird supports SOCKS proxy only.
I think that the HTTPS CONNECT method support will help Thunderbird to be more popular in the world.
Reproducible: Always
Steps to Reproduce:
unable to connect to the POP3/SMTP servers through HTTP proxy that support CONNECT method as in the RFC2817.
Expected Results:
Check out some C source in additional information block. Such source demonstrates how to connect to the network server through HTTP proxy.
#include <windows.h>
#include <stdio.h>
#include <time.h>
#define CODEBLOCK
static unsigned long getaddressandport(unsigned char *str,unsigned char *addr,unsigned long *port)
{
unsigned char *cptr = addr;
while(1)
{
if(str[0] == 0)break;
if(str[0] == ':')break;
cptr[0] = str[0];
str++;
cptr++;
cptr[0] = 0;
}
if(str[0] == ':')
{
str++;
*port = atoi(str);
return(0);
}
return(1);
}
static unsigned long _sendhttpconnect(int skt,char *targetaddress,unsigned long targetport)
{
static unsigned char request[] = "CONNECT %s:%lu HTTP/1.1\r\n"
"Host: %s:%lu\r\n\r\n";
unsigned char buffer[2048];
unsigned long blen;
sprintf(buffer,request,targetaddress,targetport,targetaddress,targetport);
blen = strlen(buffer);
printf("Proxy Request:[%s]\n",buffer);
if(send(skt,buffer,blen,0) == blen)return(0);
return(1);
}
static unsigned long _recvhttpresponse(int skt)
{
unsigned char buffer[2048];
unsigned long blen,bc;
unsigned long retcode = 504;
buffer[0] = 0;
blen = 0;
while(1)
{
bc = recv(skt,&(buffer[blen]),sizeof(buffer)-blen-2,0);
if((bc == SOCKET_ERROR)||(bc == 0))break;
blen += bc;
buffer[blen] = 0;
if(strstr(buffer,"\r\n\r\n") != NULL)break;
}
printf("Proxy response:[%s]\n",buffer);
CODEBLOCK
{
unsigned char *cptr;
cptr = buffer;
while((cptr[0] != 0)&&(cptr[0] != ' '))cptr++;
if(cptr[0] == ' ')
{
cptr++;
retcode = atoi(cptr);
}
}
return(retcode);
}
static unsigned long recvstring(int skt,unsigned char *buffer,unsigned long maxbufsize)
{
unsigned long l,bc;
l = 0;
while(1)
{
bc = recv(skt,&(buffer[l]),maxbufsize-2,0);
if((bc == SOCKET_ERROR)||(bc == 0))break;
l += bc;
buffer[l] = 0;
//printf("[%s]\n",buffer);
//fflush(stdout);
if(buffer[l-1] == '\n')return(0);
}
return(1);
}
static unsigned long do_protocol(int skt)
{
unsigned char reqbuf[512];
unsigned char repbuf[512];
unsigned long len;
if(recvstring(skt,repbuf,sizeof(repbuf)) == 0)
{
while(1)
{
gets(reqbuf);
printf("SEND->[%s]\n",reqbuf);
fflush(stdout);
strcat(reqbuf,"\n");
len = strlen(reqbuf);
if(send(skt,reqbuf,len,0) != len)break;
if(recvstring(skt,repbuf,sizeof(repbuf)) != 0)
{
printf("Session terminated.\n");
fflush(stdout);
break;
}
printf("RECV->[%s]",repbuf);
fflush(stdout);
}
return(0);
}
return(1);
}
static unsigned char proxyaddress[256];
static unsigned char targetaddress[256];
static unsigned long proxyport = 0;
static unsigned long targetport = 0;
void main(unsigned long argc,unsigned char **argv)
{
WSADATA wsaData;
unsigned long code=0;
int skt;
SOCKADDR_IN sin;
struct hostent *she;
if(argc < 3)printf("use: proxyconnect proxy:proxyport target:targetport\n");
else{
code = 0;
code += getaddressandport(argv[1],proxyaddress,&proxyport);
code += getaddressandport(argv[2],targetaddress,&targetport);
if(code == 0)
{
printf("Connecting to %s:%lu through %s:%lu\n",targetaddress,targetport,proxyaddress,proxyport);
fflush(stdout);
if(WSAStartup(0x0101,&wsaData) == 0)
{
if((skt=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) != INVALID_SOCKET)
{
sin.sin_family = AF_INET;
if((sin.sin_addr.s_addr=inet_addr(proxyaddress)) == INADDR_NONE)
{
if((she=gethostbyname(proxyaddress)) != NULL)
{
sin.sin_addr.s_addr = *((unsigned long*)she->h_addr_list[0]);
}
else sin.sin_addr.s_addr = INADDR_NONE;
}
if(sin.sin_addr.s_addr != INADDR_NONE)
{
sin.sin_port = htons(proxyport);
if(connect(skt,(LPSOCKADDR)&sin,sizeof(sin)) == 0)
{
printf("proxy connected.\n");
fflush(stdout);
if(_sendhttpconnect(skt,targetaddress,targetport) == 0)
{
printf("request sent.\n");
fflush(stdout);
if(_recvhttpresponse(skt) == 200)
{
printf("200 reply received, continue session.\n");
fflush(stdout);
do_protocol(skt);
}
}
}
else printf("connect() failed\n");
}
else printf("unable to resolve %s\n",proxyaddress);
}
else printf("socket() failed\n");
WSACleanup();
}
else printf("WSAStartup() failed\n");
}
else printf("invalid command line\n");
}
}
Comment 1•16 years ago
|
||
Old request. The issue was something with authentication, as I seem to recall.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
No, this is a new request. Please note that i have described how this may be done.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
Comment 3•16 years ago
|
||
(In reply to comment #2)
> No, this is a new request. Please note that i have described how this may be
> done.
Then please explain what is different between that request and your request, apart from your additional description. To me these bugs look to be asking for the same thing - http proxy support - and therefore yours is still a duplicate of bug 264981 even if it is "new" in the sense you only just filed it.
Comment 4•16 years ago
|
||
(In reply to comment #3)
> (In reply to comment #2)
> > No, this is a new request. Please note that i have described how this may be
> > done.
>
> Then please explain what is different between that request and your request,
> apart from your additional description. To me these bugs look to be asking for
> the same thing - http proxy support - and therefore yours is still a duplicate
> of bug 264981 even if it is "new" in the sense you only just filed it.
I might add - that you seem to provide some code in comment #0 - how about providing a patch for bug 264981 ? :-)
Comment 5•16 years ago
|
||
Since there has been no rationale for keeping this not a duplicate, I'm going to reduplicate it.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago → 16 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•