mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 10:35:40 +08:00
Merge remote-tracking branch 'refs/remotes/origin/devel'
This commit is contained in:
commit
69cb310481
27
src/common.c
27
src/common.c
@ -648,7 +648,6 @@ int doconnect(struct clientparam * param){
|
||||
}
|
||||
else {
|
||||
struct linger lg = {1,conf.timeouts[SINGLEBYTE_S]};
|
||||
int opt = 1;
|
||||
|
||||
if(SAISNULL(¶m->sinsr)){
|
||||
if(SAISNULL(¶m->req)) {
|
||||
@ -660,26 +659,38 @@ int doconnect(struct clientparam * param){
|
||||
if(!*SAPORT(¶m->sinsr))*SAPORT(¶m->sinsr) = *SAPORT(¶m->req);
|
||||
if ((param->remsock=so._socket(SASOCK(¶m->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
|
||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg));
|
||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
||||
#ifdef REUSE
|
||||
{
|
||||
int opt;
|
||||
|
||||
#ifdef SO_REUSEADDR
|
||||
opt = 1;
|
||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
||||
#endif
|
||||
#ifdef SO_REUSEPORT
|
||||
opt = 1;
|
||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NOIPV6
|
||||
if(*SAFAMILY(¶m->sinsr) == AF_INET6) memcpy(¶m->sinsl, ¶m->srv->extsa6, sizeof(param->srv->extsa6));
|
||||
else
|
||||
#endif
|
||||
memcpy(¶m->sinsl, ¶m->srv->extsa, sizeof(param->srv->extsa));
|
||||
if (param->srv->targetport && !*SAPORT(¶m->sinsl) && ntohs(*SAPORT(¶m->sincr)) > 1023) *SAPORT(¶m->sinsl) = *SAPORT(¶m->sincr);
|
||||
*SAPORT(¶m->sinsl) = 0;
|
||||
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
||||
*SAPORT(¶m->sinsl) = 0;
|
||||
if(so._bind(param->remsock, (struct sockaddr*)¶m->sinsl, SASIZE(¶m->sinsl))==-1) {
|
||||
return 12;
|
||||
}
|
||||
return 12;
|
||||
}
|
||||
|
||||
if(param->operation >= 256 || (param->operation & CONNECT)){
|
||||
#ifdef _WIN32
|
||||
unsigned long ul = 1;
|
||||
#endif
|
||||
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,sizeof(param->sinsr))) {return (13);}
|
||||
if(so._connect(param->remsock,(struct sockaddr *)¶m->sinsr,sizeof(param->sinsr))) {
|
||||
return (13);
|
||||
}
|
||||
param->nconnects++;
|
||||
#ifdef _WIN32
|
||||
ioctlsocket(param->remsock, FIONBIO, &ul);
|
||||
|
@ -293,6 +293,7 @@ for(;;){
|
||||
RETURN(511);
|
||||
}
|
||||
if(buf[i-3] == '1') keepalive = 2;
|
||||
param->transparent = 0;
|
||||
if((isconnect = !strncasecmp((char *)buf, "CONNECT", 7))) keepalive = 2;
|
||||
|
||||
if ((sb=(unsigned char *)(unsigned char *)strchr((char *)buf, ' ')) == NULL) {RETURN(512);}
|
||||
|
14
src/socks.c
14
src/socks.c
@ -179,6 +179,20 @@ void * sockschild(struct clientparam* param) {
|
||||
#endif
|
||||
if ((param->remsock=so._socket(SASOCK(¶m->req), command == 2? SOCK_STREAM:SOCK_DGRAM, command == 2?IPPROTO_TCP:IPPROTO_UDP)) == INVALID_SOCKET) {RETURN (11);}
|
||||
param->operation = command == 2?BIND:UDPASSOC;
|
||||
#ifdef REUSE
|
||||
if (command == 2){
|
||||
int opt;
|
||||
|
||||
#ifdef SO_REUSEADDR
|
||||
opt = 1;
|
||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int));
|
||||
#endif
|
||||
#ifdef SO_REUSEPORT
|
||||
opt = 1;
|
||||
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user