Skip to content

Commit

Permalink
修改docker代码
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgyc committed Oct 24, 2024
1 parent 49b40b5 commit 772b111
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,17 @@ ipv4_end = "10.1.2.200"
docker run -it --rm bjdgyc/anylink tool -d
```

6. 启动容器
6. iptables兼容设置
```bash
# 默认 iptables 使用 nf_tables 设置转发规则,如果内核低于 4.19 版本,需要特殊配置
docker run -itd --name anylink --privileged \
-e IPTABLES_LEGACY=on \
-p 443:443 -p 8800:8800 -p 443:443/udp \
--restart=always \
bjdgyc/anylink
```

7. 启动容器
```bash
# 默认启动
docker run -itd --name anylink --privileged \
Expand All @@ -410,7 +420,7 @@ ipv4_end = "10.1.2.200"
docker restart anylink
```

6. 使用自定义参数启动容器
8. 使用自定义参数启动容器
```bash
# 参数可以参考 ./anylink tool -d
# 可以使用命令行参数 或者 环境变量 配置
Expand Down Expand Up @@ -459,7 +469,8 @@ ipv4_end = "10.1.2.200"
- [AnyConnect Secure Client](https://www.cisco.com/) (可通过群文件下载: Windows/macOS/Linux/Android/iOS)
- [OpenConnect](https://gitlab.com/openconnect/openconnect) (Windows/macOS/Linux)
- [三方 AnyLink Secure Client](https://github.com/tlslink/anylink-client) (Windows/macOS/Linux)
- 【推荐】三方客户端下载地址(Windows/macOS/Linux/Android/iOS) [国内地址](https://ocserv.yydy.link:2023) [国外地址](https://cisco.yydy.link/#/)
- 【推荐】三方客户端下载地址(
Windows/macOS/Linux/Android/iOS) [国内地址](https://ocserv.yydy.link:2023) [国外地址](https://cisco.yydy.link/#/)

## Contribution

Expand Down
4 changes: 3 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ LABEL maintainer="github.com/bjdgyc"
ARG CN="no"

ENV TZ=Asia/Shanghai
ENV ANYLINK_IN_CONTAINER=true
#开关变量 on off
ENV ANYLINK_IN_CONTAINER="on"
ENV IPTABLES_LEGACY="off"

WORKDIR /app
COPY docker/init_release.sh /tmp/
Expand Down
10 changes: 8 additions & 2 deletions docker/docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
var1=$1

#set -x
Expand All @@ -19,13 +19,19 @@ case $var1 in
#iptables -nL -t nat

# 启动服务 先判断配置文件是否存在
if [ ! -f /app/conf/profile.xml ]; then
if [[ ! -f /app/conf/profile.xml ]]; then
/bin/cp -r /home/conf-bak/* /app/conf/
echo "After the configuration file is initialized, the container will be forcibly exited. Restart the container."
echo "配置文件初始化完成后,容器会强制退出,请重新启动容器。"
exit 1
fi

# 兼容老版本 iptables
if [[ $IPTABLES_LEGACY == "on" ]]; then
rm /sbin/iptables
ln -s /sbin/iptables-legacy /sbin/iptables
fi

exec /app/anylink "$@"
;;
esac
7 changes: 4 additions & 3 deletions docker/init_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ fi
# docker 启动使用 4.19 以上内核
apk add --no-cache ca-certificates bash iproute2 tzdata iptables

# alpine:3.19 兼容老版 iptables
# alpine:3.19 兼容老版本 iptables
apk add --no-cache iptables-legacy
rm /sbin/iptables
ln -s /sbin/iptables-legacy /sbin/iptables

#rm /sbin/iptables
#ln -s /sbin/iptables-legacy /sbin/iptables


chmod +x /app/docker_entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion server/base/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (

func initMod() {
container := os.Getenv(inContainerKey)
if container == "true" {
if container == "on" {
InContainer = true
}
log.Println("InContainer", InContainer)
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/user/Online.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
label="唯一MAC">
<template slot-scope="scope">
<el-tag v-if="scope.row.unique_mac" type="success">是</el-tag>
<el-tag v-else type="info">否</el-tag>
</template>
</el-table-column>

Expand Down

0 comments on commit 772b111

Please sign in to comment.