mirror of
				https://github.com/wangyu-/UDPspeeder.git
				synced 2025-10-31 01:45:38 +08:00 
			
		
		
		
	add dest ip restriction
This commit is contained in:
		
							
								
								
									
										11
									
								
								tun_dev.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								tun_dev.cpp
									
									
									
									
									
								
							| @@ -293,6 +293,17 @@ int tun_dev_client_event_loop() | |||||||
| 					mylog(log_warn,"read from tun_fd return %d,errno=%s\n",len,strerror(errno)); | 					mylog(log_warn,"read from tun_fd return %d,errno=%s\n",len,strerror(errno)); | ||||||
| 					continue; | 					continue; | ||||||
| 				} | 				} | ||||||
|  | 				if(len>=20) | ||||||
|  | 				{ | ||||||
|  | 					u32_t dest_ip=htonl(read_u32(data+16)); | ||||||
|  | 					if(  ( ntohl(sub_net_uint32)&0xFFFFFF00 ) !=  ( ntohl (dest_ip) &0xFFFFFF00) ) | ||||||
|  | 					{ | ||||||
|  | 						string sub=my_ntoa(dest_ip); | ||||||
|  | 						string dst=my_ntoa( htonl( ntohl (dest_ip) &0xFFFFFF00)   ); | ||||||
|  | 						mylog(log_warn,"packet's dest ip [%s] not in subnet [%s],dropped\n", sub.c_str(), dst.c_str()); | ||||||
|  | 						continue; | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  |  | ||||||
| 				mylog(log_trace,"Received packet from tun,len: %d\n",len); | 				mylog(log_trace,"Received packet from tun,len: %d\n",len); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user