mirror of
				https://github.com/3proxy/3proxy.git
				synced 2025-11-04 07:42:39 +08:00 
			
		
		
		
	Support IPv6 subnets in parent extip
This commit is contained in:
		
							parent
							
								
									34e63ed37c
								
							
						
					
					
						commit
						5861de176e
					
				
							
								
								
									
										18
									
								
								src/auth.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/auth.c
									
									
									
									
									
								
							@ -253,6 +253,24 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
 | 
			
		||||
			if(cur->type == R_EXTIP){
 | 
			
		||||
				param->sinsl = cur->addr;
 | 
			
		||||
				if(SAISNULL(¶m->sinsl))param->sinsl = param->sincr;
 | 
			
		||||
#ifndef NOIPV6
 | 
			
		||||
				else if(cur->cidr && *SAFAMILY(¶m->sinsl) == AF_INET6){
 | 
			
		||||
					char c;
 | 
			
		||||
					int i;
 | 
			
		||||
 | 
			
		||||
					for(i = 0; i < 16; i++){
 | 
			
		||||
						if(i%8)myrand(¶m->sincr, sizeof(param->sincr));
 | 
			
		||||
						else if(i%4) myrand(¶m->req, sizeof(param->req));
 | 
			
		||||
 | 
			
		||||
						if(i*8 >= cur->cidr) ((char *)SAADDR(¶m->sinsl))[i] = rand();
 | 
			
		||||
						else if ((i+1)*8 >  cur->cidr){
 | 
			
		||||
							c = rand();
 | 
			
		||||
							c >>= (cur->cidr - (i*8));
 | 
			
		||||
							((char *)SAADDR(¶m->sinsl))[i] |= c;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
#endif
 | 
			
		||||
				if(cur->next)continue;
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -141,13 +141,13 @@ char* NULLADDR="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
 | 
			
		||||
 | 
			
		||||
int myrand(void * entropy, int len){
 | 
			
		||||
	int i;
 | 
			
		||||
	unsigned short init;
 | 
			
		||||
	uint16_t init;
 | 
			
		||||
 | 
			
		||||
	init = randomizer;
 | 
			
		||||
	for(i=0; i < len/2; i++){
 | 
			
		||||
		init ^= ((unsigned short *)entropy)[i];
 | 
			
		||||
		init ^= ((uint16_t *)entropy)[i];
 | 
			
		||||
	}
 | 
			
		||||
	srand(init);
 | 
			
		||||
	srand(rand()+init);
 | 
			
		||||
	randomizer = rand();
 | 
			
		||||
	return rand();
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								src/conf.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/conf.c
									
									
									
									
									
								
							@ -608,6 +608,7 @@ static int h_monitor(int argc, char **argv){
 | 
			
		||||
static int h_parent(int argc, char **argv){
 | 
			
		||||
  struct ace *acl = NULL;
 | 
			
		||||
  struct chain *chains;
 | 
			
		||||
  char * cidr;
 | 
			
		||||
 | 
			
		||||
	acl = conf.acl;
 | 
			
		||||
	while(acl && acl->next) acl = acl->next;
 | 
			
		||||
@ -646,13 +647,16 @@ static int h_parent(int argc, char **argv){
 | 
			
		||||
		fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
 | 
			
		||||
		return(4);
 | 
			
		||||
	}
 | 
			
		||||
#ifndef NOIPV6
 | 
			
		||||
	if(!getip46(46, argv[3], (struct sockaddr *)&chains->addr)) return 5;
 | 
			
		||||
#else
 | 
			
		||||
	cidr = strchr(argv[3], '/');
 | 
			
		||||
	if(cidr) *cidr = 0;
 | 
			
		||||
	getip46(46, argv[3], (struct sockaddr *)&chains->addr);
 | 
			
		||||
#endif
 | 
			
		||||
	chains->exthost = mystrdup((char *)argv[3]);
 | 
			
		||||
	chains->exthost = (unsigned char *)mystrdup((char *)argv[3]);
 | 
			
		||||
	if(!chains->exthost) return 21;
 | 
			
		||||
	if(cidr){
 | 
			
		||||
		*cidr = '/';
 | 
			
		||||
		chains->cidr = atoi(cidr + 1);
 | 
			
		||||
	}
 | 
			
		||||
	*SAPORT(&chains->addr) = htons((unsigned short)atoi((char *)argv[4]));
 | 
			
		||||
	if(argc > 5) chains->extuser = mystrdup((char *)argv[5]);
 | 
			
		||||
	if(argc > 6) chains->extpass = mystrdup((char *)argv[6]);
 | 
			
		||||
 | 
			
		||||
@ -294,10 +294,11 @@ struct chain {
 | 
			
		||||
#else
 | 
			
		||||
	struct sockaddr_in addr;
 | 
			
		||||
#endif
 | 
			
		||||
	unsigned short weight;
 | 
			
		||||
	char * exthost;
 | 
			
		||||
	char * extuser;
 | 
			
		||||
	char * extpass;
 | 
			
		||||
	unsigned short weight;
 | 
			
		||||
	unsigned short cidr;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct period {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user