mirror of
				https://github.com/wangyu-/udp2raw.git
				synced 2025-11-04 20:25:34 +08:00 
			
		
		
		
	added lib dir
This commit is contained in:
		@@ -75,7 +75,7 @@ int clear_iptables_rule()
 | 
				
			|||||||
		strcat(buf,iptables_rule);
 | 
							strcat(buf,iptables_rule);
 | 
				
			||||||
		if(system(buf)==0)
 | 
							if(system(buf)==0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			mylog(log_warn,"iptables rule cleared\n",buf);
 | 
								mylog(log_warn,"iptables rule cleared by: %s \n",buf);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
#include <aes.h>
 | 
					#include <lib/aes.h>
 | 
				
			||||||
#include <md5.h>
 | 
					#include <lib/md5.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										35
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								main.cpp
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
				
			|||||||
#include "common.h"
 | 
					#include "common.h"
 | 
				
			||||||
#include "network.h"
 | 
					#include "network.h"
 | 
				
			||||||
#include "log.h"
 | 
					#include "log.h"
 | 
				
			||||||
#include "md5.h"
 | 
					#include "lib/md5.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char local_address[100]="0.0.0.0", remote_address[100]="255.255.255.255",source_address[100]="0.0.0.0";
 | 
					char local_address[100]="0.0.0.0", remote_address[100]="255.255.255.255",source_address[100]="0.0.0.0";
 | 
				
			||||||
u32_t local_address_uint32,remote_address_uint32,source_address_uint32;
 | 
					u32_t local_address_uint32,remote_address_uint32,source_address_uint32;
 | 
				
			||||||
@@ -1374,7 +1374,7 @@ int server_on_raw_recv_multi()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	char ip_port[40];
 | 
						char ip_port[40];
 | 
				
			||||||
	sprintf(ip_port,"%s:%d",my_ntoa(ip),port);
 | 
						sprintf(ip_port,"%s:%d",my_ntoa(ip),port);
 | 
				
			||||||
	mylog(log_trace,"[%s]peek_raw %s %d\n",ip_port);
 | 
						mylog(log_trace,"[%s]peek_raw\n",ip_port);
 | 
				
			||||||
	int data_len; char *data;
 | 
						int data_len; char *data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(raw_mode==mode_faketcp&&peek_info.syn==1)
 | 
						if(raw_mode==mode_faketcp&&peek_info.syn==1)
 | 
				
			||||||
@@ -2288,47 +2288,44 @@ int server_event_loop()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void print_help()
 | 
					void print_help()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	printf("udp-to-raw tunnel v0.1\n");
 | 
						printf("udp2raw-tunnel\n");
 | 
				
			||||||
 | 
						printf("version: %s %s\n",__DATE__,__TIME__);
 | 
				
			||||||
 | 
						printf("repository: https://github.com/wangyu-/udp2raw-tunnel\n");
 | 
				
			||||||
	printf("\n");
 | 
						printf("\n");
 | 
				
			||||||
	printf("usage:\n");
 | 
						printf("usage:\n");
 | 
				
			||||||
	printf("    run as client : ./this_program -c -l adress:port -r adress:port  [options]\n");
 | 
						printf("    run as client : ./this_program -c -l adress:port -r adress:port  [options]\n");
 | 
				
			||||||
	printf("    run as server : ./this_program -s -l adress:port -r adress:port  [options]\n");
 | 
						printf("    run as server : ./this_program -s -l adress:port -r adress:port  [options]\n");
 | 
				
			||||||
	printf("\n");
 | 
						printf("\n");
 | 
				
			||||||
	printf("common options,these options must be same on both side:\n");
 | 
						printf("common options,these options must be same on both side:\n");
 | 
				
			||||||
	printf("    --raw-mode            <string>        avaliable values:faketcp,udp,icmp\n");
 | 
						printf("    --raw-mode            <string>        avaliable values:faketcp(default),udp,icmp\n");
 | 
				
			||||||
	printf("    -k,--key              <string>        password to gen symetric key\n");
 | 
						printf("    -k,--key              <string>        password to gen symetric key,default:\"secret key\"\n");
 | 
				
			||||||
	printf("    --auth-mode           <string>        avaliable values:aes128cbc(default),xor,none\n");
 | 
						printf("    --auth-mode           <string>        avaliable values:aes128cbc(default),xor,none\n");
 | 
				
			||||||
	printf("    --cipher-mode         <string>        avaliable values:md5(default),crc32,simple,none\n");
 | 
						printf("    --cipher-mode         <string>        avaliable values:md5(default),crc32,simple,none\n");
 | 
				
			||||||
	printf("    -a,--auto-rule                        auto add (and delete) iptables rule\n");
 | 
						printf("    -a,--auto-rule                        auto add (and delete) iptables rule\n");
 | 
				
			||||||
	printf("    -g,--gen-rule                         generate iptables rule then exit\n");
 | 
						printf("    -g,--gen-rule                         generate iptables rule then exit\n");
 | 
				
			||||||
	printf("    --disable-anti-replay 				  disable anti-replay,not suggested");
 | 
						printf("    --disable-anti-replay                 disable anti-replay,not suggested\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	printf("\n");
 | 
						//printf("\n");
 | 
				
			||||||
	printf("client options:\n");
 | 
						printf("client options:\n");
 | 
				
			||||||
	printf("    --source-ip           <ip>            force source-ip for raw socket\n");
 | 
						printf("    --source-ip           <ip>            force source-ip for raw socket\n");
 | 
				
			||||||
	printf("    --source-port         <port>          force source-port for raw socket,tcp/udp only\n");
 | 
						printf("    --source-port         <port>          force source-port for raw socket,tcp/udp only\n");
 | 
				
			||||||
	printf("                                          this option disables port changing while re-connecting\n");
 | 
						printf("                                          this option disables port changing while re-connecting\n");
 | 
				
			||||||
	printf("                                          \n");
 | 
					//	printf("                                          \n");
 | 
				
			||||||
	printf("other options:\n");
 | 
						printf("other options:\n");
 | 
				
			||||||
	printf("    --log-level           <number>        0:never,never print log\n");
 | 
						printf("    --log-level           <number>        0:never    1:fatal   2:error   3:warn \n");
 | 
				
			||||||
	printf("                                          1:fatal\n");
 | 
						printf("                                          4:info (default)     5:debug   6:trace\n");
 | 
				
			||||||
	printf("                                          2:error\n");
 | 
					//	printf("\n");
 | 
				
			||||||
	printf("                                          3:warn\n");
 | 
					 | 
				
			||||||
	printf("                                          4:info (default)\n");
 | 
					 | 
				
			||||||
	printf("                                          5:debug\n");
 | 
					 | 
				
			||||||
	printf("                                          6:trace\n");
 | 
					 | 
				
			||||||
	printf("\n");
 | 
					 | 
				
			||||||
	printf("    --log-position                        enable file name,function name,line number in log\n");
 | 
						printf("    --log-position                        enable file name,function name,line number in log\n");
 | 
				
			||||||
	printf("    --disable-color                       disable log color\n");
 | 
						printf("    --disable-color                       disable log color\n");
 | 
				
			||||||
	printf("    --disable-bpf                         disable the kernel space filter,most time its not necessary\n");
 | 
						printf("    --disable-bpf                         disable the kernel space filter,most time its not necessary\n");
 | 
				
			||||||
	printf("                                          unless you suspect there is a bug\n");
 | 
						printf("                                          unless you suspect there is a bug\n");
 | 
				
			||||||
	printf("\n");
 | 
					//	printf("\n");
 | 
				
			||||||
	printf("    --sock-buf            <number>        buf size for socket,>=10 and <=10240,unit:kbyte\n");
 | 
						printf("    --sock-buf            <number>        buf size for socket,>=10 and <=10240,unit:kbyte,default:1024\n");
 | 
				
			||||||
	printf("    --seqmode             <number>        seq increase mode for faketcp:\n");
 | 
						printf("    --seqmode             <number>        seq increase mode for faketcp:\n");
 | 
				
			||||||
	printf("                                          0:dont increase\n");
 | 
						printf("                                          0:dont increase\n");
 | 
				
			||||||
	printf("                                          1:increase every packet\n");
 | 
						printf("                                          1:increase every packet\n");
 | 
				
			||||||
	printf("                                          2:increase randomly, about every 3 packets (default)\n");
 | 
						printf("                                          2:increase randomly, about every 3 packets (default)\n");
 | 
				
			||||||
	printf("\n");
 | 
					//	printf("\n");
 | 
				
			||||||
	printf("    -h,--help                             print this help message\n");
 | 
						printf("    -h,--help                             print this help message\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//printf("common options,these options must be same on both side\n");
 | 
						//printf("common options,these options must be same on both side\n");
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								makefile
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								makefile
									
									
									
									
									
								
							@@ -4,10 +4,13 @@ FLAGS2= -O3
 | 
				
			|||||||
all:
 | 
					all:
 | 
				
			||||||
	sudo killall udp2raw||true
 | 
						sudo killall udp2raw||true
 | 
				
			||||||
	sleep 0.2
 | 
						sleep 0.2
 | 
				
			||||||
	g++ main.cpp -o udp2raw -static  -ggdb -I. aes.c md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11    ${FLAGS} ${FLAGS2}
 | 
						g++ main.cpp -o udp2raw -static  -ggdb -I. -Ilib lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11    ${FLAGS} ${FLAGS2}
 | 
				
			||||||
	${ccmips} main.cpp -o udp2raw_mips  -lrt -I. aes.c md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2}
 | 
						${ccmips} main.cpp -o udp2raw_mips  -lrt -I. -Ilib lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -std=c++11 ${FLAGS} ${FLAGS2}
 | 
				
			||||||
 | 
					fast:
 | 
				
			||||||
 | 
						sudo killall udp2raw||true
 | 
				
			||||||
 | 
						sleep 0.2
 | 
				
			||||||
 | 
						g++ main.cpp -o udp2raw -ggdb -I. -Ilib lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11    ${FLAGS} 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
debug:
 | 
					debug:
 | 
				
			||||||
	g++ main.cpp -o udp2raw -static  -ggdb -I. aes.c md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11    ${FLAGS} -Wformat-nonliteral -D MY_DEBUG
 | 
						g++ main.cpp -o udp2raw -static  -ggdb -I. -Ilib lib/aes.c lib/md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11    ${FLAGS} -Wformat-nonliteral -D MY_DEBUG
 | 
				
			||||||
	${ccmips} main.cpp -o udp2raw   -ggdb -I. aes.c md5.c encrypt.cpp log.cpp network.cpp common.cpp -lrt -std=c++11    ${FLAGS} -Wformat-nonliteral -D MY_DEBUG
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ struct sock_filter code_tcp[] = {
 | 
				
			|||||||
{ 0x45, 4, 0, 0x00001fff },//5
 | 
					{ 0x45, 4, 0, 0x00001fff },//5
 | 
				
			||||||
{ 0xb1, 0, 0, 0x00000000 },//6
 | 
					{ 0xb1, 0, 0, 0x00000000 },//6
 | 
				
			||||||
{ 0x48, 0, 0, 0x00000002 },//7
 | 
					{ 0x48, 0, 0, 0x00000002 },//7
 | 
				
			||||||
{ 0x15, 0, 1, 0x0000fffe },//8
 | 
					{ 0x15, 0, 1, 0x0000fffe },//8   //modify this fffe to the port you listen on
 | 
				
			||||||
{ 0x6, 0, 0, 0x0000ffff },//9
 | 
					{ 0x6, 0, 0, 0x0000ffff },//9
 | 
				
			||||||
{ 0x6, 0, 0, 0x00000000 },//10
 | 
					{ 0x6, 0, 0, 0x00000000 },//10
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -61,7 +61,7 @@ struct sock_filter code_udp[] = {
 | 
				
			|||||||
{ 0x45, 4, 0, 0x00001fff },
 | 
					{ 0x45, 4, 0, 0x00001fff },
 | 
				
			||||||
{ 0xb1, 0, 0, 0x00000000 },
 | 
					{ 0xb1, 0, 0, 0x00000000 },
 | 
				
			||||||
{ 0x48, 0, 0, 0x00000002 },
 | 
					{ 0x48, 0, 0, 0x00000002 },
 | 
				
			||||||
{ 0x15, 0, 1, 0x0000fffe },
 | 
					{ 0x15, 0, 1, 0x0000fffe },    //modify this fffe to the port you listen on
 | 
				
			||||||
{ 0x6, 0, 0, 0x0000ffff },
 | 
					{ 0x6, 0, 0, 0x0000ffff },
 | 
				
			||||||
{ 0x6, 0, 0, 0x00000000 },
 | 
					{ 0x6, 0, 0, 0x00000000 },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user