diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf26cc4 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# denyip + +大陆服务器禁止国外IP访问 + +## build + +~~~bash +# Debian System +apt install build-essential +apt install golang +apt install tcpdump procps iptables ipset + +root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP# make clean; make +rm -rf denyip ipquery +rm -rf main.o common.o ip2region/ip2region.o ip2region/xdb_searcher.o qqwry/qqwry.o +gcc -g -Os -Wall -Iip2region -Iqqwry -c main.c -o main.o +gcc -g -Os -Wall -Iip2region -Iqqwry -c common.c -o common.o +gcc -g -Os -Wall -Iip2region -Iqqwry -c ip2region/ip2region.c -o ip2region/ip2region.o +gcc -g -Os -Wall -Iip2region -Iqqwry -c ip2region/xdb_searcher.c -o ip2region/xdb_searcher.o +gcc -g -Os -Wall -Iip2region -Iqqwry -c qqwry/qqwry.c -o qqwry/qqwry.o +gcc -g -Os -Wall -Iip2region -Iqqwry -o denyip main.o common.o ip2region/ip2region.o ip2region/xdb_searcher.o qqwry/qqwry.o -lm -static +root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP# +~~~ + +### help + +~~~bash + +root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP# ./denyip -h + DenyIp +Linux system firewall, reject non-Chinese IP +Email: aixiao@aixiao.me +Version: 0.1 +Usage: ./denyip [-i eth0|-h|-?] [start|stop] +Options: + stop Enable firewall rules + start Disable firewall rules +Parameters: + -h|? Help info + -i interface name + + +root@niuyuling:~/DenyIP# killall denyip # 关闭 +root@niuyuling:~/DenyIP# ./denyip -i eth0 # 启动 +root@niuyuling:~/DenyIP# ./denyip start # Iptables 规则打开 +root@niuyuling:~/DenyIP# ./denyip stop # Iptables 规则关闭 +~~~ diff --git a/denyip b/denyip index 1fbbe51..c02ca96 100644 Binary files a/denyip and b/denyip differ diff --git a/main.c b/main.c index 6837943..e69d163 100644 --- a/main.c +++ b/main.c @@ -307,7 +307,7 @@ int main(int argc, char *argv[]) perror("popen failed"); return 1; } - + // 创建足够大的缓冲区来存储命令输出 char buffer[1024 * 2]; // 2KB 缓冲区 size_t bytesRead = fread(buffer, 1, sizeof(buffer) - 1, fp); @@ -349,6 +349,7 @@ int main(int argc, char *argv[]) iteration++; if (iteration >= 3600) { + iteration = 0; printf("准备重启进程...\n"); restart_process(pid1, pid2, argv); } diff --git a/main.o b/main.o index 347f7e4..c0c112f 100644 Binary files a/main.o and b/main.o differ