mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-03-02 22:23:01 +00:00
Compare commits
19 commits
3ab566c725
...
fd48ce4ff6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd48ce4ff6 | ||
|
|
70f6d6b21a | ||
|
|
e9757350f3 | ||
|
|
fcf86063f3 | ||
|
|
20ca19233a | ||
|
|
ba07e15695 | ||
|
|
6b6818efa4 | ||
|
|
0430fa8350 | ||
|
|
c7e9018e71 | ||
|
|
11031dad00 | ||
|
|
c4c5aee9ac | ||
|
|
67d4142c3a | ||
|
|
4b8275f15f | ||
|
|
522a2f7349 | ||
|
|
1012636d35 | ||
|
|
e1058b1eaf | ||
|
|
3a2988c068 | ||
|
|
4b9e34aea6 | ||
|
|
0f563dc030 |
20 changed files with 404 additions and 357 deletions
11
.dockerignore
Normal file
11
.dockerignore
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
.git
|
||||||
|
db
|
||||||
|
cert
|
||||||
|
*.log
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
.tmp
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
LICENSE
|
||||||
|
README.*
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,3 +1,6 @@
|
||||||
|
# shared volume
|
||||||
|
geodata/
|
||||||
|
|
||||||
# Ignore editor and IDE settings
|
# Ignore editor and IDE settings
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,25 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
FINISH_FILE="$GEODATA_DIR/cron-job-finished.txt"
|
||||||
|
|
||||||
|
MAX_WAIT=300 # 5 minutes
|
||||||
|
ELAPSED=0
|
||||||
|
INTERVAL=10
|
||||||
|
|
||||||
|
while [ ! -f "$FINISH_FILE" ] && [ $ELAPSED -lt $MAX_WAIT ]; do
|
||||||
|
echo "Still waiting for geodata initialization... ($ELAPSED/$MAX_WAIT seconds)"
|
||||||
|
sleep $INTERVAL
|
||||||
|
ELAPSED=$((ELAPSED + INTERVAL))
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -f "$FINISH_FILE" ]; then
|
||||||
|
echo "ERROR: Geodata initialization timed out after $MAX_WAIT seconds"
|
||||||
|
echo "Container startup aborted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Start fail2ban
|
# Start fail2ban
|
||||||
[ $XUI_ENABLE_FAIL2BAN == "true" ] && fail2ban-client -x start
|
[ "$XUI_ENABLE_FAIL2BAN" = "true" ] && fail2ban-client -x start
|
||||||
|
|
||||||
# Run x-ui
|
# Run x-ui
|
||||||
exec /app/x-ui
|
exec /app/x-ui
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
#!/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
|
|
||||||
mkdir -p build/bin
|
|
||||||
cd build/bin
|
|
||||||
wget -q "https://github.com/XTLS/Xray-core/releases/download/v25.10.15/Xray-linux-${ARCH}.zip"
|
|
||||||
unzip "Xray-linux-${ARCH}.zip"
|
|
||||||
rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat
|
|
||||||
mv xray "xray-linux-${FNAME}"
|
|
||||||
wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
||||||
wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
||||||
wget -q -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
|
|
||||||
wget -q -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat
|
|
||||||
wget -q -O geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
||||||
wget -q -O geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
||||||
cd ../../
|
|
||||||
24
Dockerfile
24
Dockerfile
|
|
@ -2,40 +2,40 @@
|
||||||
# Stage: Builder
|
# Stage: Builder
|
||||||
# ========================================================
|
# ========================================================
|
||||||
FROM golang:1.25-alpine AS builder
|
FROM golang:1.25-alpine AS builder
|
||||||
WORKDIR /app
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
RUN apk --no-cache --update add \
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
build-base \
|
build-base \
|
||||||
gcc \
|
gcc
|
||||||
wget \
|
|
||||||
unzip
|
# docker CACHE
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||||
RUN go build -ldflags "-w -s" -o build/x-ui main.go
|
RUN go build -ldflags "-w -s" -o build/x-ui main.go
|
||||||
RUN ./DockerInit.sh "$TARGETARCH"
|
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
# Stage: Final Image of 3x-ui
|
# Stage: Final Image of 3x-ui
|
||||||
# ========================================================
|
# ========================================================
|
||||||
FROM alpine
|
FROM alpine
|
||||||
ENV TZ=Asia/Tehran
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache --update \
|
RUN apk add --no-cache \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
tzdata \
|
tzdata \
|
||||||
fail2ban \
|
fail2ban \
|
||||||
bash
|
bash
|
||||||
|
|
||||||
|
COPY DockerEntrypoint.sh /app/
|
||||||
COPY --from=builder /app/build/ /app/
|
COPY --from=builder /app/build/ /app/
|
||||||
COPY --from=builder /app/DockerEntrypoint.sh /app/
|
|
||||||
COPY --from=builder /app/x-ui.sh /usr/bin/x-ui
|
COPY --from=builder /app/x-ui.sh /usr/bin/x-ui
|
||||||
|
|
||||||
|
|
||||||
# Configure fail2ban
|
# Configure fail2ban
|
||||||
RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \
|
RUN rm -f /etc/fail2ban/jail.d/alpine-ssh.conf \
|
||||||
&& cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local \
|
&& cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local \
|
||||||
|
|
@ -51,5 +51,5 @@ RUN chmod +x \
|
||||||
ENV XUI_ENABLE_FAIL2BAN="true"
|
ENV XUI_ENABLE_FAIL2BAN="true"
|
||||||
EXPOSE 2053
|
EXPOSE 2053
|
||||||
VOLUME [ "/etc/x-ui" ]
|
VOLUME [ "/etc/x-ui" ]
|
||||||
CMD [ "./x-ui" ]
|
|
||||||
ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]
|
ENTRYPOINT [ "/app/DockerEntrypoint.sh" ]
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,57 @@
|
||||||
services:
|
services:
|
||||||
3xui:
|
3x-ui:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile
|
|
||||||
container_name: 3xui_app
|
container_name: 3xui_app
|
||||||
# hostname: yourhostname <- optional
|
|
||||||
volumes:
|
volumes:
|
||||||
- $PWD/db/:/etc/x-ui/
|
- $PWD/db/:/etc/x-ui/
|
||||||
- $PWD/cert/:/root/cert/
|
- $PWD/cert/:/root/cert/
|
||||||
|
- $PWD/geodata/:/app/bin
|
||||||
environment:
|
environment:
|
||||||
|
TZ: "Asia/Tehran"
|
||||||
XRAY_VMESS_AEAD_FORCED: "false"
|
XRAY_VMESS_AEAD_FORCED: "false"
|
||||||
XUI_ENABLE_FAIL2BAN: "true"
|
XUI_ENABLE_FAIL2BAN: "true"
|
||||||
|
GEODATA_DIR: "/app/bin"
|
||||||
tty: true
|
tty: true
|
||||||
network_mode: host
|
network_mode: host
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- geodata-cron
|
||||||
|
|
||||||
|
docker-proxy:
|
||||||
|
image: tecnativa/docker-socket-proxy
|
||||||
|
container_name: docker_proxy
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- CONTAINERS=1
|
||||||
|
- POST=1
|
||||||
|
- ALLOW_RESTARTS=1
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
networks:
|
||||||
|
- docker-internal
|
||||||
|
|
||||||
|
geodata-cron:
|
||||||
|
build:
|
||||||
|
context: docker-cron-runner
|
||||||
|
args:
|
||||||
|
XRAY_VERSION: "${XRAY_VERSION:-v25.10.15}"
|
||||||
|
XRAY_BUILD_DIR: "/app/xray"
|
||||||
|
container_name: geodata_cron
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- docker-proxy
|
||||||
|
environment:
|
||||||
|
TZ: "UTC"
|
||||||
|
DOCKER_PROXY_URL: "http://docker-proxy:2375"
|
||||||
|
TARGET_CONTAINER_NAME: "3xui_app"
|
||||||
|
CRON_SCHEDULE: "0 */6 * * *"
|
||||||
|
SHARED_VOLUME_PATH: "/app/bin"
|
||||||
|
volumes:
|
||||||
|
- $PWD/geodata/:/app/bin/
|
||||||
|
networks:
|
||||||
|
- docker-internal
|
||||||
|
|
||||||
|
networks:
|
||||||
|
docker-internal:
|
||||||
|
driver: bridge
|
||||||
29
docker-cron-runner/Dockerfile
Normal file
29
docker-cron-runner/Dockerfile
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
FROM alpine:3.20
|
||||||
|
|
||||||
|
ARG TARGETARCH
|
||||||
|
ARG XRAY_VERSION
|
||||||
|
ARG XRAY_BUILD_DIR
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
wget \
|
||||||
|
unzip \
|
||||||
|
curl \
|
||||||
|
bash \
|
||||||
|
ca-certificates \
|
||||||
|
tzdata
|
||||||
|
|
||||||
|
|
||||||
|
COPY xray-tools.sh entrypoint.sh cron-job-script.sh ./
|
||||||
|
|
||||||
|
#RUN mkdir -p "$XRAY_BUILD_DIR"
|
||||||
|
RUN chmod +x /app/xray-tools.sh /app/entrypoint.sh /app/cron-job-script.sh \
|
||||||
|
&& mkdir -p "$XRAY_BUILD_DIR" \
|
||||||
|
&& ./xray-tools.sh install_xray_core "$TARGETARCH" "$XRAY_BUILD_DIR" "$XRAY_VERSION" \
|
||||||
|
&& ./xray-tools.sh update_geodata_in_docker "$XRAY_BUILD_DIR"
|
||||||
|
|
||||||
|
ENV XRAY_BUILD_DIR=${XRAY_BUILD_DIR}
|
||||||
|
|
||||||
|
#CMD ["/app/entrypoint.sh"] \
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
23
docker-cron-runner/cron-job-script.sh
Normal file
23
docker-cron-runner/cron-job-script.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "[$(date)] Starting geodata update..."
|
||||||
|
|
||||||
|
FINISHED_FLAG="${SHARED_VOLUME_PATH}/cron-job-finished.txt"
|
||||||
|
|
||||||
|
if [ -f "$FINISHED_FLAG" ]; then
|
||||||
|
rm -f "$FINISHED_FLAG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/app/xray-tools.sh update_geodata_in_docker "${SHARED_VOLUME_PATH}"
|
||||||
|
touch "$FINISHED_FLAG"
|
||||||
|
|
||||||
|
echo "[$(date)] Geodata update finished, restarting container..."
|
||||||
|
|
||||||
|
HTTP_CODE=$(
|
||||||
|
curl -s -X POST \
|
||||||
|
"${DOCKER_PROXY_URL}/containers/${TARGET_CONTAINER_NAME}/restart" \
|
||||||
|
-o /dev/null -w "%{http_code}"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "[$(date)] Restart request sent, HTTP status: ${HTTP_CODE}"
|
||||||
25
docker-cron-runner/entrypoint.sh
Normal file
25
docker-cron-runner/entrypoint.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
: "${CRON_SCHEDULE:=0 */6 * * *}"
|
||||||
|
: "${DOCKER_PROXY_URL:?DOCKER_PROXY_URL is required}"
|
||||||
|
: "${TARGET_CONTAINER_NAME:?TARGET_CONTAINER_NAME is required}" # required for cron-job-script.sh for container restart
|
||||||
|
: "${SHARED_VOLUME_PATH:?SHARED_VOLUME_PATH is required}"
|
||||||
|
|
||||||
|
CRON_ENV_FILE="/env.sh"
|
||||||
|
|
||||||
|
env | grep -v '^CRON_SCHEDULE=' | sed 's/^/export /' > "$CRON_ENV_FILE"
|
||||||
|
echo "${CRON_SCHEDULE} . ${CRON_ENV_FILE} && /app/cron-job-script.sh >> /var/log/cron.log 2>&1" > /etc/crontabs/root
|
||||||
|
|
||||||
|
echo "Starting crond with schedule: ${CRON_SCHEDULE}"
|
||||||
|
|
||||||
|
mkdir -p /var/log
|
||||||
|
touch /var/log/cron.log
|
||||||
|
|
||||||
|
mkdir -p "$SHARED_VOLUME_PATH"
|
||||||
|
cp -r "$XRAY_BUILD_DIR"/* "$SHARED_VOLUME_PATH"/
|
||||||
|
|
||||||
|
touch "$SHARED_VOLUME_PATH/cron-job-finished.txt" # cron job execution imitation
|
||||||
|
|
||||||
|
exec crond -f -l 2
|
||||||
177
docker-cron-runner/xray-tools.sh
Normal file
177
docker-cron-runner/xray-tools.sh
Normal file
|
|
@ -0,0 +1,177 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
safe_download_and_update() {
|
||||||
|
url="$1"
|
||||||
|
dest="$2"
|
||||||
|
|
||||||
|
# Create a temporary file
|
||||||
|
tmp=$(mktemp "${dest}.XXXXXX") || return 1
|
||||||
|
|
||||||
|
# Download file into a temporary location
|
||||||
|
if wget -q -O "$tmp" "$url"; then
|
||||||
|
# Check that the downloaded file is not empty
|
||||||
|
if [ -s "$tmp" ]; then
|
||||||
|
# Atomically replace the destination file
|
||||||
|
mv "$tmp" "$dest"
|
||||||
|
echo "[OK] Downloaded: $dest"
|
||||||
|
else
|
||||||
|
echo "[ERR] Downloaded file is empty: $url"
|
||||||
|
rm -f "$tmp"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[ERR] Failed to download: $url"
|
||||||
|
rm -f "$tmp"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_all_geofiles() {
|
||||||
|
update_main_geofiles
|
||||||
|
update_ir_geofiles
|
||||||
|
update_ru_geofiles
|
||||||
|
}
|
||||||
|
|
||||||
|
update_main_geofiles() {
|
||||||
|
safe_download_and_update \
|
||||||
|
"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" \
|
||||||
|
"geoip.dat"
|
||||||
|
|
||||||
|
safe_download_and_update \
|
||||||
|
"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" \
|
||||||
|
"geosite.dat"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_ir_geofiles() {
|
||||||
|
safe_download_and_update \
|
||||||
|
"https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat" \
|
||||||
|
"geoip_IR.dat"
|
||||||
|
|
||||||
|
safe_download_and_update \
|
||||||
|
"https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat" \
|
||||||
|
"geosite_IR.dat"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_ru_geofiles() {
|
||||||
|
safe_download_and_update \
|
||||||
|
"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat" \
|
||||||
|
"geoip_RU.dat"
|
||||||
|
|
||||||
|
safe_download_and_update \
|
||||||
|
"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat" \
|
||||||
|
"geosite_RU.dat"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_geodata_in_docker() {
|
||||||
|
XRAYDIR="$1"
|
||||||
|
OLD_DIR=$(pwd)
|
||||||
|
trap 'cd "$OLD_DIR"' EXIT
|
||||||
|
|
||||||
|
echo "[$(date)] Running update_geodata"
|
||||||
|
|
||||||
|
if [ ! -d "$XRAYDIR" ]; then
|
||||||
|
mkdir -p "$XRAYDIR"
|
||||||
|
fi
|
||||||
|
cd "$XRAYDIR"
|
||||||
|
|
||||||
|
update_all_geofiles
|
||||||
|
echo "[$(date)] All geo files have been updated successfully!"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
install_xray_core() {
|
||||||
|
TARGETARCH="$1"
|
||||||
|
XRAYDIR="$2"
|
||||||
|
XRAY_VERSION="$3"
|
||||||
|
|
||||||
|
OLD_DIR=$(pwd)
|
||||||
|
trap 'cd "$OLD_DIR"' EXIT
|
||||||
|
|
||||||
|
echo "[$(date)] Running install_xray_core"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if [ ! -d "$XRAYDIR" ]; then
|
||||||
|
mkdir -p "$XRAYDIR"
|
||||||
|
fi
|
||||||
|
cd "$XRAYDIR"
|
||||||
|
|
||||||
|
wget -q "https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-${ARCH}.zip"
|
||||||
|
|
||||||
|
# Validate the downloaded zip file
|
||||||
|
if [ ! -f "Xray-linux-${ARCH}.zip" ] || [ ! -s "Xray-linux-${ARCH}.zip" ]; then
|
||||||
|
echo "[ERR] Failed to download Xray-core zip or file is empty"
|
||||||
|
cd "$OLD_DIR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
unzip -q "Xray-linux-${ARCH}.zip" -d ./xray-unzip
|
||||||
|
|
||||||
|
# Validate the extracted xray binary
|
||||||
|
if [ ! -f "./xray-unzip/xray" ] || [ ! -s "./xray-unzip/xray" ]; then
|
||||||
|
echo "[ERR] Failed to extract xray binary"
|
||||||
|
rm -rf ./xray-unzip
|
||||||
|
rm -f "Xray-linux-${ARCH}.zip"
|
||||||
|
cd "$OLD_DIR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp ./xray-unzip/xray ./"xray-linux-${FNAME}"
|
||||||
|
rm -r xray-unzip
|
||||||
|
rm "Xray-linux-${ARCH}.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "${0##*/}" = "xray-tools.sh" ]; then
|
||||||
|
cmd="$1"
|
||||||
|
shift || true
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
install_xray_core)
|
||||||
|
# args: TARGETARCH XRAYDIR XRAY_VERSION
|
||||||
|
install_xray_core "$@"
|
||||||
|
;;
|
||||||
|
update_geodata_in_docker)
|
||||||
|
# args: XRAYDIR
|
||||||
|
update_geodata_in_docker "$@"
|
||||||
|
;;
|
||||||
|
update_all_geofiles)
|
||||||
|
update_all_geofiles
|
||||||
|
;;
|
||||||
|
""|help|-h|--help)
|
||||||
|
echo "Usage:"
|
||||||
|
echo " $0 install_xray_core TARGETARCH XRAYDIR XRAY_VERSION"
|
||||||
|
echo " $0 update_geodata_in_docker XRAYDIR"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown command: $cmd" >&2
|
||||||
|
echo "Try: $0 help" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
const oneMinute = 1000 * 60; // MilliseConds in a Minute
|
|
||||||
const oneHour = oneMinute * 60; // The milliseconds of one hour
|
|
||||||
const oneDay = oneHour * 24; // The Number of MilliseConds A Day
|
|
||||||
const oneWeek = oneDay * 7; // The milliseconds per week
|
|
||||||
const oneMonth = oneDay * 30; // The milliseconds of a month
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrease according to the number of days
|
|
||||||
*
|
|
||||||
* @param days to reduce the number of days to be reduced
|
|
||||||
*/
|
|
||||||
Date.prototype.minusDays = function (days) {
|
|
||||||
return this.minusMillis(oneDay * days);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increase according to the number of days
|
|
||||||
*
|
|
||||||
* @param days The number of days to be increased
|
|
||||||
*/
|
|
||||||
Date.prototype.plusDays = function (days) {
|
|
||||||
return this.plusMillis(oneDay * days);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A few
|
|
||||||
*
|
|
||||||
* @param hours to be reduced
|
|
||||||
*/
|
|
||||||
Date.prototype.minusHours = function (hours) {
|
|
||||||
return this.minusMillis(oneHour * hours);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increase hourly
|
|
||||||
*
|
|
||||||
* @param hours to increase the number of hours
|
|
||||||
*/
|
|
||||||
Date.prototype.plusHours = function (hours) {
|
|
||||||
return this.plusMillis(oneHour * hours);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make reduction in minutes
|
|
||||||
*
|
|
||||||
* @param minutes to reduce the number of minutes
|
|
||||||
*/
|
|
||||||
Date.prototype.minusMinutes = function (minutes) {
|
|
||||||
return this.minusMillis(oneMinute * minutes);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add in minutes
|
|
||||||
*
|
|
||||||
* @param minutes to increase the number of minutes
|
|
||||||
*/
|
|
||||||
Date.prototype.plusMinutes = function (minutes) {
|
|
||||||
return this.plusMillis(oneMinute * minutes);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrease in milliseconds
|
|
||||||
*
|
|
||||||
* @param millis to reduce the milliseconds
|
|
||||||
*/
|
|
||||||
Date.prototype.minusMillis = function(millis) {
|
|
||||||
let time = this.getTime() - millis;
|
|
||||||
let newDate = new Date();
|
|
||||||
newDate.setTime(time);
|
|
||||||
return newDate;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add in milliseconds to increase
|
|
||||||
*
|
|
||||||
* @param millis to increase the milliseconds to increase
|
|
||||||
*/
|
|
||||||
Date.prototype.plusMillis = function(millis) {
|
|
||||||
let time = this.getTime() + millis;
|
|
||||||
let newDate = new Date();
|
|
||||||
newDate.setTime(time);
|
|
||||||
return newDate;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setting time is 00: 00: 00.000 on the day
|
|
||||||
*/
|
|
||||||
Date.prototype.setMinTime = function () {
|
|
||||||
this.setHours(0);
|
|
||||||
this.setMinutes(0);
|
|
||||||
this.setSeconds(0);
|
|
||||||
this.setMilliseconds(0);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setting time is 23: 59: 59.999 on the same day
|
|
||||||
*/
|
|
||||||
Date.prototype.setMaxTime = function () {
|
|
||||||
this.setHours(23);
|
|
||||||
this.setMinutes(59);
|
|
||||||
this.setSeconds(59);
|
|
||||||
this.setMilliseconds(999);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formatting date
|
|
||||||
*/
|
|
||||||
Date.prototype.formatDate = function () {
|
|
||||||
return this.getFullYear() + "-" + NumberFormatter.addZero(this.getMonth() + 1) + "-" + NumberFormatter.addZero(this.getDate());
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format time
|
|
||||||
*/
|
|
||||||
Date.prototype.formatTime = function () {
|
|
||||||
return NumberFormatter.addZero(this.getHours()) + ":" + NumberFormatter.addZero(this.getMinutes()) + ":" + NumberFormatter.addZero(this.getSeconds());
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formatting date plus time
|
|
||||||
*
|
|
||||||
* @param split Date and time separation symbols, default is a space
|
|
||||||
*/
|
|
||||||
Date.prototype.formatDateTime = function (split = ' ') {
|
|
||||||
return this.formatDate() + split + this.formatTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
class DateUtil {
|
|
||||||
// String to date object
|
|
||||||
static parseDate(str) {
|
|
||||||
return new Date(str.replace(/-/g, '/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
static formatMillis(millis) {
|
|
||||||
return moment(millis).format('YYYY-M-D HH:mm:ss');
|
|
||||||
}
|
|
||||||
|
|
||||||
static firstDayOfMonth() {
|
|
||||||
const date = new Date();
|
|
||||||
date.setDate(1);
|
|
||||||
date.setMinTime();
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
static convertToJalalian(date) {
|
|
||||||
return date && moment.isMoment(date) ? date.format('jYYYY/jMM/jDD HH:mm:ss') : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -883,3 +883,34 @@ class FileManager {
|
||||||
link.remove();
|
link.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class IntlUtil {
|
||||||
|
static formatDate(date) {
|
||||||
|
const language = LanguageManager.getLanguage()
|
||||||
|
|
||||||
|
let intlOptions = {
|
||||||
|
year: "numeric",
|
||||||
|
month: "numeric",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
second: "numeric"
|
||||||
|
}
|
||||||
|
|
||||||
|
const intl = new Intl.DateTimeFormat(
|
||||||
|
language,
|
||||||
|
intlOptions
|
||||||
|
)
|
||||||
|
|
||||||
|
return intl.format(new Date(date))
|
||||||
|
}
|
||||||
|
static formatRelativeTime(date) {
|
||||||
|
const language = LanguageManager.getLanguage()
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
const diff = Math.round((date - now) / (1000 * 60 * 60 * 24))
|
||||||
|
const formatter = new Intl.RelativeTimeFormat(language, { numeric: 'auto' })
|
||||||
|
|
||||||
|
return formatter.format(diff, 'day');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -44,7 +44,6 @@
|
||||||
<script src="{{ .base_path }}assets/axios/axios.min.js?{{ .cur_ver }}"></script>
|
<script src="{{ .base_path }}assets/axios/axios.min.js?{{ .cur_ver }}"></script>
|
||||||
<script src="{{ .base_path }}assets/qs/qs.min.js"></script>
|
<script src="{{ .base_path }}assets/qs/qs.min.js"></script>
|
||||||
<script src="{{ .base_path }}assets/js/axios-init.js?{{ .cur_ver }}"></script>
|
<script src="{{ .base_path }}assets/js/axios-init.js?{{ .cur_ver }}"></script>
|
||||||
<script src="{{ .base_path }}assets/js/util/date-util.js?{{ .cur_ver }}"></script>
|
|
||||||
<script src="{{ .base_path }}assets/js/util/index.js?{{ .cur_ver }}"></script>
|
<script src="{{ .base_path }}assets/js/util/index.js?{{ .cur_ver }}"></script>
|
||||||
<script>
|
<script>
|
||||||
const basePath = '{{ .base_path }}';
|
const basePath = '{{ .base_path }}';
|
||||||
|
|
|
||||||
|
|
@ -111,20 +111,12 @@
|
||||||
<template v-if="client.expiryTime !=0 && client.reset >0">
|
<template v-if="client.expiryTime !=0 && client.reset >0">
|
||||||
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
|
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
|
||||||
</span>
|
<span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
|
||||||
<span v-else>
|
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
|
||||||
[[ DateUtil.formatMillis(client._expiryTime) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
<table>
|
<table>
|
||||||
<tr class="tr-table-box">
|
<tr class="tr-table-box">
|
||||||
<td class="tr-table-rt"> [[ remainedDays(client.expiryTime) ]] </td>
|
<td class="tr-table-rt"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </td>
|
||||||
<td class="infinite-bar tr-table-bar">
|
<td class="infinite-bar tr-table-bar">
|
||||||
<a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
|
<a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -136,18 +128,10 @@
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
|
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
|
||||||
</span>
|
<span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
|
||||||
<span v-else>
|
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
|
||||||
[[ DateUtil.formatMillis(client._expiryTime) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
|
<a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" :style="{ border: 'none' }" class="infinite-tag">
|
<a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" :style="{ border: 'none' }" class="infinite-tag">
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
|
|
@ -232,20 +216,12 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<template v-if="client.expiryTime !=0 && client.reset >0">
|
<template v-if="client.expiryTime !=0 && client.reset >0">
|
||||||
<td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ remainedDays(client.expiryTime) ]] </td>
|
<td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </td>
|
||||||
<td width="120px" class="infinite-bar">
|
<td width="120px" class="infinite-bar">
|
||||||
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
|
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
|
||||||
</span>
|
<span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
|
||||||
<span v-else>
|
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
|
||||||
[[ DateUtil.formatMillis(client._expiryTime) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
<a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
|
<a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
|
||||||
</a-popover>
|
</a-popover>
|
||||||
|
|
@ -256,18 +232,10 @@
|
||||||
<td colspan="3" :style="{ textAlign: 'center' }">
|
<td colspan="3" :style="{ textAlign: 'center' }">
|
||||||
<a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}
|
<span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
|
||||||
</span>
|
<span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
|
||||||
<span v-else>
|
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
|
||||||
[[ DateUtil.formatMillis(client._expiryTime) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]]
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag>
|
<a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag">
|
<a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag">
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
|
|
@ -289,12 +257,7 @@
|
||||||
</template>
|
</template>
|
||||||
<template slot="createdAt" slot-scope="text, client, index">
|
<template slot="createdAt" slot-scope="text, client, index">
|
||||||
<template v-if="client.created_at">
|
<template v-if="client.created_at">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
[[ IntlUtil.formatDate(client.created_at) ]]
|
||||||
[[ DateUtil.formatMillis(client.created_at) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(client.created_at)) ]]
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
-
|
-
|
||||||
|
|
@ -302,12 +265,7 @@
|
||||||
</template>
|
</template>
|
||||||
<template slot="updatedAt" slot-scope="text, client, index">
|
<template slot="updatedAt" slot-scope="text, client, index">
|
||||||
<template v-if="client.updated_at">
|
<template v-if="client.updated_at">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
[[ IntlUtil.formatDate(client.updated_at) ]]
|
||||||
[[ DateUtil.formatMillis(client.updated_at) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(client.updated_at)) ]]
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
-
|
-
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,7 @@
|
||||||
<br v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0">
|
<br v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0">
|
||||||
<span v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0">
|
<span v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0">
|
||||||
<strong>{{ i18n "pages.inbounds.lastReset" }}:</strong>
|
<strong>{{ i18n "pages.inbounds.lastReset" }}:</strong>
|
||||||
<span v-if="datepicker == 'gregorian'">[[
|
<span>[[ IntlUtil.formatDate(dbInbound.lastTrafficResetTime) ]]</span>
|
||||||
moment(dbInbound.lastTrafficResetTime).format('YYYY-MM-DD HH:mm:ss') ]]</span>
|
|
||||||
<span v-else>[[ DateUtil.convertToJalalian(moment(dbInbound.lastTrafficResetTime)) ]]</span>
|
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
{{ i18n "pages.inbounds.periodicTrafficResetTitle" }}
|
{{ i18n "pages.inbounds.periodicTrafficResetTitle" }}
|
||||||
|
|
|
||||||
|
|
@ -384,15 +384,12 @@
|
||||||
</template>
|
</template>
|
||||||
<template slot="expiryTime" slot-scope="text, dbInbound">
|
<template slot="expiryTime" slot-scope="text, dbInbound">
|
||||||
<a-popover v-if="dbInbound.expiryTime > 0" :overlay-class-name="themeSwitcher.currentTheme">
|
<a-popover v-if="dbInbound.expiryTime > 0" :overlay-class-name="themeSwitcher.currentTheme">
|
||||||
<template slot="content" v-if="app.datepicker === 'gregorian'">
|
<template slot="content">
|
||||||
[[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
|
[[ IntlUtil.formatDate(dbInbound.expiryTime) ]]
|
||||||
</template>
|
|
||||||
<template v-else slot="content">
|
|
||||||
[[ DateUtil.convertToJalalian(moment(dbInbound.expiryTime)) ]]
|
|
||||||
</template>
|
</template>
|
||||||
<a-tag :style="{ minWidth: '50px' }"
|
<a-tag :style="{ minWidth: '50px' }"
|
||||||
:color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, dbInbound._expiryTime)">
|
:color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, dbInbound._expiryTime)">
|
||||||
[[ remainedDays(dbInbound._expiryTime) ]]
|
[[ IntlUtil.formatRelativeTime(dbInbound.expiryTime) ]]
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</a-popover>
|
</a-popover>
|
||||||
<a-tag v-else color="purple" class="infinite-tag">
|
<a-tag v-else color="purple" class="infinite-tag">
|
||||||
|
|
@ -549,12 +546,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a-tag :style="{ minWidth: '50px', textAlign: 'center' }"
|
<a-tag :style="{ minWidth: '50px', textAlign: 'center' }"
|
||||||
v-if="dbInbound.expiryTime > 0" :color="dbInbound.isExpiry? 'red': 'blue'">
|
v-if="dbInbound.expiryTime > 0" :color="dbInbound.isExpiry? 'red': 'blue'">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
[[ IntlUtil.formatDate(dbInbound.expiryTime) ]]
|
||||||
[[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(dbInbound.expiryTime)) ]]
|
|
||||||
</template>
|
|
||||||
</a-tag>
|
</a-tag>
|
||||||
<a-tag v-else :style="{ textAlign: 'center' }" color="purple" class="infinite-tag">
|
<a-tag v-else :style="{ textAlign: 'center' }" color="purple" class="infinite-tag">
|
||||||
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
<svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
|
||||||
|
|
@ -1407,13 +1399,6 @@
|
||||||
if (remainedSeconds >= resetSeconds) return 0;
|
if (remainedSeconds >= resetSeconds) return 0;
|
||||||
return 100 * (1 - (remainedSeconds / resetSeconds));
|
return 100 * (1 - (remainedSeconds / resetSeconds));
|
||||||
},
|
},
|
||||||
remainedDays(expTime) {
|
|
||||||
if (expTime == 0) return null;
|
|
||||||
if (expTime < 0) return TimeFormatter.formatSecond(expTime / -1000);
|
|
||||||
now = new Date().getTime();
|
|
||||||
if (expTime < now) return '{{ i18n "depleted" }}';
|
|
||||||
return TimeFormatter.formatSecond((expTime - now) / 1000);
|
|
||||||
},
|
|
||||||
statsExpColor(dbInbound, email) {
|
statsExpColor(dbInbound, email) {
|
||||||
if (email.length == 0) return '#7a316f';
|
if (email.length == 0) return '#7a316f';
|
||||||
clientStats = dbInbound.clientStats.find(stats => stats.email === email);
|
clientStats = dbInbound.clientStats.find(stats => stats.email === email);
|
||||||
|
|
@ -1458,10 +1443,7 @@
|
||||||
formatLastOnline(email) {
|
formatLastOnline(email) {
|
||||||
const ts = this.getLastOnline(email)
|
const ts = this.getLastOnline(email)
|
||||||
if (!ts) return '-'
|
if (!ts) return '-'
|
||||||
if (this.datepicker === 'gregorian') {
|
return IntlUtil.formatDate(ts)
|
||||||
return DateUtil.formatMillis(ts)
|
|
||||||
}
|
|
||||||
return DateUtil.convertToJalalian(moment(ts))
|
|
||||||
},
|
},
|
||||||
isRemovable(dbInboundId) {
|
isRemovable(dbInboundId) {
|
||||||
return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInboundId)).length > 1;
|
return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInboundId)).length > 1;
|
||||||
|
|
|
||||||
|
|
@ -844,11 +844,9 @@
|
||||||
text = `<td>${log.Email}</td>`;
|
text = `<td>${log.Email}</td>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { locale, timeZone } = Intl.DateTimeFormat().resolvedOptions();
|
|
||||||
|
|
||||||
formattedLogs += `
|
formattedLogs += `
|
||||||
<tr ${outboundColor}>
|
<tr ${outboundColor}>
|
||||||
<td><b>${new Date(log.DateTime).toLocaleString(locale, { timeZone })}</b></td>
|
<td><b>${IntlUtil.formatDate(log.DateTime)}</b></td>
|
||||||
<td>${log.FromAddress}</td>
|
<td>${log.FromAddress}</td>
|
||||||
<td>${log.ToAddress}</td>
|
<td>${log.ToAddress}</td>
|
||||||
<td>${log.Inbound}</td>
|
<td>${log.Inbound}</td>
|
||||||
|
|
|
||||||
|
|
@ -199,12 +199,7 @@
|
||||||
<td>{{ i18n "pages.inbounds.createdAt" }}</td>
|
<td>{{ i18n "pages.inbounds.createdAt" }}</td>
|
||||||
<td>
|
<td>
|
||||||
<template v-if="infoModal.clientSettings && infoModal.clientSettings.created_at">
|
<template v-if="infoModal.clientSettings && infoModal.clientSettings.created_at">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
<a-tag>[[ IntlUtil.formatDate(infoModal.clientSettings.created_at) ]]</a-tag>
|
||||||
<a-tag>[[ DateUtil.formatMillis(infoModal.clientSettings.created_at) ]]</a-tag>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<a-tag>[[ DateUtil.convertToJalalian(moment(infoModal.clientSettings.created_at)) ]]</a-tag>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<a-tag>-</a-tag>
|
<a-tag>-</a-tag>
|
||||||
|
|
@ -215,12 +210,7 @@
|
||||||
<td>{{ i18n "pages.inbounds.updatedAt" }}</td>
|
<td>{{ i18n "pages.inbounds.updatedAt" }}</td>
|
||||||
<td>
|
<td>
|
||||||
<template v-if="infoModal.clientSettings && infoModal.clientSettings.updated_at">
|
<template v-if="infoModal.clientSettings && infoModal.clientSettings.updated_at">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
<a-tag>[[ IntlUtil.formatDate(infoModal.clientSettings.updated_at) ]]</a-tag>
|
||||||
<a-tag>[[ DateUtil.formatMillis(infoModal.clientSettings.updated_at) ]]</a-tag>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<a-tag>[[ DateUtil.convertToJalalian(moment(infoModal.clientSettings.updated_at)) ]]</a-tag>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<a-tag>-</a-tag>
|
<a-tag>-</a-tag>
|
||||||
|
|
@ -282,12 +272,7 @@
|
||||||
<td>
|
<td>
|
||||||
<template v-if="infoModal.clientSettings.expiryTime > 0">
|
<template v-if="infoModal.clientSettings.expiryTime > 0">
|
||||||
<a-tag :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)">
|
<a-tag :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)">
|
||||||
<template v-if="app.datepicker === 'gregorian'">
|
[[ IntlUtil.formatDate(infoModal.clientSettings.expiryTime) ]]
|
||||||
[[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[ DateUtil.convertToJalalian(moment(infoModal.clientSettings.expiryTime)) ]]
|
|
||||||
</template>
|
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</template>
|
</template>
|
||||||
<a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="green">[[ infoModal.clientSettings.expiryTime / -86400000 ]] {{ i18n "pages.client.days" }}
|
<a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="green">[[ infoModal.clientSettings.expiryTime / -86400000 ]] {{ i18n "pages.client.days" }}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
<script src="{{ .base_path }}assets/vue/vue.min.js?{{ .cur_ver }}"></script>
|
<script src="{{ .base_path }}assets/vue/vue.min.js?{{ .cur_ver }}"></script>
|
||||||
<script src="{{ .base_path }}assets/ant-design-vue/antd.min.js"></script>
|
<script src="{{ .base_path }}assets/ant-design-vue/antd.min.js"></script>
|
||||||
<script src="{{ .base_path }}assets/js/util/index.js?{{ .cur_ver }}"></script>
|
<script src="{{ .base_path }}assets/js/util/index.js?{{ .cur_ver }}"></script>
|
||||||
<script src="{{ .base_path }}assets/js/util/date-util.js?{{ .cur_ver }}"></script>
|
|
||||||
<script src="{{ .base_path }}assets/qrcode/qrious2.min.js?{{ .cur_ver }}"></script>
|
<script src="{{ .base_path }}assets/qrcode/qrious2.min.js?{{ .cur_ver }}"></script>
|
||||||
{{ template "page/head_end" .}}
|
{{ template "page/head_end" .}}
|
||||||
|
|
||||||
|
|
@ -141,17 +140,7 @@
|
||||||
<a-descriptions-item
|
<a-descriptions-item
|
||||||
label='{{ i18n "lastOnline" }}'>
|
label='{{ i18n "lastOnline" }}'>
|
||||||
<template v-if="app.lastOnlineMs > 0">
|
<template v-if="app.lastOnlineMs > 0">
|
||||||
<template
|
[[ IntlUtil.formatDate(app.lastOnlineMs) ]]
|
||||||
v-if="app.datepicker === 'gregorian'">
|
|
||||||
[[
|
|
||||||
DateUtil.formatMillis(app.lastOnlineMs)
|
|
||||||
]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[
|
|
||||||
DateUtil.convertToJalalian(moment(app.lastOnlineMs))
|
|
||||||
]]
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span>-</span>
|
<span>-</span>
|
||||||
|
|
@ -163,17 +152,7 @@
|
||||||
{{ i18n "subscription.noExpiry" }}
|
{{ i18n "subscription.noExpiry" }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<template
|
[[ IntlUtil.formatDate(app.expireMs) ]]
|
||||||
v-if="app.datepicker === 'gregorian'">
|
|
||||||
[[
|
|
||||||
DateUtil.formatMillis(app.expireMs)
|
|
||||||
]]
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
[[
|
|
||||||
DateUtil.convertToJalalian(moment(app.expireMs))
|
|
||||||
]]
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</a-descriptions-item>
|
</a-descriptions-item>
|
||||||
</a-descriptions>
|
</a-descriptions>
|
||||||
|
|
|
||||||
27
x-ui.sh
27
x-ui.sh
|
|
@ -6,6 +6,8 @@ blue='\033[0;34m'
|
||||||
yellow='\033[0;33m'
|
yellow='\033[0;33m'
|
||||||
plain='\033[0m'
|
plain='\033[0m'
|
||||||
|
|
||||||
|
source docker-cron-runner/xray-tools.sh
|
||||||
|
|
||||||
#Add some basic function here
|
#Add some basic function here
|
||||||
function LOGD() {
|
function LOGD() {
|
||||||
echo -e "${yellow}[DEG] $* ${plain}"
|
echo -e "${yellow}[DEG] $* ${plain}"
|
||||||
|
|
@ -44,7 +46,7 @@ iplimit_log_path="${log_folder}/3xipl.log"
|
||||||
iplimit_banned_log_path="${log_folder}/3xipl-banned.log"
|
iplimit_banned_log_path="${log_folder}/3xipl-banned.log"
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
if [[ $# > 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
echo && read -rp "$1 [Default $2]: " temp
|
echo && read -rp "$1 [Default $2]: " temp
|
||||||
if [[ "${temp}" == "" ]]; then
|
if [[ "${temp}" == "" ]]; then
|
||||||
temp=$2
|
temp=$2
|
||||||
|
|
@ -867,27 +869,6 @@ delete_ports() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_all_geofiles() {
|
|
||||||
update_main_geofiles
|
|
||||||
update_ir_geofiles
|
|
||||||
update_ru_geofiles
|
|
||||||
}
|
|
||||||
|
|
||||||
update_main_geofiles() {
|
|
||||||
wget -O geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
||||||
wget -O geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
||||||
}
|
|
||||||
|
|
||||||
update_ir_geofiles() {
|
|
||||||
wget -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
|
|
||||||
wget -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat
|
|
||||||
}
|
|
||||||
|
|
||||||
update_ru_geofiles() {
|
|
||||||
wget -O geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat
|
|
||||||
wget -O geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat
|
|
||||||
}
|
|
||||||
|
|
||||||
update_geo() {
|
update_geo() {
|
||||||
echo -e "${green}\t1.${plain} Loyalsoldier (geoip.dat, geosite.dat)"
|
echo -e "${green}\t1.${plain} Loyalsoldier (geoip.dat, geosite.dat)"
|
||||||
echo -e "${green}\t2.${plain} chocolate4u (geoip_IR.dat, geosite_IR.dat)"
|
echo -e "${green}\t2.${plain} chocolate4u (geoip_IR.dat, geosite_IR.dat)"
|
||||||
|
|
@ -2038,7 +2019,7 @@ show_menu() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# > 0 ]]; then
|
if [[ $# -gt 0 ]]; then
|
||||||
case $1 in
|
case $1 in
|
||||||
"start")
|
"start")
|
||||||
check_install 0 && start 0
|
check_install 0 && start 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue