mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-08 21:56:08 +00:00
328d920e98
Map each mtproto client's totalGB and expiryTime onto mtg-multi's new
[secret-limits] (quota/expires): emit them into the generated config and
hot-apply through PUT /secrets so live connections survive. Quota is
written as an exact "<n>B" byte count that round-trips through both the
config and API parsers without the precision loss of a base-2 unit.
The sidecar's quota counter is not pruned when a secret is dropped, so a
panel-side traffic reset re-pushes the client's secret and then calls
POST /secrets/{name}/reset-quota (wired into every reset path) so a
renewed client is not immediately re-blocked.
Resolve the mtg-multi binary from the fork's latest release tag in
DockerInit.sh and release.yml instead of a hardcoded version pin, so the
panel no longer needs a manual bump per fork release.
59 lines
2.1 KiB
Bash
Executable File
59 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
case $1 in
|
|
amd64)
|
|
ARCH="64"
|
|
FNAME="amd64"
|
|
;;
|
|
i386)
|
|
ARCH="32"
|
|
FNAME="i386"
|
|
;;
|
|
armv8 | arm64 | aarch64)
|
|
ARCH="arm64-v8a"
|
|
FNAME="arm64"
|
|
;;
|
|
armv7 | arm | arm32)
|
|
ARCH="arm32-v7a"
|
|
FNAME="arm32"
|
|
;;
|
|
armv6)
|
|
ARCH="arm32-v6"
|
|
FNAME="armv6"
|
|
;;
|
|
*)
|
|
ARCH="64"
|
|
FNAME="amd64"
|
|
;;
|
|
esac
|
|
MTG_MULTI_VER=$(curl -sfL "https://api.github.com/repos/mhsanaei/mtg-multi/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1)
|
|
if [ -z "$MTG_MULTI_VER" ]; then
|
|
echo "DockerInit: could not resolve the latest mtg-multi release tag" >&2
|
|
exit 1
|
|
fi
|
|
mkdir -p build/bin
|
|
cd build/bin
|
|
curl -sfLRO "https://github.com/XTLS/Xray-core/releases/download/v26.6.27/Xray-linux-${ARCH}.zip"
|
|
unzip "Xray-linux-${ARCH}.zip"
|
|
rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat
|
|
mv xray "xray-linux-${FNAME}"
|
|
# mtg-multi (MTProto sidecar) ships prebuilt release binaries for every target
|
|
# we package, so download and unpack the matching one instead of compiling.
|
|
case $FNAME in
|
|
i386) MTGARCH="386" ;;
|
|
arm32) MTGARCH="armv7" ;;
|
|
*) MTGARCH="$FNAME" ;;
|
|
esac
|
|
MTG_PKG="mtg-multi-${MTG_MULTI_VER#v}-linux-${MTGARCH}"
|
|
curl -sfLRO "https://github.com/mhsanaei/mtg-multi/releases/download/${MTG_MULTI_VER}/${MTG_PKG}.tar.gz"
|
|
tar -xzf "${MTG_PKG}.tar.gz"
|
|
mv "${MTG_PKG}/mtg-multi" "mtg-linux-${FNAME}"
|
|
rm -rf "${MTG_PKG}" "${MTG_PKG}.tar.gz"
|
|
chmod +x "mtg-linux-${FNAME}"
|
|
curl -sfLRO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
curl -sfLRO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
curl -sfLRo geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
|
|
curl -sfLRo geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat
|
|
curl -sfLRo geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
curl -sfLRo geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
cd ../../
|