# denyip

大陆服务器禁止国外IP访问  

## build

~~~bash
# Debian System
apt install build-essential
apt install golang
apt install libpcap-dev libcap-dev libsystemd-dev

root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP# make clean; make
rm -rf a.out ipquery
rm -rf cap.o common.o ip2region/ip2region.o ip2region/xdb_searcher.o libipset.o
gcc -g -Wall -Iip2region -c cap.c -o cap.o
gcc -g -Wall -Iip2region -c common.c -o common.o
gcc -g -Wall -Iip2region -c ip2region/ip2region.c -o ip2region/ip2region.o
gcc -g -Wall -Iip2region -c ip2region/xdb_searcher.c -o ip2region/xdb_searcher.o
gcc -g -Wall -Iip2region -c libipset.c -o libipset.o
gcc -g -Wall -Iip2region -o a.out cap.o common.o ip2region/ip2region.o ip2region/xdb_searcher.o libipset.o -lpcap -ldbus-1 -lsystemd  -L/usr/lib64 -lcap  -lipset -lmnl
root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP#
~~~

### help

~~~bash

root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP# ./a.out -h
DenyIP version 0.2
拒绝Linux服务器非大陆IP工具
MAIL: aixiao@aixiao.me
Date: 20241024
  Usage: denyip [-d] [-i <interface>] [-s <start|stop>] [-h|-?]
      -d      Daemon mode
      -i      interface (default eth0)
      -s      regular signal (default start|stop)
                  start Enable Iptables rule
                  stop  Disable Iptables rule
      -h|-?   Help Information


root@niuyuling:~/DenyIP# killall -15 denyip     # 关闭
root@niuyuling:~/DenyIP# ./denyip -i eth0       # 启动
root@niuyuling:~/DenyIP# ./denyip -s start      # Iptables 规则打开
root@niuyuling:~/DenyIP# ./denyip -s stop       # Iptables 规则关闭
~~~
