From f8d1abb527d1f31355beee2d88844b0a87746b88 Mon Sep 17 00:00:00 2001 From: aixiao Date: Wed, 15 Jan 2025 10:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++- denyip | Bin 12559416 -> 12559416 bytes 2 files changed, 109 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cfa33a..a1bca50 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ```bash apt-get install ipset -apt-get install libpcap-dev +apt-get install libcap-dev libpcap-dev libdbus-1-dev git clone https://git.aixiao.me/aixiao/DenyIP-go.git cd DenyIP-go @@ -22,7 +22,115 @@ cd DenyIP-go 编译项目: ```bash +# 动态构建 go build -o denyip + +# 静态构建 +root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP-go# bash build-static-bin.sh +++ pkg-config --libs --static libcap ++ libcap='-L/usr/lib64 -lcap ' +++ pkg-config --libs --static libpcap ++ libpcap='-lpcap -ldbus-1 -pthread -lsystemd ' +++ pkg-config --libs --static dbus-1 ++ dbus='-ldbus-1 -pthread -lsystemd ' ++ a=\' ++ eval 'CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -ldflags '\''-extldflags "-static -lpcap -ldbus-1 -pthread -lsystemd -ldbus-1 -pthread -lsystemd -L/usr/lib64 -lcap -lc"'\''' +++ CGO_ENABLED=1 +++ GOOS=linux +++ GOARCH=amd64 +++ go build -a -ldflags '-extldflags "-static -lpcap -ldbus-1 -pthread -lsystemd -ldbus-1 -pthread -lsystemd -L/usr/lib64 -lcap -lc"' +# denyip +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `get_group_creds': +(.text.get_group_creds+0x84): 警告:Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `getgrgid_malloc': +(.text.getgrgid_malloc+0x80): 警告:Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `get_group_creds': +(.text.get_group_creds+0xe4): 警告:Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `getgrnam_malloc': +(.text.getgrnam_malloc+0x7c): 警告:Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libdbus-1.a(dbus-sysdeps-unix.c.o): in function `fill_user_info': +(.text+0x1baa): 警告:Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /tmp/go-link-2318349626/000004.o: in function `_cgo_04fbb8f65a5f_C2func_getaddrinfo': +/tmp/go-build/cgo-gcc-prolog:60:(.text+0x33): 警告:Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libpcap.a(nametoaddr.o): in function `pcap_nametoaddr': +(.text+0x9): 警告:Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libpcap.a(nametoaddr.o): in function `pcap_nametonetaddr': +(.text+0x111): 警告:Using 'getnetbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libpcap.a(nametoaddr.o): in function `pcap_nametoproto': +(.text+0x471): 警告:Using 'getprotobyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `get_user_creds': +(.text.get_user_creds+0x1ba): 警告:Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libdbus-1.a(dbus-sysdeps-unix.c.o): in function `fill_user_info': +(.text+0x1a1d): 警告:Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `get_user_creds': +(.text.get_user_creds+0x9c): 警告:Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libdbus-1.a(dbus-sysdeps-unix.c.o): in function `fill_user_info': +(.text+0x19c4): 警告:Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking +root@NIUYULING:/mnt/c/Users/root/Desktop/git.aixiao.me/DenyIP-go# + +``` + +### 安装 + +```bash +root@NG-FROM:~# wget https://git.aixiao.me/aixiao/DenyIP-go/raw/branch/main/install.sh +--2025-01-15 10:56:09-- https://git.aixiao.me/aixiao/DenyIP-go/raw/branch/main/install.sh +Resolving git.aixiao.me (git.aixiao.me)... 47.240.75.93 +Connecting to git.aixiao.me (git.aixiao.me)|47.240.75.93|:443... connected. +HTTP request sent, awaiting response... 200 OK +Length: 1110 (1.1K) [text/plain] +Saving to: ‘install.sh’ + +install.sh 100%[=========================================================================>] 1.08K --.-KB/s in 0s + +2025-01-15 10:56:10 (12.8 MB/s) - ‘install.sh’ saved [1110/1110] + +root@NG-FROM:~# bash install.sh ++ init ++ DENYIP_HOME=/root/DenyIP-go ++ main ++ test -d /root/DenyIP-go ++ mkdir -p /root/DenyIP-go ++ mkdir -p /root/DenyIP-go/ip2region ++ test -f /root/DenyIp/ip2region/ip2region.xdb ++ wget -O /root/DenyIP-go/ip2region/ip2region.xdb https://git.aixiao.me/aixiao/DenyIP-go/raw/branch/main/ip2region/ip2region.xdb +--2025-01-15 10:56:17-- https://git.aixiao.me/aixiao/DenyIP-go/raw/branch/main/ip2region/ip2region.xdb +Resolving git.aixiao.me (git.aixiao.me)... 47.240.75.93 +Connecting to git.aixiao.me (git.aixiao.me)|47.240.75.93|:443... connected. +HTTP request sent, awaiting response... 200 OK +Length: 11070083 (11M) [application/octet-stream] +Saving to: ‘/root/DenyIP-go/ip2region/ip2region.xdb’ + +/root/DenyIP-go/ip2region/ip2region.xd 100%[=========================================================================>] 10.56M 6.30MB/s in 1.7s + +2025-01-15 10:56:19 (6.30 MB/s) - ‘/root/DenyIP-go/ip2region/ip2region.xdb’ saved [11070083/11070083] + +++ md5sum /root/DenyIP-go/ip2region/ip2region.xdb +++ cut -d ' ' -f 1 ++ test 508c6b0257a02152b9d1b2b3792936e1 '!=' 508c6b0257a02152b9d1b2b3792936e1 ++ echo 'ip2region.xdb md5 check success' +ip2region.xdb md5 check success ++ test -f /root/DenyIp/denyip ++ wget -O /root/DenyIP-go/denyip https://git.aixiao.me/aixiao/DenyIP-go/raw/branch/main/denyip +--2025-01-15 10:56:19-- https://git.aixiao.me/aixiao/DenyIP-go/raw/branch/main/denyip +Resolving git.aixiao.me (git.aixiao.me)... 47.240.75.93 +Connecting to git.aixiao.me (git.aixiao.me)|47.240.75.93|:443... connected. +HTTP request sent, awaiting response... 200 OK +Length: 12559416 (12M) [application/octet-stream] +Saving to: ‘/root/DenyIP-go/denyip’ + +/root/DenyIP-go/denyip 100%[=========================================================================>] 11.98M 5.28MB/s in 2.3s + +2025-01-15 10:56:22 (5.28 MB/s) - ‘/root/DenyIP-go/denyip’ saved [12559416/12559416] + ++ chmod +x /root/DenyIP-go/denyip +++ file /root/DenyIP-go/denyip +++ grep ELF ++ test -n '/root/DenyIP-go/denyip: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=abbdb4ab38005c7c40777ac749a81c24f82095ef, for GNU/Linux 3.2.0, with debug_info, not stripped' ++ echo 'denyip install success' +denyip install success ++ exit 0 +root@NG-FROM:~# ``` ### 命令行选项 diff --git a/denyip b/denyip index 2db3060bf2cfbc089c47f6386c454269196fdfe0..fc37e0e41c8c1b73a79c1d42e35a715d60d2cb04 100644 GIT binary patch delta 1031 zcmbWy=~qkv9LDjhDYDB>_N5}3dz*V}ZbXslPFiQiD9hB`nM#?~sVO3446;l}_H2m;OCj^l;b{sRAi_l|G>f)}6jJTHFdcg{2X{cqGThJHnKwh#0-ev1j%f40RrMt+wE z)8qAyNI?*+7|)z~L6EYoYN^@Zq}1EJHO{;ezou(OxjEn4;?t8-s@hW}XHiybv7Bwp zuWQH>Es7#(_S`nFZt>S<78t8*s|vLgt7^{ksbyA=NwYd7A*1mJ--RxRA?PqnKm^8n zB%&}8lMs!`n1ZR8hUu7rnV5wb%*Gtd#XQW%0xZNLEJiGrU@4YiIaXjLR$(>PU@hVh zj|8m4dL&{4lCTj*h>(yB6J#hzK`P8pk%mp!jC5?lR%9R(+pry3*nw>1AQu`e$iq(L zqX2~{LNQ8Ug$;J>f&;rziZblMUhKpEu*2Z|(~}_UqUzQ?l3d}gbg6E|f97QLN;W$p93nvl4DFksEXToE>X9J`Exi-jJoWprs zz(s`6gG;!KE9k{l^x+z=;|6Zx7H;DX`f(Tca32rw5CeFG#~8#DJjF9S#|yl~D-7W^ d-rz0X;XOVejA4Al2tMI6zF;&QvV9#a{0Hz#ivj=u delta 1031 zcmbWy>sw0!0LSs83%TE~g%BcaXQ#8BliQ|POD)yfDv{ILtg>p+MWRTCTnaPy`z7WQ zV!4#w@%Rh;7hZVdmB+V#!HduH`@Q--&u{4a-}oU6{EX>{3=c*Wp}gJP()P{PpOo?^ zIrJ+|5QHL(rL|rVn*EkQSy83WTPgW9htgP5U~AS%k}9URRn%ve7(HT5sc7*OTXlJL z4O#jeSr%=@*{yzePD`!Du5;S$ey7@$S!k;^I@G3IpX{><=D-iug)UcY&=orlF&OJ{ zh{t$LKmsOW5+-8`reYeVV+Lko7G`4(=3*Y^V*wUo5fYJv#aM!+NX9ZO#|oriC01cI zQn3bWk%o0xj}6d44-p1PNQVp~Oi-XA0~@gko3RC3VTJ|Ukclj8#|~JL4I6T>6S>HP z9r@UW0u-VM4iv))7fMiyGVDe<_F!++6ipH?t(UX{*z@fj)p3*4;m`rMio5pVn2MSMh$9l0Djb= z9t{Yf5eIPyO=w07T5%X{ID&Q@#W8fC6UT7^T{wwuoI((%aV9z%I@>++pKpV_#W|eE z1zbcg`fv%CaRnh