mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
intip changed to intsa
intip changed to intsa for IPv6 use
This commit is contained in:
parent
cce3a94f04
commit
bc7ca3af09
@ -727,7 +727,7 @@ static int h_proxy(int argc, unsigned char ** argv){
|
||||
}
|
||||
|
||||
static int h_internal(int argc, unsigned char ** argv){
|
||||
conf.intip = getip(argv[1]);
|
||||
getip46(46, argv[1], &conf.intsa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,8 @@ struct extparam conf = {
|
||||
NULL, NULL,
|
||||
NONE, NONE,
|
||||
NULL,
|
||||
INADDR_ANY, INADDR_ANY,
|
||||
{AF_INET},
|
||||
INADDR_ANY,
|
||||
0, 0,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -72,6 +72,17 @@ static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
|
||||
if(node->value)(*cbf)(cb, buf, ipprint(buf, *(unsigned *)node -> value));
|
||||
}
|
||||
|
||||
static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
|
||||
#ifdef NOIPV6
|
||||
if(node->value)return pr_ip(node, &((struct sockaddr_in *)node->value)->sin_addr.s_addr)
|
||||
#else
|
||||
char buf[64];
|
||||
*buf = 0;
|
||||
inet_ntop(((struct sockaddr *)node -> value)->sa_family, node->value, buf, sizeof(buf));
|
||||
if(node->value)(*cbf)(cb, buf, strlen(buf));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
|
||||
char buf[16];
|
||||
int i, found = 0;
|
||||
@ -555,8 +566,8 @@ static void * ef_server_targetport(struct node * node){
|
||||
return &((struct srvparam *)node->value) -> targetport;
|
||||
}
|
||||
|
||||
static void * ef_server_intip(struct node * node){
|
||||
return &((struct srvparam *)node->value) -> intip;
|
||||
static void * ef_server_intsa(struct node * node){
|
||||
return &((struct srvparam *)node->value) -> intsa;
|
||||
}
|
||||
|
||||
static void * ef_server_extip(struct node * node){
|
||||
@ -763,7 +774,7 @@ static struct property prop_server[] = {
|
||||
{prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
|
||||
{prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
|
||||
{prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
|
||||
{prop_server + 5, "intip", ef_server_intip, TYPE_IP, "ip address of internal interface"},
|
||||
{prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
|
||||
{prop_server + 6, "extip", ef_server_extip, TYPE_IP, "ip address of external interface"},
|
||||
{prop_server + 7, "intport", ef_server_intport, TYPE_PORT, "port to listen"},
|
||||
{prop_server + 8, "extport", ef_server_extport, TYPE_PORT, "port to use for outgoing connection"},
|
||||
@ -819,6 +830,7 @@ struct datatype datatypes[64] = {
|
||||
{"traffic", NULL, pr_traffic, NULL},
|
||||
{"port", NULL, pr_port, NULL},
|
||||
{"ip", NULL, pr_ip, NULL},
|
||||
{"sa", NULL, pr_sa, NULL},
|
||||
{"cidr", NULL, pr_cidr, NULL},
|
||||
{"string", NULL, pr_string, NULL},
|
||||
{"datetime", NULL, pr_datetime, NULL},
|
||||
|
@ -107,7 +107,7 @@ void * dnsprchild(struct clientparam* param) {
|
||||
unsigned a, b, c, d;
|
||||
sscanf(host, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||
ip = htonl((d<<24) ^ (c<<16) ^ (b<<8) ^ a);
|
||||
if(ip == param->srv->intip){
|
||||
if(param->srv->intsa.ss_family == AF_INET && ip == ((struct sockaddr_in *)¶m->srv->intsa)->sin_addr.s_addr){
|
||||
buf[2] = 0x85;
|
||||
buf[3] = 0x80;
|
||||
buf[6] = 0;
|
||||
|
@ -545,7 +545,8 @@ for(;;){
|
||||
#endif
|
||||
|
||||
if((res = (*param->srv->authfunc)(param))) {RETURN(res);}
|
||||
if (param->sins.sin_addr.s_addr == param->srv->intip && param->sins.sin_port == param->srv->intport) {
|
||||
if (param->srv->intsa.ss_family == AF_INET &&
|
||||
(param->sins.sin_addr.s_addr == ((struct sockaddr_in *)¶m->srv->intsa)->sin_addr.s_addr && param->sins.sin_port == param->srv->intport)) {
|
||||
RETURN(519);
|
||||
}
|
||||
sasize = sizeof(struct sockaddr_in);
|
||||
|
@ -47,10 +47,6 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#ifndef NOIPV6
|
||||
#include <Ws2tcpip.h>
|
||||
|
||||
#endif
|
||||
#ifndef _WINCE
|
||||
#include <io.h>
|
||||
#else
|
||||
@ -319,7 +315,6 @@ extern pthread_mutex_t odbc_mutex;
|
||||
#endif
|
||||
|
||||
extern struct hashtable dns_table;
|
||||
|
||||
extern struct datatype datatypes[64];
|
||||
|
||||
extern struct commands commandhandlers[];
|
||||
|
@ -173,7 +173,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
srv.intip = getip((unsigned char *)argv[i]+2);
|
||||
getip46(46, argv[i]+2, &srv.intsa);
|
||||
break;
|
||||
case 'e':
|
||||
srv.extip = getip((unsigned char *)argv[i]+2);
|
||||
@ -535,8 +535,8 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||
else srv->logformat = (unsigned char *)mystrdup((char *)srv->logformat);
|
||||
}
|
||||
if(srv->logtarget) srv->logtarget = (unsigned char *)mystrdup((char *)srv->logtarget);
|
||||
if(!srv->intip) srv->intip = conf.intip;
|
||||
param->sinc.sin_addr.s_addr = srv->intip;
|
||||
if(!srv->intsa.ss_family) memcpy(&srv->intsa, &conf.intsa, sizeof(srv->intsa));
|
||||
param->sinc.sin_addr.s_addr = ((struct sockaddr_in *)&srv->intsa)->sin_addr.s_addr;
|
||||
param->sinc.sin_port = srv->intport;
|
||||
if(!srv->extip) srv->extip = conf.extip;
|
||||
param->sins.sin_addr.s_addr = param->extip = srv->extip;
|
||||
@ -843,7 +843,9 @@ void freeconf(struct extparam *confp){
|
||||
confp->logtype = NONE;
|
||||
confp->authfunc = ipauth;
|
||||
confp->bandlimfunc = NULL;
|
||||
confp->intip = confp->extip = 0;
|
||||
memset(&confp->intsa, 0, sizeof(confp->intsa));
|
||||
confp->intsa.ss_family = AF_INET;
|
||||
confp->extip = 0;
|
||||
confp->intport = confp->extport = 0;
|
||||
confp->singlepacket = 0;
|
||||
confp->maxchild = 100;
|
||||
|
@ -178,7 +178,7 @@ fflush(stderr);
|
||||
param->clisock = so._socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if(param->clisock == INVALID_SOCKET) {RETURN(11);}
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = param->srv->intip;
|
||||
sin.sin_addr.s_addr = ((struct sockaddr_in *)¶m->srv->intsa)->sin_addr.s_addr;
|
||||
sin.sin_port = htons(0);
|
||||
if(so._bind(param->clisock,(struct sockaddr *)&sin,sizeof(struct sockaddr_in))) {RETURN (12);}
|
||||
#if SOCKSTRACE > 0
|
||||
|
@ -28,6 +28,9 @@ extern "C" {
|
||||
#define INVALID_SOCKET (-1)
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#ifndef NOIPV6
|
||||
#include <Ws2tcpip.h>
|
||||
#endif
|
||||
#define pthread_mutex_t CRITICAL_SECTION
|
||||
#define pthread_mutex_init(x, y) InitializeCriticalSection(x)
|
||||
#define pthread_mutex_lock(x) EnterCriticalSection(x)
|
||||
@ -330,7 +333,7 @@ struct srvparam {
|
||||
int nfilters, nreqfilters, nhdrfilterscli, nhdrfilterssrv, npredatfilters, ndatfilterscli, ndatfilterssrv;
|
||||
unsigned bufsize;
|
||||
unsigned logdumpsrv, logdumpcli;
|
||||
unsigned long intip;
|
||||
struct sockaddr_storage intsa;
|
||||
unsigned long extip;
|
||||
pthread_mutex_t counter_mutex;
|
||||
struct pollfd fds;
|
||||
@ -451,7 +454,8 @@ struct extparam {
|
||||
unsigned char *logname, **archiver;
|
||||
ROTATION logtype, countertype;
|
||||
char * counterfile;
|
||||
unsigned long intip, extip;
|
||||
struct sockaddr_storage intsa;
|
||||
unsigned long extip;
|
||||
unsigned short intport, extport;
|
||||
struct passwords *pwl;
|
||||
struct auth * authenticate;
|
||||
@ -659,6 +663,7 @@ typedef enum {
|
||||
TYPE_TRAFFIC,
|
||||
TYPE_PORT,
|
||||
TYPE_IP,
|
||||
TYPE_SA,
|
||||
TYPE_CIDR,
|
||||
TYPE_STRING,
|
||||
TYPE_DATETIME,
|
||||
|
Loading…
Reference in New Issue
Block a user