修改文档

This commit is contained in:
aixiao 2025-01-15 10:57:18 +08:00
parent 4c09dce14a
commit f8d1abb527
2 changed files with 109 additions and 1 deletions

110
README.md
View File

@ -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:~#
```
### 命令行选项

BIN
denyip

Binary file not shown.