From af485a626dec9702c8c4754c509c0c9104abb508 Mon Sep 17 00:00:00 2001 From: sigkill64 Date: Tue, 5 Jul 2022 14:21:18 +0800 Subject: [PATCH] change 'nmp' to 'proxy' --- .gitmodules | 6 ++--- custom.env.example | 1 + docker-compose.gen | 9 ++++---- motd/Dockerfile | 9 +++++--- nmp/Dockerfile | 19 --------------- nmp/nmp | 1 - nmp/nmp.run | 3 --- {nmp => proxy}/.dockerignore | 0 proxy/Dockerfile | 21 +++++++++++++++++ proxy/nmp | 1 + proxy/proxy.run | 5 ++++ proxy/v2ray/config.json | 45 ++++++++++++++++++++++++++++++++++++ 12 files changed, 87 insertions(+), 33 deletions(-) delete mode 100644 nmp/Dockerfile delete mode 160000 nmp/nmp delete mode 100755 nmp/nmp.run rename {nmp => proxy}/.dockerignore (100%) create mode 100644 proxy/Dockerfile create mode 160000 proxy/nmp create mode 100755 proxy/proxy.run create mode 100644 proxy/v2ray/config.json diff --git a/.gitmodules b/.gitmodules index c55d66e..5b5a57b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "nmp/nmp"] - path = nmp/nmp - url = https://git.oxfs.io/nmp/nmp.git [submodule "jellyfin/jellyfin-noto"] path = jellyfin/jellyfin-noto url = https://github.com/jellyfin-archive/jellyfin-noto.git [submodule "wsdd2/wsdd2"] path = wsdd2/wsdd2 url = https://github.com/Netgear/wsdd2.git +[submodule "proxy/nmp"] + path = proxy/nmp + url = https://git.oxfs.io/nmp/nmp.git diff --git a/custom.env.example b/custom.env.example index f4e0c51..9239b0e 100644 --- a/custom.env.example +++ b/custom.env.example @@ -17,6 +17,7 @@ ARGS_JELLYFIN_VERSION=10.7.7 # proxy service PROXY_SOCKS_PORT=1234 +PROXY_HTTP_PORT=1248 PROXY_NMP_ENDPOINT=wss://next.example.com PROXY_NMP_TOKEN=abcd1234bcda4312 diff --git a/docker-compose.gen b/docker-compose.gen index b96dc45..d04fa78 100755 --- a/docker-compose.gen +++ b/docker-compose.gen @@ -28,13 +28,14 @@ cat <<-EOF >docker-compose.yml version: '3' services: - nmp: - image: "oxfs.io/nmp" + proxy: + image: "sigkill.top/proxy" build: - context: ./nmp + context: ./proxy args: - PYTHON_VERSION=${ARGS_PYTHON_VERSION} - ALPINE_VERSION=${ARGS_ALPINE_VERSION} + - APK_MIRROR=${ARGS_APK_MIRROR} environment: - NMP_ENDPOINT=${PROXY_NMP_ENDPOINT} - NMP_TOKEN=${PROXY_NMP_TOKEN} @@ -42,7 +43,7 @@ services: - localnet ports: - ${PROXY_SOCKS_PORT}:10086 - #- 10080:10080 + - ${PROXY_HTTP_PORT}:10080 restart: unless-stopped samba: diff --git a/motd/Dockerfile b/motd/Dockerfile index 3e5c6cc..ee7f236 100644 --- a/motd/Dockerfile +++ b/motd/Dockerfile @@ -3,12 +3,15 @@ FROM alpine:${ALPINE_VERSION} ARG APK_MIRROR=dl-cdn.alpinelinux.org +COPY motd.run /etc/periodic/hourly/ + RUN sed -i "s/dl-cdn.alpinelinux.org/${APK_MIRROR}/g" /etc/apk/repositories && \ - apk --no-cache --no-progress add jq curl && \ + apk add --no-cache --no-progress tzdata jq curl && \ + chmod +x /etc/periodic/hourly/motd.run && \ rm -rf /tmp/* -COPY motd.run /etc/periodic/hourly/ - VOLUME ["/mnt/motd"] +ENV TZ=Asia/Shanghai + ENTRYPOINT ["crond", "-f", "-d", "8"] diff --git a/nmp/Dockerfile b/nmp/Dockerfile deleted file mode 100644 index ca501d4..0000000 --- a/nmp/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -ARG PYTHON_VERSION=3 -ARG ALPINE_VERSION -FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} - -ENV NMP_ENDPOINT="" -ENV NMP_TOKEN="" - -WORKDIR /var/lib/nmp - -COPY nmp/nmp/ ./nmp/ -COPY nmp/setup.py ./ -COPY nmp.run /usr/local/bin/ - -RUN ["chmod", "+x", "/usr/local/bin/nmp.run"] -RUN ["python", "setup.py", "develop"] - -EXPOSE 10086/tcp - -ENTRYPOINT ["nmp.run"] diff --git a/nmp/nmp b/nmp/nmp deleted file mode 160000 index 577ed20..0000000 --- a/nmp/nmp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 577ed20ee80845163264c230f40903458022f124 diff --git a/nmp/nmp.run b/nmp/nmp.run deleted file mode 100755 index bb5ad30..0000000 --- a/nmp/nmp.run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec nmp --uvloop true --server sockv5 --endpoint "${NMP_ENDPOINT}" --host '0.0.0.0' --port 10086 --token "${NMP_TOKEN}" diff --git a/nmp/.dockerignore b/proxy/.dockerignore similarity index 100% rename from nmp/.dockerignore rename to proxy/.dockerignore diff --git a/proxy/Dockerfile b/proxy/Dockerfile new file mode 100644 index 0000000..5f06dce --- /dev/null +++ b/proxy/Dockerfile @@ -0,0 +1,21 @@ +ARG PYTHON_VERSION=3 +ARG ALPINE_VERSION +FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} + +ARG APK_MIRROR="dl-cdn.alpinelinux.org" +ENV NMP_ENDPOINT="" +ENV NMP_TOKEN="" + +COPY proxy.run /usr/local/bin/ +COPY v2ray/config.json /etc/v2ray/ +COPY nmp/setup.py /tmp/nmp/ +COPY nmp/nmp/ /tmp/nmp/nmp/ + +RUN sed -i "s/dl-cdn.alpinelinux.org/${APK_MIRROR}/g" /etc/apk/repositories && \ + apk add --no-cache --no-progress v2ray && \ + chmod +x /usr/local/bin/proxy.run && \ + cd /tmp/nmp && python setup.py develop + +EXPOSE 10086 10080 + +ENTRYPOINT ["proxy.run"] diff --git a/proxy/nmp b/proxy/nmp new file mode 160000 index 0000000..e26f8b8 --- /dev/null +++ b/proxy/nmp @@ -0,0 +1 @@ +Subproject commit e26f8b811f7ad340f477552ea4becee100b732ce diff --git a/proxy/proxy.run b/proxy/proxy.run new file mode 100755 index 0000000..a9cb234 --- /dev/null +++ b/proxy/proxy.run @@ -0,0 +1,5 @@ +#!/bin/sh + +nmp --uvloop true --server sockv5 --endpoint "${NMP_ENDPOINT}" --host '0.0.0.0' --port 10086 --token "${NMP_TOKEN}" >/dev/null 2>&1 & +sleep 1 +exec v2ray -config /etc/v2ray/config.json >/dev/null 2>&1 diff --git a/proxy/v2ray/config.json b/proxy/v2ray/config.json new file mode 100644 index 0000000..baaf88b --- /dev/null +++ b/proxy/v2ray/config.json @@ -0,0 +1,45 @@ +{ + "log": { + "access": "none", + "error": "none", + "loglevel": "none" + }, + "routing": { + "domainStrategy": "AsIs", + "domainMatcher": "mph", + "rules": [{ + "domainMatcher": "mph", + "type": "field", + "domains": [ + "geosite:tld-cn", + "geosite:geolocation-cn" + ], + "inboundTag": "tagin-http", + "outboundTag": "tagout-direct" + }] + }, + "inbounds": [{ + "listen": "0.0.0.0", + "port": 10080, + "protocol": "http", + "settings": { + "timeout": 60, + "allowTransparent": false + }, + "tag": "tagin-http" + }], + "outbounds": [{ + "sendThrough": "0.0.0.0", + "protocol": "socks", + "settings": { + "servers": [{ + "address": "127.0.0.1", + "port": 10086 + }] + }, + "tag": "tagout-socks" + }, { + "protocol": "freedom", + "tag": "tagout-direct" + }] +}