timmy commited on
Commit
31034a8
·
1 Parent(s): a756f06
Files changed (3) hide show
  1. Dockerfile +11 -12
  2. dante.template.conf +16 -0
  3. entrypoint.sh +30 -0
Dockerfile CHANGED
@@ -1,16 +1,15 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
 
4
- FROM python:3.9
 
 
5
 
6
- RUN useradd -m -u 1000 user
7
- USER user
8
- ENV PATH="/home/user/.local/bin:$PATH"
 
9
 
10
- WORKDIR /app
11
 
12
- COPY --chown=user ./requirements.txt requirements.txt
13
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
-
15
- COPY --chown=user . /app
16
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM debian:stable-slim
 
2
 
3
+ RUN apt-get update && \
4
+ apt-get install -y dante-server iproute2 passwd && \
5
+ apt-get clean && rm -rf /var/lib/apt/lists/*
6
 
7
+ # 模板 & 脚本
8
+ COPY dante.template.conf /etc/dante.template.conf
9
+ COPY entrypoint.sh /entrypoint.sh
10
+ RUN chmod +x /entrypoint.sh
11
 
12
+ EXPOSE 1080
13
 
14
+ ENTRYPOINT ["/entrypoint.sh"]
15
+ CMD ["sockd", "-f", "/etc/dante.conf"]
 
 
 
dante.template.conf ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ logoutput: stderr
2
+
3
+ internal: 0.0.0.0 port = 1080
4
+
5
+ # external: __AUTO_EXTERNAL__
6
+
7
+ method: username
8
+ user.notprivileged: nobody
9
+
10
+ client pass {
11
+ from: 0.0.0.0/0 to: 0.0.0.0/0
12
+ }
13
+
14
+ socks pass {
15
+ from: 0.0.0.0/0 to: 0.0.0.0/0
16
+ }
entrypoint.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ echo ">>> Detecting network interface..."
4
+ IFACE=$(ip route get 8.8.8.8 | awk '{print $5; exit}')
5
+ echo ">>> Detected external interface: $IFACE"
6
+
7
+ # 自动生成账号密码(如果用户没传入)
8
+ if [ -z "$USERNAME" ]; then
9
+ USERNAME="user$(date +%s | md5sum | cut -c1-5)"
10
+ fi
11
+
12
+ if [ -z "$PASSWORD" ]; then
13
+ PASSWORD="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10)"
14
+ fi
15
+
16
+ echo ">>> SOCKS Username: $USERNAME"
17
+ echo ">>> SOCKS Password: $PASSWORD"
18
+
19
+ # 创建系统用户
20
+ useradd -r -s /bin/false "$USERNAME"
21
+ echo "$USERNAME:$PASSWORD" | chpasswd
22
+
23
+ # 生成 dante.conf
24
+ sed "s|__AUTO_EXTERNAL__|external: $IFACE|" /etc/dante.template.conf > /etc/dante.conf
25
+
26
+ echo ">>> Final /etc/dante.conf:"
27
+ cat /etc/dante.conf
28
+
29
+ echo ">>> Starting Dante SOCKS5..."
30
+ exec "$@"