mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-21 14:42:19 +07:00
feat(update): add rolling dev update channel for per-commit builds
Adds an opt-in Dev channel so panels running CI per-commit builds can self-update to the latest commit, mirroring the stable online-update flow. CI publishes/overwrites a single fixed-tag pre-release (dev-latest), force-moved to the newest main commit and marked --latest=false so releases/latest stays the stable tag. Builds stamp the short commit via -ldflags; the panel compares the running commit to the dev release commit to detect an update, and update.sh honors XUI_UPDATE_TAG to install from that tag. Linux/systemd only.
This commit is contained in:
@@ -97,7 +97,13 @@ jobs:
|
|||||||
export CC=$(realpath "$(find "$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
|
export CC=$(realpath "$(find "$TOOLCHAIN_DIR/bin" -name '*-gcc.br_real' -type f -executable | head -n1)")
|
||||||
[ -z "$CC" ] && { echo "No gcc.br_real found in $TOOLCHAIN_DIR/bin" >&2; exit 1; }
|
[ -z "$CC" ] && { echo "No gcc.br_real found in $TOOLCHAIN_DIR/bin" >&2; exit 1; }
|
||||||
cd -
|
cd -
|
||||||
go build -ldflags "-w -s -linkmode external -extldflags '-static'" -o xui-release -v main.go
|
# Stamp the commit into per-commit (dev channel) builds only; tagged
|
||||||
|
# stable releases stay unstamped so config.IsDevBuild() returns false.
|
||||||
|
LDFLAGS="-w -s -linkmode external -extldflags '-static'"
|
||||||
|
if [[ "$GITHUB_REF" != refs/tags/* ]]; then
|
||||||
|
LDFLAGS="$LDFLAGS -X github.com/mhsanaei/3x-ui/v3/internal/config.buildCommit=${GITHUB_SHA::8} -X github.com/mhsanaei/3x-ui/v3/internal/config.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
fi
|
||||||
|
go build -ldflags "$LDFLAGS" -o xui-release -v main.go
|
||||||
file xui-release
|
file xui-release
|
||||||
ldd xui-release || echo "Static binary confirmed"
|
ldd xui-release || echo "Static binary confirmed"
|
||||||
|
|
||||||
@@ -245,7 +251,12 @@ jobs:
|
|||||||
go version
|
go version
|
||||||
gcc --version
|
gcc --version
|
||||||
|
|
||||||
go build -ldflags "-w -s" -o xui-release.exe -v main.go
|
# Stamp the commit into per-commit (dev channel) builds only.
|
||||||
|
LDFLAGS="-w -s"
|
||||||
|
if [[ "$GITHUB_REF" != refs/tags/* ]]; then
|
||||||
|
LDFLAGS="$LDFLAGS -X github.com/mhsanaei/3x-ui/v3/internal/config.buildCommit=${GITHUB_SHA:0:8} -X github.com/mhsanaei/3x-ui/v3/internal/config.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
fi
|
||||||
|
go build -ldflags "$LDFLAGS" -o xui-release.exe -v main.go
|
||||||
|
|
||||||
- name: Copy and download resources
|
- name: Copy and download resources
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
@@ -302,3 +313,61 @@ jobs:
|
|||||||
asset_name: x-ui-windows-amd64.zip
|
asset_name: x-ui-windows-amd64.zip
|
||||||
overwrite: true
|
overwrite: true
|
||||||
prerelease: true
|
prerelease: true
|
||||||
|
|
||||||
|
# =================================
|
||||||
|
# Rolling dev channel (per-commit)
|
||||||
|
# =================================
|
||||||
|
# Publishes/overwrites the build artifacts to a single fixed-tag pre-release
|
||||||
|
# `dev-latest`, force-moved to the new commit on every push to main. The panel's
|
||||||
|
# "Dev" update channel installs from this tag. `--latest=false` is load-bearing:
|
||||||
|
# it keeps releases/latest pointing at the real stable tag, so the stable
|
||||||
|
# channel is unaffected.
|
||||||
|
publish-dev:
|
||||||
|
name: Publish rolling dev release
|
||||||
|
needs: [build, build-windows]
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
# Serialize racing pushes; never cancel an in-flight upload, or the dev
|
||||||
|
# release could be left with a partial asset set.
|
||||||
|
concurrency:
|
||||||
|
group: dev-release
|
||||||
|
cancel-in-progress: false
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- name: Download all build artifacts
|
||||||
|
uses: actions/download-artifact@v7
|
||||||
|
with:
|
||||||
|
path: dev-artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Publish dev-latest pre-release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
COMMIT: ${{ github.sha }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
short="${COMMIT::8}"
|
||||||
|
notes="Rolling development build — installs via the panel's Dev update channel.
|
||||||
|
|
||||||
|
commit=${COMMIT}
|
||||||
|
built=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
|
|
||||||
|
Automated per-commit build from main. Not a stable release."
|
||||||
|
|
||||||
|
# Force-move the dev-latest tag to this commit so the release tracks it.
|
||||||
|
git tag -f dev-latest "${COMMIT}"
|
||||||
|
git push -f origin refs/tags/dev-latest
|
||||||
|
|
||||||
|
if gh release view dev-latest >/dev/null 2>&1; then
|
||||||
|
gh release edit dev-latest --prerelease --latest=false \
|
||||||
|
--title "Dev build ${short}" --notes "${notes}"
|
||||||
|
else
|
||||||
|
gh release create dev-latest --prerelease --latest=false \
|
||||||
|
--target "${COMMIT}" --title "Dev build ${short}" --notes "${notes}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
gh release upload dev-latest dev-artifacts/*.tar.gz dev-artifacts/*.zip --clobber
|
||||||
|
|||||||
@@ -4240,6 +4240,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/panel/api/server/setUpdateChannel": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"Server"
|
||||||
|
],
|
||||||
|
"summary": "Toggle the panel update channel between stable and the rolling per-commit dev release. Only effective on dev builds.",
|
||||||
|
"operationId": "post_panel_api_server_setUpdateChannel",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"example": {
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful response",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"success": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"msg": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"obj": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/panel/api/server/updateGeofile": {
|
"/panel/api/server/updateGeofile": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|||||||
@@ -400,6 +400,12 @@ export const sections: readonly Section[] = [
|
|||||||
path: '/panel/api/server/updatePanel',
|
path: '/panel/api/server/updatePanel',
|
||||||
summary: 'Self-update the panel to the latest version. The server restarts on success.',
|
summary: 'Self-update the panel to the latest version. The server restarts on success.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
path: '/panel/api/server/setUpdateChannel',
|
||||||
|
summary: 'Toggle the panel update channel between stable and the rolling per-commit dev release. Only effective on dev builds.',
|
||||||
|
body: '{\n "dev": true\n}',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/panel/api/server/updateGeofile',
|
path: '/panel/api/server/updateGeofile',
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ export default function IndexPage() {
|
|||||||
useEffect(() => { setMessageInstance(messageApi); }, [messageApi]);
|
useEffect(() => { setMessageInstance(messageApi); }, [messageApi]);
|
||||||
|
|
||||||
const [accessLogEnable, setAccessLogEnable] = useState(false);
|
const [accessLogEnable, setAccessLogEnable] = useState(false);
|
||||||
|
const [isDevBuild, setIsDevBuild] = useState(false);
|
||||||
|
const [devChannelEnable, setDevChannelEnable] = useState(false);
|
||||||
const [panelUpdateInfo, setPanelUpdateInfo] = useState<PanelUpdateInfo>({
|
const [panelUpdateInfo, setPanelUpdateInfo] = useState<PanelUpdateInfo>({
|
||||||
currentVersion: '',
|
currentVersion: '',
|
||||||
latestVersion: '',
|
latestVersion: '',
|
||||||
@@ -87,8 +89,14 @@ export default function IndexPage() {
|
|||||||
const [loadingTip, setLoadingTip] = useState(t('loading'));
|
const [loadingTip, setLoadingTip] = useState(t('loading'));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
HttpUtil.post<{ accessLogEnable?: boolean }>('/panel/api/setting/defaultSettings').then((msg) => {
|
HttpUtil.post<{ accessLogEnable?: boolean; isDevBuild?: boolean; devChannelEnable?: boolean }>(
|
||||||
if (msg?.success && msg.obj) setAccessLogEnable(!!msg.obj.accessLogEnable);
|
'/panel/api/setting/defaultSettings',
|
||||||
|
).then((msg) => {
|
||||||
|
if (msg?.success && msg.obj) {
|
||||||
|
setAccessLogEnable(!!msg.obj.accessLogEnable);
|
||||||
|
setIsDevBuild(!!msg.obj.isDevBuild);
|
||||||
|
setDevChannelEnable(!!msg.obj.devChannelEnable);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
HttpUtil.get<PanelUpdateInfo>('/panel/api/server/getPanelUpdateInfo').then((msg) => {
|
HttpUtil.get<PanelUpdateInfo>('/panel/api/server/getPanelUpdateInfo').then((msg) => {
|
||||||
if (msg?.success && msg.obj) setPanelUpdateInfo(msg.obj);
|
if (msg?.success && msg.obj) setPanelUpdateInfo(msg.obj);
|
||||||
@@ -119,13 +127,21 @@ export default function IndexPage() {
|
|||||||
}, [refresh]);
|
}, [refresh]);
|
||||||
|
|
||||||
function openPanelVersion() {
|
function openPanelVersion() {
|
||||||
if (panelUpdateInfo.updateAvailable) {
|
if (panelUpdateInfo.updateAvailable || isDevBuild) {
|
||||||
setPanelUpdateOpen(true);
|
setPanelUpdateOpen(true);
|
||||||
} else {
|
} else {
|
||||||
window.open('https://github.com/MHSanaei/3x-ui/releases', '_blank', 'noopener,noreferrer');
|
window.open('https://github.com/MHSanaei/3x-ui/releases', '_blank', 'noopener,noreferrer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleChannelChange(dev: boolean) {
|
||||||
|
const res = await HttpUtil.post('/panel/api/server/setUpdateChannel', { dev });
|
||||||
|
if (!res?.success) return;
|
||||||
|
setDevChannelEnable(dev);
|
||||||
|
const msg = await HttpUtil.get<PanelUpdateInfo>('/panel/api/server/getPanelUpdateInfo');
|
||||||
|
if (msg?.success && msg.obj) setPanelUpdateInfo(msg.obj);
|
||||||
|
}
|
||||||
|
|
||||||
function openTelegram() {
|
function openTelegram() {
|
||||||
window.open('https://t.me/XrayUI', '_blank', 'noopener,noreferrer');
|
window.open('https://t.me/XrayUI', '_blank', 'noopener,noreferrer');
|
||||||
}
|
}
|
||||||
@@ -224,7 +240,9 @@ export default function IndexPage() {
|
|||||||
{isMobile && displayVersion && (
|
{isMobile && displayVersion && (
|
||||||
<Tag color={panelUpdateInfo.updateAvailable ? 'orange' : 'green'}>
|
<Tag color={panelUpdateInfo.updateAvailable ? 'orange' : 'green'}>
|
||||||
{panelUpdateInfo.updateAvailable
|
{panelUpdateInfo.updateAvailable
|
||||||
? `v${panelUpdateInfo.latestVersion}`
|
? panelUpdateInfo.channel === 'dev'
|
||||||
|
? panelUpdateInfo.latestVersion
|
||||||
|
: `v${panelUpdateInfo.latestVersion}`
|
||||||
: `v${displayVersion}`}
|
: `v${displayVersion}`}
|
||||||
</Tag>
|
</Tag>
|
||||||
)}
|
)}
|
||||||
@@ -446,6 +464,9 @@ export default function IndexPage() {
|
|||||||
<PanelUpdateModal
|
<PanelUpdateModal
|
||||||
open={panelUpdateOpen}
|
open={panelUpdateOpen}
|
||||||
info={panelUpdateInfo}
|
info={panelUpdateInfo}
|
||||||
|
isDevBuild={isDevBuild}
|
||||||
|
devChannelEnable={devChannelEnable}
|
||||||
|
onChannelChange={handleChannelChange}
|
||||||
onClose={() => setPanelUpdateOpen(false)}
|
onClose={() => setPanelUpdateOpen(false)}
|
||||||
onBusy={setBusy}
|
onBusy={setBusy}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Alert, Button, Modal, Tag } from 'antd';
|
import { Alert, Button, Modal, Switch, Tag } from 'antd';
|
||||||
import { CloudDownloadOutlined } from '@ant-design/icons';
|
import { CloudDownloadOutlined } from '@ant-design/icons';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
@@ -7,8 +8,11 @@ import { HttpUtil, PromiseUtil } from '@/utils';
|
|||||||
import './PanelUpdateModal.css';
|
import './PanelUpdateModal.css';
|
||||||
|
|
||||||
export interface PanelUpdateInfo {
|
export interface PanelUpdateInfo {
|
||||||
|
channel?: string;
|
||||||
currentVersion: string;
|
currentVersion: string;
|
||||||
latestVersion: string;
|
latestVersion: string;
|
||||||
|
currentCommit?: string;
|
||||||
|
latestCommit?: string;
|
||||||
updateAvailable: boolean;
|
updateAvailable: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,13 +24,27 @@ interface BusyEvent {
|
|||||||
interface PanelUpdateModalProps {
|
interface PanelUpdateModalProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
info: PanelUpdateInfo;
|
info: PanelUpdateInfo;
|
||||||
|
isDevBuild?: boolean;
|
||||||
|
devChannelEnable?: boolean;
|
||||||
|
onChannelChange?: (dev: boolean) => void | Promise<void>;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onBusy: (e: BusyEvent) => void;
|
onBusy: (e: BusyEvent) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PanelUpdateModal({ open, info, onClose, onBusy }: PanelUpdateModalProps) {
|
export default function PanelUpdateModal({
|
||||||
|
open,
|
||||||
|
info,
|
||||||
|
isDevBuild,
|
||||||
|
devChannelEnable,
|
||||||
|
onChannelChange,
|
||||||
|
onClose,
|
||||||
|
onBusy,
|
||||||
|
}: PanelUpdateModalProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [modal, contextHolder] = Modal.useModal();
|
const [modal, contextHolder] = Modal.useModal();
|
||||||
|
const [channelBusy, setChannelBusy] = useState(false);
|
||||||
|
|
||||||
|
const isDev = info.channel === 'dev';
|
||||||
|
|
||||||
async function pollUntilBack(): Promise<boolean> {
|
async function pollUntilBack(): Promise<boolean> {
|
||||||
await PromiseUtil.sleep(5000);
|
await PromiseUtil.sleep(5000);
|
||||||
@@ -43,6 +61,16 @@ export default function PanelUpdateModal({ open, info, onClose, onBusy }: PanelU
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleChannel(checked: boolean) {
|
||||||
|
if (!onChannelChange) return;
|
||||||
|
setChannelBusy(true);
|
||||||
|
try {
|
||||||
|
await onChannelChange(checked);
|
||||||
|
} finally {
|
||||||
|
setChannelBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updatePanel() {
|
function updatePanel() {
|
||||||
modal.confirm({
|
modal.confirm({
|
||||||
title: t('pages.index.panelUpdateDialog'),
|
title: t('pages.index.panelUpdateDialog'),
|
||||||
@@ -84,15 +112,41 @@ export default function PanelUpdateModal({ open, info, onClose, onBusy }: PanelU
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{isDevBuild && (
|
||||||
|
<div className="version-list">
|
||||||
|
<div className="version-list-item">
|
||||||
|
<span>{t('pages.index.devChannel')}</span>
|
||||||
|
<Switch
|
||||||
|
checked={!!devChannelEnable}
|
||||||
|
loading={channelBusy}
|
||||||
|
onChange={handleChannel}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{devChannelEnable && (
|
||||||
|
<Alert
|
||||||
|
type="info"
|
||||||
|
className="mb-12"
|
||||||
|
title={t('pages.index.devChannelWarning')}
|
||||||
|
showIcon
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="version-list">
|
<div className="version-list">
|
||||||
<div className="version-list-item">
|
<div className="version-list-item">
|
||||||
<span>{t('pages.index.currentPanelVersion')}</span>
|
<span>{isDev ? t('pages.index.currentCommit') : t('pages.index.currentPanelVersion')}</span>
|
||||||
<Tag color="green">v{info.currentVersion || '?'}</Tag>
|
{isDev ? (
|
||||||
|
<Tag color="green">{info.currentCommit || '?'}</Tag>
|
||||||
|
) : (
|
||||||
|
<Tag color="green">v{info.currentVersion || '?'}</Tag>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{info.updateAvailable ? (
|
{info.updateAvailable ? (
|
||||||
<div className="version-list-item">
|
<div className="version-list-item">
|
||||||
<span>{t('pages.index.latestPanelVersion')}</span>
|
<span>{isDev ? t('pages.index.latestCommit') : t('pages.index.latestPanelVersion')}</span>
|
||||||
<Tag color="purple">{info.latestVersion || '-'}</Tag>
|
<Tag color="purple">{(isDev ? info.latestCommit : info.latestVersion) || '-'}</Tag>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="version-list-item">
|
<div className="version-list-item">
|
||||||
|
|||||||
@@ -20,6 +20,15 @@ var version string
|
|||||||
//go:embed name
|
//go:embed name
|
||||||
var name string
|
var name string
|
||||||
|
|
||||||
|
// buildCommit and buildDate are injected at build time via `-ldflags -X` for
|
||||||
|
// CI per-commit (dev channel) builds; see .github/workflows/release.yml. They
|
||||||
|
// stay empty for a plain `go build` and for stable tagged releases, which is how
|
||||||
|
// IsDevBuild tells a rolling dev build apart from a stable/local one.
|
||||||
|
var (
|
||||||
|
buildCommit string
|
||||||
|
buildDate string
|
||||||
|
)
|
||||||
|
|
||||||
// LogLevel represents the logging level for the application.
|
// LogLevel represents the logging level for the application.
|
||||||
type LogLevel string
|
type LogLevel string
|
||||||
|
|
||||||
@@ -42,6 +51,23 @@ func GetName() string {
|
|||||||
return strings.TrimSpace(name)
|
return strings.TrimSpace(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBuildCommit returns the short git commit this binary was built from, or an
|
||||||
|
// empty string for a plain/local build or a stable tagged release.
|
||||||
|
func GetBuildCommit() string {
|
||||||
|
return strings.TrimSpace(buildCommit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBuildDate returns the UTC build timestamp injected at build time, or empty.
|
||||||
|
func GetBuildDate() string {
|
||||||
|
return strings.TrimSpace(buildDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsDevBuild reports whether this binary is a CI per-commit (dev channel) build,
|
||||||
|
// detected by the injected commit. Stable releases and local builds return false.
|
||||||
|
func IsDevBuild() bool {
|
||||||
|
return GetBuildCommit() != ""
|
||||||
|
}
|
||||||
|
|
||||||
// GetLogLevel returns the current logging level based on environment variables or defaults to Info.
|
// GetLogLevel returns the current logging level based on environment variables or defaults to Info.
|
||||||
func GetLogLevel() LogLevel {
|
func GetLogLevel() LogLevel {
|
||||||
if IsDebug() {
|
if IsDebug() {
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) {
|
|||||||
g.POST("/restartXrayService", a.restartXrayService)
|
g.POST("/restartXrayService", a.restartXrayService)
|
||||||
g.POST("/installXray/:version", a.installXray)
|
g.POST("/installXray/:version", a.installXray)
|
||||||
g.POST("/updatePanel", a.updatePanel)
|
g.POST("/updatePanel", a.updatePanel)
|
||||||
|
g.POST("/setUpdateChannel", a.setUpdateChannel)
|
||||||
g.POST("/updateGeofile", a.updateGeofile)
|
g.POST("/updateGeofile", a.updateGeofile)
|
||||||
g.POST("/updateGeofile/:fileName", a.updateGeofile)
|
g.POST("/updateGeofile/:fileName", a.updateGeofile)
|
||||||
g.POST("/logs/:count", a.getLogs)
|
g.POST("/logs/:count", a.getLogs)
|
||||||
@@ -211,6 +212,19 @@ func (a *ServerController) updatePanel(c *gin.Context) {
|
|||||||
jsonMsg(c, I18nWeb(c, "pages.index.panelUpdateStartedPopover"), err)
|
jsonMsg(c, I18nWeb(c, "pages.index.panelUpdateStartedPopover"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setUpdateChannel toggles whether self-update tracks the rolling dev release.
|
||||||
|
func (a *ServerController) setUpdateChannel(c *gin.Context) {
|
||||||
|
var req struct {
|
||||||
|
Dev bool `json:"dev"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
jsonMsg(c, "invalid data", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := a.settingService.SetDevChannelEnable(req.Dev)
|
||||||
|
jsonMsg(c, I18nWeb(c, "pages.index.updateChannelChanged"), err)
|
||||||
|
}
|
||||||
|
|
||||||
// updateGeofile updates the specified geo file for Xray.
|
// updateGeofile updates the specified geo file for Xray.
|
||||||
func (a *ServerController) updateGeofile(c *gin.Context) {
|
func (a *ServerController) updateGeofile(c *gin.Context) {
|
||||||
fileName := c.Param("fileName")
|
fileName := c.Param("fileName")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -25,17 +26,27 @@ import (
|
|||||||
type PanelService struct{}
|
type PanelService struct{}
|
||||||
|
|
||||||
// PanelUpdateInfo contains the current and latest available panel versions.
|
// PanelUpdateInfo contains the current and latest available panel versions.
|
||||||
|
// On the dev channel the version fields carry a "dev+<sha>" label and the commit
|
||||||
|
// fields hold the short SHAs that drive the update-available decision.
|
||||||
type PanelUpdateInfo struct {
|
type PanelUpdateInfo struct {
|
||||||
|
Channel string `json:"channel"`
|
||||||
CurrentVersion string `json:"currentVersion"`
|
CurrentVersion string `json:"currentVersion"`
|
||||||
LatestVersion string `json:"latestVersion"`
|
LatestVersion string `json:"latestVersion"`
|
||||||
|
CurrentCommit string `json:"currentCommit,omitempty"`
|
||||||
|
LatestCommit string `json:"latestCommit,omitempty"`
|
||||||
UpdateAvailable bool `json:"updateAvailable"`
|
UpdateAvailable bool `json:"updateAvailable"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
panelUpdaterURL = "https://raw.githubusercontent.com/MHSanaei/3x-ui/main/update.sh"
|
panelUpdaterURL = "https://raw.githubusercontent.com/MHSanaei/3x-ui/main/update.sh"
|
||||||
maxPanelUpdaterBytes = 2 << 20
|
maxPanelUpdaterBytes = 2 << 20
|
||||||
|
// devReleaseTag is the fixed-tag rolling pre-release the CI force-moves to the
|
||||||
|
// newest main commit; the dev update channel installs from it.
|
||||||
|
devReleaseTag = "dev-latest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var releaseCommitRegex = regexp.MustCompile(`(?i)commit=([0-9a-f]{7,40})`)
|
||||||
|
|
||||||
func (s *PanelService) RestartPanel(delay time.Duration) error {
|
func (s *PanelService) RestartPanel(delay time.Duration) error {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
@@ -58,20 +69,59 @@ func (s *PanelService) RestartPanel(delay time.Duration) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUpdateInfo checks GitHub for the latest 3x-ui release.
|
// GetUpdateInfo checks GitHub for the latest 3x-ui release. When the dev channel
|
||||||
|
// is enabled on a dev build it compares commits against the rolling dev release;
|
||||||
|
// otherwise it compares versions against the latest stable tag.
|
||||||
func (s *PanelService) GetUpdateInfo() (*PanelUpdateInfo, error) {
|
func (s *PanelService) GetUpdateInfo() (*PanelUpdateInfo, error) {
|
||||||
|
if devChannelActive() {
|
||||||
|
return getDevUpdateInfo()
|
||||||
|
}
|
||||||
latest, err := fetchLatestPanelVersion()
|
latest, err := fetchLatestPanelVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
current := config.GetVersion()
|
current := config.GetVersion()
|
||||||
return &PanelUpdateInfo{
|
return &PanelUpdateInfo{
|
||||||
|
Channel: "stable",
|
||||||
CurrentVersion: current,
|
CurrentVersion: current,
|
||||||
LatestVersion: latest,
|
LatestVersion: latest,
|
||||||
UpdateAvailable: isNewerVersion(latest, current),
|
UpdateAvailable: isNewerVersion(latest, current),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// devChannelActive reports whether self-update should track the rolling dev
|
||||||
|
// release. It requires both the opt-in setting and a dev build, so a stable
|
||||||
|
// binary with the toggle left on never cross-grades to the dev channel.
|
||||||
|
func devChannelActive() bool {
|
||||||
|
if !config.IsDevBuild() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
enabled, err := (&service.SettingService{}).GetDevChannelEnable()
|
||||||
|
return err == nil && enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
// getDevUpdateInfo compares the running commit against the commit recorded in the
|
||||||
|
// rolling dev release.
|
||||||
|
func getDevUpdateInfo() (*PanelUpdateInfo, error) {
|
||||||
|
release, err := fetchPanelRelease(devReleaseTag)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
latestCommit := extractReleaseCommit(release)
|
||||||
|
if latestCommit == "" {
|
||||||
|
return nil, fmt.Errorf("dev release commit is unknown")
|
||||||
|
}
|
||||||
|
currentCommit := config.GetBuildCommit()
|
||||||
|
return &PanelUpdateInfo{
|
||||||
|
Channel: "dev",
|
||||||
|
CurrentVersion: config.GetVersion(),
|
||||||
|
CurrentCommit: shortCommit(currentCommit),
|
||||||
|
LatestCommit: shortCommit(latestCommit),
|
||||||
|
LatestVersion: "dev+" + shortCommit(latestCommit),
|
||||||
|
UpdateAvailable: !commitsEqual(currentCommit, latestCommit),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// StartUpdate starts the official updater outside of the current web request.
|
// StartUpdate starts the official updater outside of the current web request.
|
||||||
func (s *PanelService) StartUpdate() error {
|
func (s *PanelService) StartUpdate() error {
|
||||||
if runtime.GOOS != "linux" {
|
if runtime.GOOS != "linux" {
|
||||||
@@ -89,6 +139,10 @@ func (s *PanelService) StartUpdate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainFolder, serviceFolder := resolveUpdateFolders()
|
mainFolder, serviceFolder := resolveUpdateFolders()
|
||||||
|
updateTag := ""
|
||||||
|
if devChannelActive() {
|
||||||
|
updateTag = devReleaseTag
|
||||||
|
}
|
||||||
updateScript := fmt.Sprintf("set -e; trap 'rm -f %s' EXIT; %s %s", shellQuote(scriptPath), shellQuote(bash), shellQuote(scriptPath))
|
updateScript := fmt.Sprintf("set -e; trap 'rm -f %s' EXIT; %s %s", shellQuote(scriptPath), shellQuote(bash), shellQuote(scriptPath))
|
||||||
|
|
||||||
if systemdRun, err := exec.LookPath("systemd-run"); err == nil {
|
if systemdRun, err := exec.LookPath("systemd-run"); err == nil {
|
||||||
@@ -97,6 +151,7 @@ func (s *PanelService) StartUpdate() error {
|
|||||||
"--unit", unitName,
|
"--unit", unitName,
|
||||||
"--setenv", "XUI_MAIN_FOLDER="+mainFolder,
|
"--setenv", "XUI_MAIN_FOLDER="+mainFolder,
|
||||||
"--setenv", "XUI_SERVICE="+serviceFolder,
|
"--setenv", "XUI_SERVICE="+serviceFolder,
|
||||||
|
"--setenv", "XUI_UPDATE_TAG="+updateTag,
|
||||||
bash, "-lc", updateScript,
|
bash, "-lc", updateScript,
|
||||||
)
|
)
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
@@ -118,6 +173,7 @@ func (s *PanelService) StartUpdate() error {
|
|||||||
cmd.Env = append(os.Environ(),
|
cmd.Env = append(os.Environ(),
|
||||||
"XUI_MAIN_FOLDER="+mainFolder,
|
"XUI_MAIN_FOLDER="+mainFolder,
|
||||||
"XUI_SERVICE="+serviceFolder,
|
"XUI_SERVICE="+serviceFolder,
|
||||||
|
"XUI_UPDATE_TAG="+updateTag,
|
||||||
)
|
)
|
||||||
setDetachedProcess(cmd)
|
setDetachedProcess(cmd)
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
@@ -170,26 +226,88 @@ func downloadPanelUpdater() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fetchLatestPanelVersion() (string, error) {
|
func fetchLatestPanelVersion() (string, error) {
|
||||||
client := (&service.SettingService{}).NewProxiedHTTPClient(10 * time.Second)
|
release, err := fetchPanelRelease("")
|
||||||
resp, err := client.Get("https://api.github.com/repos/MHSanaei/3x-ui/releases/latest")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return "", fmt.Errorf("GitHub API returned status %d: %s", resp.StatusCode, resp.Status)
|
|
||||||
}
|
|
||||||
|
|
||||||
var release service.Release
|
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if release.TagName == "" {
|
if release.TagName == "" {
|
||||||
return "", fmt.Errorf("latest panel release tag is empty")
|
return "", fmt.Errorf("latest panel release tag is empty")
|
||||||
}
|
}
|
||||||
return release.TagName, nil
|
return release.TagName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fetchPanelRelease fetches a release from GitHub. An empty tag resolves the
|
||||||
|
// latest stable release; a non-empty tag (e.g. dev-latest) resolves that tag.
|
||||||
|
func fetchPanelRelease(tag string) (*service.Release, error) {
|
||||||
|
url := "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest"
|
||||||
|
if tag != "" {
|
||||||
|
url = "https://api.github.com/repos/MHSanaei/3x-ui/releases/tags/" + tag
|
||||||
|
}
|
||||||
|
client := (&service.SettingService{}).NewProxiedHTTPClient(10 * time.Second)
|
||||||
|
resp, err := client.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("GitHub API returned status %d: %s", resp.StatusCode, resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
var release service.Release
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &release, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// extractReleaseCommit reads the build commit recorded in the dev release: first
|
||||||
|
// the `commit=<sha>` marker the CI writes into the body, falling back to the
|
||||||
|
// tag's target commit.
|
||||||
|
func extractReleaseCommit(release *service.Release) string {
|
||||||
|
if m := releaseCommitRegex.FindStringSubmatch(release.Body); m != nil {
|
||||||
|
return strings.ToLower(m[1])
|
||||||
|
}
|
||||||
|
if isCommitSHA(release.TargetCommitish) {
|
||||||
|
return strings.ToLower(release.TargetCommitish)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func isCommitSHA(s string) bool {
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
if len(s) < 7 || len(s) > 40 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, r := range s {
|
||||||
|
if (r < '0' || r > '9') && (r < 'a' || r > 'f') && (r < 'A' || r > 'F') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func shortCommit(sha string) string {
|
||||||
|
sha = strings.TrimSpace(sha)
|
||||||
|
if len(sha) > 8 {
|
||||||
|
return sha[:8]
|
||||||
|
}
|
||||||
|
return sha
|
||||||
|
}
|
||||||
|
|
||||||
|
// commitsEqual compares a short (injected) commit against a full release commit
|
||||||
|
// by prefix, so an 8-char build stamp matches the 40-char release SHA.
|
||||||
|
func commitsEqual(a, b string) bool {
|
||||||
|
a = strings.ToLower(strings.TrimSpace(a))
|
||||||
|
b = strings.ToLower(strings.TrimSpace(b))
|
||||||
|
if a == "" || b == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(a) > len(b) {
|
||||||
|
a, b = b, a
|
||||||
|
}
|
||||||
|
return strings.HasPrefix(b, a)
|
||||||
|
}
|
||||||
|
|
||||||
func resolveUpdateFolders() (string, string) {
|
func resolveUpdateFolders() (string, string) {
|
||||||
mainFolder := os.Getenv("XUI_MAIN_FOLDER")
|
mainFolder := os.Getenv("XUI_MAIN_FOLDER")
|
||||||
if mainFolder == "" {
|
if mainFolder == "" {
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package panel
|
package panel
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/mhsanaei/3x-ui/v3/internal/web/service"
|
||||||
|
)
|
||||||
|
|
||||||
func TestIsNewerVersion(t *testing.T) {
|
func TestIsNewerVersion(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
@@ -39,3 +43,67 @@ func TestShellQuote(t *testing.T) {
|
|||||||
t.Fatalf("unexpected quote result with single quote: %s", got)
|
t.Fatalf("unexpected quote result with single quote: %s", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExtractReleaseCommit(t *testing.T) {
|
||||||
|
full := "1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b"
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
release service.Release
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "from body marker",
|
||||||
|
release: service.Release{Body: "Rolling build\n\ncommit=" + full + "\nbuilt=2026-06-24T00:00:00Z"},
|
||||||
|
want: full,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "body marker is case-insensitive and wins over target",
|
||||||
|
release: service.Release{Body: "COMMIT=" + full, TargetCommitish: "deadbeef"},
|
||||||
|
want: full,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "fallback to target commit sha",
|
||||||
|
release: service.Release{Body: "no marker here", TargetCommitish: full},
|
||||||
|
want: full,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "branch target is not a commit",
|
||||||
|
release: service.Release{Body: "no marker", TargetCommitish: "main"},
|
||||||
|
want: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range cases {
|
||||||
|
if got := extractReleaseCommit(&tc.release); got != tc.want {
|
||||||
|
t.Fatalf("%s: extractReleaseCommit = %q, want %q", tc.name, got, tc.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCommitsEqual(t *testing.T) {
|
||||||
|
full := "1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b"
|
||||||
|
cases := []struct {
|
||||||
|
a, b string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"1a2b3c4d", full, true}, // injected 8-char prefix matches full release sha
|
||||||
|
{full, "1a2b3c4d", true}, // order independent
|
||||||
|
{"1A2B3C4D", full, true}, // case insensitive
|
||||||
|
{"deadbeef", full, false}, // different commit
|
||||||
|
{"", full, false}, // empty current never matches
|
||||||
|
{"1a2b3c4d", "", false}, // empty latest never matches
|
||||||
|
}
|
||||||
|
for _, tc := range cases {
|
||||||
|
if got := commitsEqual(tc.a, tc.b); got != tc.want {
|
||||||
|
t.Fatalf("commitsEqual(%q, %q) = %v, want %v", tc.a, tc.b, got, tc.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShortCommit(t *testing.T) {
|
||||||
|
if got := shortCommit("1a2b3c4d5e6f7a8b"); got != "1a2b3c4d" {
|
||||||
|
t.Fatalf("shortCommit truncation = %q, want %q", got, "1a2b3c4d")
|
||||||
|
}
|
||||||
|
if got := shortCommit("abc"); got != "abc" {
|
||||||
|
t.Fatalf("shortCommit short input = %q, want %q", got, "abc")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -117,7 +117,10 @@ type Status struct {
|
|||||||
|
|
||||||
// Release represents information about a software release from GitHub.
|
// Release represents information about a software release from GitHub.
|
||||||
type Release struct {
|
type Release struct {
|
||||||
TagName string `json:"tag_name"` // The tag name of the release
|
TagName string `json:"tag_name"` // The tag name of the release
|
||||||
|
Body string `json:"body"` // The release notes; the dev channel reads its commit from here
|
||||||
|
TargetCommitish string `json:"target_commitish"` // The branch/commit the tag points at
|
||||||
|
Prerelease bool `json:"prerelease"` // Whether this is a pre-release
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerService provides business logic for server monitoring and management.
|
// ServerService provides business logic for server monitoring and management.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"github.com/mhsanaei/3x-ui/v3/internal/config"
|
||||||
"github.com/mhsanaei/3x-ui/v3/internal/database"
|
"github.com/mhsanaei/3x-ui/v3/internal/database"
|
||||||
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
||||||
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
||||||
@@ -109,6 +110,7 @@ var defaultValueMap = map[string]string{
|
|||||||
"restartXrayOnClientDisable": "true",
|
"restartXrayOnClientDisable": "true",
|
||||||
"xrayOutboundTestUrl": "https://www.google.com/generate_204",
|
"xrayOutboundTestUrl": "https://www.google.com/generate_204",
|
||||||
"panelOutbound": "",
|
"panelOutbound": "",
|
||||||
|
"devChannelEnable": "false",
|
||||||
|
|
||||||
// LDAP defaults
|
// LDAP defaults
|
||||||
"ldapEnable": "false",
|
"ldapEnable": "false",
|
||||||
@@ -855,6 +857,16 @@ func (s *SettingService) SetRestartXrayOnClientDisable(value bool) error {
|
|||||||
return s.setBool("restartXrayOnClientDisable", value)
|
return s.setBool("restartXrayOnClientDisable", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDevChannelEnable reports whether the panel self-update tracks the rolling
|
||||||
|
// per-commit dev release instead of the latest stable tag.
|
||||||
|
func (s *SettingService) GetDevChannelEnable() (bool, error) {
|
||||||
|
return s.getBool("devChannelEnable")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SettingService) SetDevChannelEnable(value bool) error {
|
||||||
|
return s.setBool("devChannelEnable", value)
|
||||||
|
}
|
||||||
|
|
||||||
// GetIpLimitEnable reports whether the IP-limit feature is available. Always
|
// GetIpLimitEnable reports whether the IP-limit feature is available. Always
|
||||||
// true since the panel enforces limits via the core's online-stats API; on an
|
// true since the panel enforces limits via the core's online-stats API; on an
|
||||||
// older core the job falls back to access-log parsing and warns there when the
|
// older core the job falls back to access-log parsing and warns there when the
|
||||||
@@ -1209,25 +1221,27 @@ func (s *SettingService) BuildSubURIBase(host string) string {
|
|||||||
func (s *SettingService) GetDefaultSettings(host string) (any, error) {
|
func (s *SettingService) GetDefaultSettings(host string) (any, error) {
|
||||||
type settingFunc func() (any, error)
|
type settingFunc func() (any, error)
|
||||||
settings := map[string]settingFunc{
|
settings := map[string]settingFunc{
|
||||||
"expireDiff": func() (any, error) { return s.GetExpireDiff() },
|
"expireDiff": func() (any, error) { return s.GetExpireDiff() },
|
||||||
"trafficDiff": func() (any, error) { return s.GetTrafficDiff() },
|
"trafficDiff": func() (any, error) { return s.GetTrafficDiff() },
|
||||||
"pageSize": func() (any, error) { return s.GetPageSize() },
|
"pageSize": func() (any, error) { return s.GetPageSize() },
|
||||||
"defaultCert": func() (any, error) { return s.GetCertFile() },
|
"defaultCert": func() (any, error) { return s.GetCertFile() },
|
||||||
"defaultKey": func() (any, error) { return s.GetKeyFile() },
|
"defaultKey": func() (any, error) { return s.GetKeyFile() },
|
||||||
"tgBotEnable": func() (any, error) { return s.GetTgbotEnabled() },
|
"tgBotEnable": func() (any, error) { return s.GetTgbotEnabled() },
|
||||||
"subThemeDir": func() (any, error) { return s.GetSubThemeDir() },
|
"subThemeDir": func() (any, error) { return s.GetSubThemeDir() },
|
||||||
"subEnable": func() (any, error) { return s.GetSubEnable() },
|
"subEnable": func() (any, error) { return s.GetSubEnable() },
|
||||||
"subJsonEnable": func() (any, error) { return s.GetSubJsonEnable() },
|
"subJsonEnable": func() (any, error) { return s.GetSubJsonEnable() },
|
||||||
"subClashEnable": func() (any, error) { return s.GetSubClashEnable() },
|
"subClashEnable": func() (any, error) { return s.GetSubClashEnable() },
|
||||||
"subTitle": func() (any, error) { return s.GetSubTitle() },
|
"subTitle": func() (any, error) { return s.GetSubTitle() },
|
||||||
"subURI": func() (any, error) { return s.GetSubURI() },
|
"subURI": func() (any, error) { return s.GetSubURI() },
|
||||||
"subJsonURI": func() (any, error) { return s.GetSubJsonURI() },
|
"subJsonURI": func() (any, error) { return s.GetSubJsonURI() },
|
||||||
"subClashURI": func() (any, error) { return s.GetSubClashURI() },
|
"subClashURI": func() (any, error) { return s.GetSubClashURI() },
|
||||||
"datepicker": func() (any, error) { return s.GetDatepicker() },
|
"datepicker": func() (any, error) { return s.GetDatepicker() },
|
||||||
"ipLimitEnable": func() (any, error) { return s.GetIpLimitEnable() },
|
"ipLimitEnable": func() (any, error) { return s.GetIpLimitEnable() },
|
||||||
"accessLogEnable": func() (any, error) { return s.GetAccessLogEnable() },
|
"accessLogEnable": func() (any, error) { return s.GetAccessLogEnable() },
|
||||||
"webDomain": func() (any, error) { return s.GetWebDomain() },
|
"webDomain": func() (any, error) { return s.GetWebDomain() },
|
||||||
"subDomain": func() (any, error) { return s.GetSubDomain() },
|
"subDomain": func() (any, error) { return s.GetSubDomain() },
|
||||||
|
"devChannelEnable": func() (any, error) { return s.GetDevChannelEnable() },
|
||||||
|
"isDevBuild": func() (any, error) { return config.IsDevBuild(), nil },
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[string]any)
|
result := make(map[string]any)
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "إصدار البانل الحالي",
|
"currentPanelVersion": "إصدار البانل الحالي",
|
||||||
"latestPanelVersion": "أحدث إصدار للبانل",
|
"latestPanelVersion": "أحدث إصدار للبانل",
|
||||||
"panelUpToDate": "البانل محدث لآخر إصدار",
|
"panelUpToDate": "البانل محدث لآخر إصدار",
|
||||||
|
"devChannel": "قناة التطوير",
|
||||||
|
"devChannelWarning": "تتابع نسخ التطوير كل كومِت على main وليست إصدارات مستقرة — لا يوجد رجوع تلقائي لإصدار أقدم.",
|
||||||
|
"currentCommit": "الكومِت الحالي",
|
||||||
|
"latestCommit": "أحدث كومِت",
|
||||||
|
"updateChannelChanged": "تم تغيير قناة التحديث",
|
||||||
"upToDate": "محدث",
|
"upToDate": "محدث",
|
||||||
"xrayStatusUnknown": "مش معروف",
|
"xrayStatusUnknown": "مش معروف",
|
||||||
"xrayStatusRunning": "شغالة",
|
"xrayStatusRunning": "شغالة",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Current panel version",
|
"currentPanelVersion": "Current panel version",
|
||||||
"latestPanelVersion": "Latest panel version",
|
"latestPanelVersion": "Latest panel version",
|
||||||
"panelUpToDate": "Panel is up to date",
|
"panelUpToDate": "Panel is up to date",
|
||||||
|
"devChannel": "Dev channel",
|
||||||
|
"devChannelWarning": "Dev builds track every commit on main and aren't stable releases — there is no automatic downgrade.",
|
||||||
|
"currentCommit": "Current commit",
|
||||||
|
"latestCommit": "Latest commit",
|
||||||
|
"updateChannelChanged": "Update channel changed",
|
||||||
"upToDate": "Up to date",
|
"upToDate": "Up to date",
|
||||||
"xrayStatusUnknown": "Unknown",
|
"xrayStatusUnknown": "Unknown",
|
||||||
"xrayStatusRunning": "Running",
|
"xrayStatusRunning": "Running",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Versión actual del panel",
|
"currentPanelVersion": "Versión actual del panel",
|
||||||
"latestPanelVersion": "Última versión del panel",
|
"latestPanelVersion": "Última versión del panel",
|
||||||
"panelUpToDate": "El panel está actualizado",
|
"panelUpToDate": "El panel está actualizado",
|
||||||
|
"devChannel": "Canal de desarrollo",
|
||||||
|
"devChannelWarning": "Las compilaciones de desarrollo siguen cada commit en main y no son versiones estables; no hay reversión automática.",
|
||||||
|
"currentCommit": "Commit actual",
|
||||||
|
"latestCommit": "Último commit",
|
||||||
|
"updateChannelChanged": "Canal de actualización cambiado",
|
||||||
"upToDate": "Actualizado",
|
"upToDate": "Actualizado",
|
||||||
"xrayStatusUnknown": "Desconocido",
|
"xrayStatusUnknown": "Desconocido",
|
||||||
"xrayStatusRunning": "En ejecución",
|
"xrayStatusRunning": "En ejecución",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "نسخه فعلی پنل",
|
"currentPanelVersion": "نسخه فعلی پنل",
|
||||||
"latestPanelVersion": "آخرین نسخه پنل",
|
"latestPanelVersion": "آخرین نسخه پنل",
|
||||||
"panelUpToDate": "پنل بهروز است",
|
"panelUpToDate": "پنل بهروز است",
|
||||||
|
"devChannel": "کانال توسعه (Dev)",
|
||||||
|
"devChannelWarning": "بیلدهای توسعه هر کامیت روی main را دنبال میکنند و نسخهٔ پایدار نیستند — بازگشت خودکار به نسخهٔ قبلی وجود ندارد.",
|
||||||
|
"currentCommit": "کامیت فعلی",
|
||||||
|
"latestCommit": "آخرین کامیت",
|
||||||
|
"updateChannelChanged": "کانال بهروزرسانی تغییر کرد",
|
||||||
"upToDate": "بهروز",
|
"upToDate": "بهروز",
|
||||||
"xrayStatusUnknown": "ناشناخته",
|
"xrayStatusUnknown": "ناشناخته",
|
||||||
"xrayStatusRunning": "در حال اجرا",
|
"xrayStatusRunning": "در حال اجرا",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Versi panel saat ini",
|
"currentPanelVersion": "Versi panel saat ini",
|
||||||
"latestPanelVersion": "Versi panel terbaru",
|
"latestPanelVersion": "Versi panel terbaru",
|
||||||
"panelUpToDate": "Panel sudah terbaru",
|
"panelUpToDate": "Panel sudah terbaru",
|
||||||
|
"devChannel": "Kanal dev",
|
||||||
|
"devChannelWarning": "Build dev mengikuti setiap commit di main dan bukan rilis stabil — tidak ada penurunan versi otomatis.",
|
||||||
|
"currentCommit": "Commit saat ini",
|
||||||
|
"latestCommit": "Commit terbaru",
|
||||||
|
"updateChannelChanged": "Kanal pembaruan diubah",
|
||||||
"upToDate": "Terbaru",
|
"upToDate": "Terbaru",
|
||||||
"xrayStatusUnknown": "Tidak diketahui",
|
"xrayStatusUnknown": "Tidak diketahui",
|
||||||
"xrayStatusRunning": "Berjalan",
|
"xrayStatusRunning": "Berjalan",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "現在のパネルバージョン",
|
"currentPanelVersion": "現在のパネルバージョン",
|
||||||
"latestPanelVersion": "最新のパネルバージョン",
|
"latestPanelVersion": "最新のパネルバージョン",
|
||||||
"panelUpToDate": "パネルは最新です",
|
"panelUpToDate": "パネルは最新です",
|
||||||
|
"devChannel": "開発チャンネル",
|
||||||
|
"devChannelWarning": "開発ビルドは main の各コミットを追跡し、安定版ではありません。自動ダウングレードはありません。",
|
||||||
|
"currentCommit": "現在のコミット",
|
||||||
|
"latestCommit": "最新のコミット",
|
||||||
|
"updateChannelChanged": "更新チャンネルを変更しました",
|
||||||
"upToDate": "最新",
|
"upToDate": "最新",
|
||||||
"xrayStatusUnknown": "不明",
|
"xrayStatusUnknown": "不明",
|
||||||
"xrayStatusRunning": "実行中",
|
"xrayStatusRunning": "実行中",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Versão atual do painel",
|
"currentPanelVersion": "Versão atual do painel",
|
||||||
"latestPanelVersion": "Última versão do painel",
|
"latestPanelVersion": "Última versão do painel",
|
||||||
"panelUpToDate": "O painel está atualizado",
|
"panelUpToDate": "O painel está atualizado",
|
||||||
|
"devChannel": "Canal de desenvolvimento",
|
||||||
|
"devChannelWarning": "As builds de desenvolvimento acompanham cada commit na main e não são versões estáveis — não há downgrade automático.",
|
||||||
|
"currentCommit": "Commit atual",
|
||||||
|
"latestCommit": "Último commit",
|
||||||
|
"updateChannelChanged": "Canal de atualização alterado",
|
||||||
"upToDate": "Atualizado",
|
"upToDate": "Atualizado",
|
||||||
"xrayStatusUnknown": "Desconhecido",
|
"xrayStatusUnknown": "Desconhecido",
|
||||||
"xrayStatusRunning": "Em execução",
|
"xrayStatusRunning": "Em execução",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Текущая версия панели",
|
"currentPanelVersion": "Текущая версия панели",
|
||||||
"latestPanelVersion": "Последняя версия панели",
|
"latestPanelVersion": "Последняя версия панели",
|
||||||
"panelUpToDate": "Панель обновлена",
|
"panelUpToDate": "Панель обновлена",
|
||||||
|
"devChannel": "Канал разработки",
|
||||||
|
"devChannelWarning": "Сборки разработки отслеживают каждый коммит в main и не являются стабильными релизами — автоматического отката нет.",
|
||||||
|
"currentCommit": "Текущий коммит",
|
||||||
|
"latestCommit": "Последний коммит",
|
||||||
|
"updateChannelChanged": "Канал обновления изменён",
|
||||||
"upToDate": "Обновлено",
|
"upToDate": "Обновлено",
|
||||||
"xrayStatusUnknown": "Неизвестно",
|
"xrayStatusUnknown": "Неизвестно",
|
||||||
"xrayStatusRunning": "Запущен",
|
"xrayStatusRunning": "Запущен",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Mevcut panel sürümü",
|
"currentPanelVersion": "Mevcut panel sürümü",
|
||||||
"latestPanelVersion": "Panelin en son sürümü",
|
"latestPanelVersion": "Panelin en son sürümü",
|
||||||
"panelUpToDate": "Panel güncel",
|
"panelUpToDate": "Panel güncel",
|
||||||
|
"devChannel": "Geliştirme kanalı",
|
||||||
|
"devChannelWarning": "Geliştirme yapıları main üzerindeki her commit'i izler ve kararlı sürüm değildir — otomatik geri alma yoktur.",
|
||||||
|
"currentCommit": "Geçerli commit",
|
||||||
|
"latestCommit": "Son commit",
|
||||||
|
"updateChannelChanged": "Güncelleme kanalı değiştirildi",
|
||||||
"upToDate": "Güncel",
|
"upToDate": "Güncel",
|
||||||
"xrayStatusUnknown": "Bilinmiyor",
|
"xrayStatusUnknown": "Bilinmiyor",
|
||||||
"xrayStatusRunning": "Çalışıyor",
|
"xrayStatusRunning": "Çalışıyor",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Поточна версія панелі",
|
"currentPanelVersion": "Поточна версія панелі",
|
||||||
"latestPanelVersion": "Остання версія панелі",
|
"latestPanelVersion": "Остання версія панелі",
|
||||||
"panelUpToDate": "Панель оновлено",
|
"panelUpToDate": "Панель оновлено",
|
||||||
|
"devChannel": "Канал розробки",
|
||||||
|
"devChannelWarning": "Збірки розробки відстежують кожен коміт у main і не є стабільними релізами — автоматичного відкату немає.",
|
||||||
|
"currentCommit": "Поточний коміт",
|
||||||
|
"latestCommit": "Останній коміт",
|
||||||
|
"updateChannelChanged": "Канал оновлення змінено",
|
||||||
"upToDate": "Оновлено",
|
"upToDate": "Оновлено",
|
||||||
"xrayStatusUnknown": "Невідомо",
|
"xrayStatusUnknown": "Невідомо",
|
||||||
"xrayStatusRunning": "Запущено",
|
"xrayStatusRunning": "Запущено",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "Phiên bản panel hiện tại",
|
"currentPanelVersion": "Phiên bản panel hiện tại",
|
||||||
"latestPanelVersion": "Phiên bản panel mới nhất",
|
"latestPanelVersion": "Phiên bản panel mới nhất",
|
||||||
"panelUpToDate": "Panel đã được cập nhật",
|
"panelUpToDate": "Panel đã được cập nhật",
|
||||||
|
"devChannel": "Kênh phát triển",
|
||||||
|
"devChannelWarning": "Bản dev bám theo từng commit trên main và không phải bản ổn định — không có hạ cấp tự động.",
|
||||||
|
"currentCommit": "Commit hiện tại",
|
||||||
|
"latestCommit": "Commit mới nhất",
|
||||||
|
"updateChannelChanged": "Đã đổi kênh cập nhật",
|
||||||
"upToDate": "Đã cập nhật",
|
"upToDate": "Đã cập nhật",
|
||||||
"xrayStatusUnknown": "Không xác định",
|
"xrayStatusUnknown": "Không xác định",
|
||||||
"xrayStatusRunning": "Đang chạy",
|
"xrayStatusRunning": "Đang chạy",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "当前面板版本",
|
"currentPanelVersion": "当前面板版本",
|
||||||
"latestPanelVersion": "最新面板版本",
|
"latestPanelVersion": "最新面板版本",
|
||||||
"panelUpToDate": "面板已是最新",
|
"panelUpToDate": "面板已是最新",
|
||||||
|
"devChannel": "开发通道",
|
||||||
|
"devChannelWarning": "开发版会跟踪 main 的每次提交,并非稳定版本,且无法自动降级。",
|
||||||
|
"currentCommit": "当前提交",
|
||||||
|
"latestCommit": "最新提交",
|
||||||
|
"updateChannelChanged": "更新通道已切换",
|
||||||
"upToDate": "已是最新",
|
"upToDate": "已是最新",
|
||||||
"xrayStatusUnknown": "未知",
|
"xrayStatusUnknown": "未知",
|
||||||
"xrayStatusRunning": "运行中",
|
"xrayStatusRunning": "运行中",
|
||||||
|
|||||||
@@ -153,6 +153,11 @@
|
|||||||
"currentPanelVersion": "目前面板版本",
|
"currentPanelVersion": "目前面板版本",
|
||||||
"latestPanelVersion": "最新面板版本",
|
"latestPanelVersion": "最新面板版本",
|
||||||
"panelUpToDate": "面板已是最新",
|
"panelUpToDate": "面板已是最新",
|
||||||
|
"devChannel": "開發通道",
|
||||||
|
"devChannelWarning": "開發版會追蹤 main 的每次提交,並非穩定版本,且無法自動降級。",
|
||||||
|
"currentCommit": "目前提交",
|
||||||
|
"latestCommit": "最新提交",
|
||||||
|
"updateChannelChanged": "更新通道已切換",
|
||||||
"upToDate": "已是最新",
|
"upToDate": "已是最新",
|
||||||
"xrayStatusUnknown": "未知",
|
"xrayStatusUnknown": "未知",
|
||||||
"xrayStatusRunning": "運行中",
|
"xrayStatusRunning": "運行中",
|
||||||
|
|||||||
@@ -895,9 +895,16 @@ update_x-ui() {
|
|||||||
|
|
||||||
echo -e "${green}Downloading new x-ui version...${plain}"
|
echo -e "${green}Downloading new x-ui version...${plain}"
|
||||||
|
|
||||||
tag_version=$(${curl_bin} -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" 2> /dev/null | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
# XUI_UPDATE_TAG lets the panel target a specific release tag (e.g. the
|
||||||
if [[ ! -n "$tag_version" ]]; then
|
# rolling dev-latest pre-release). Empty keeps the default latest-stable flow.
|
||||||
_fail "ERROR: Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later"
|
if [[ -n "${XUI_UPDATE_TAG}" ]]; then
|
||||||
|
tag_version="${XUI_UPDATE_TAG}"
|
||||||
|
echo -e "${green}Using update tag: ${tag_version}${plain}"
|
||||||
|
else
|
||||||
|
tag_version=$(${curl_bin} -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" 2> /dev/null | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||||
|
if [[ ! -n "$tag_version" ]]; then
|
||||||
|
_fail "ERROR: Failed to fetch x-ui version, it may be due to GitHub API restrictions, please try it later"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..."
|
echo -e "Got x-ui latest version: ${tag_version}, beginning the installation..."
|
||||||
${curl_bin} -fLRo ${xui_folder}-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz 2> /dev/null
|
${curl_bin} -fLRo ${xui_folder}-linux-$(arch).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${tag_version}/x-ui-linux-$(arch).tar.gz 2> /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user