diff --git a/common.cpp b/common.cpp index 15969e4..a6a9dfb 100644 --- a/common.cpp +++ b/common.cpp @@ -75,7 +75,7 @@ int clear_iptables_rule() strcat(buf,iptables_rule); if(system(buf)==0) { - mylog(log_warn,"iptables rule cleared\n",buf); + mylog(log_warn,"iptables rule cleared by: %s \n",buf); } else { diff --git a/encrypt.cpp b/encrypt.cpp index a274651..ab5edf2 100755 --- a/encrypt.cpp +++ b/encrypt.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include diff --git a/aes.c b/lib/aes.c similarity index 100% rename from aes.c rename to lib/aes.c diff --git a/aes.h b/lib/aes.h similarity index 100% rename from aes.h rename to lib/aes.h diff --git a/md5.c b/lib/md5.c similarity index 100% rename from md5.c rename to lib/md5.c diff --git a/md5.h b/lib/md5.h similarity index 100% rename from md5.h rename to lib/md5.h diff --git a/main.cpp b/main.cpp index 7631ac2..5c1f08f 100755 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,7 @@ #include "common.h" #include "network.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"; 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]; 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; if(raw_mode==mode_faketcp&&peek_info.syn==1) @@ -2288,47 +2288,44 @@ int server_event_loop() 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("usage:\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("\n"); printf("common options,these options must be same on both side:\n"); - printf(" --raw-mode avaliable values:faketcp,udp,icmp\n"); - printf(" -k,--key password to gen symetric key\n"); + printf(" --raw-mode avaliable values:faketcp(default),udp,icmp\n"); + printf(" -k,--key password to gen symetric key,default:\"secret key\"\n"); printf(" --auth-mode avaliable values:aes128cbc(default),xor,none\n"); printf(" --cipher-mode avaliable values:md5(default),crc32,simple,none\n"); printf(" -a,--auto-rule auto add (and delete) iptables rule\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(" --source-ip force source-ip for raw socket\n"); printf(" --source-port force source-port for raw socket,tcp/udp only\n"); printf(" this option disables port changing while re-connecting\n"); - printf(" \n"); +// printf(" \n"); printf("other options:\n"); - printf(" --log-level 0:never,never print log\n"); - printf(" 1:fatal\n"); - printf(" 2:error\n"); - printf(" 3:warn\n"); - printf(" 4:info (default)\n"); - printf(" 5:debug\n"); - printf(" 6:trace\n"); - printf("\n"); + printf(" --log-level 0:never 1:fatal 2:error 3:warn \n"); + printf(" 4:info (default) 5:debug 6:trace\n"); +// printf("\n"); printf(" --log-position enable file name,function name,line number in log\n"); printf(" --disable-color disable log color\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("\n"); - printf(" --sock-buf buf size for socket,>=10 and <=10240,unit:kbyte\n"); +// printf("\n"); + printf(" --sock-buf buf size for socket,>=10 and <=10240,unit:kbyte,default:1024\n"); printf(" --seqmode seq increase mode for faketcp:\n"); printf(" 0:dont increase\n"); printf(" 1:increase every packet\n"); printf(" 2:increase randomly, about every 3 packets (default)\n"); - printf("\n"); +// printf("\n"); printf(" -h,--help print this help message\n"); //printf("common options,these options must be same on both side\n"); diff --git a/makefile b/makefile index 65e043f..c0274ab 100755 --- a/makefile +++ b/makefile @@ -4,10 +4,13 @@ FLAGS2= -O3 all: sudo killall udp2raw||true 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} - ${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} + 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. -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: - 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 - ${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 + 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 diff --git a/network.cpp b/network.cpp index 8f9f945..02046c7 100644 --- a/network.cpp +++ b/network.cpp @@ -46,7 +46,7 @@ struct sock_filter code_tcp[] = { { 0x45, 4, 0, 0x00001fff },//5 { 0xb1, 0, 0, 0x00000000 },//6 { 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, 0x00000000 },//10 }; @@ -61,7 +61,7 @@ struct sock_filter code_udp[] = { { 0x45, 4, 0, 0x00001fff }, { 0xb1, 0, 0, 0x00000000 }, { 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, 0x00000000 }, };