diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5d563b04..ada481c8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -50,6 +50,6 @@ jobs: with: context: . push: true - platforms: linux/amd64,linux/arm64/v8 + platforms: linux/amd64,linux/arm64/v8, linux/arm/v7 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ba0faa37..94efaa20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ -name: Release X-ui +name: Release X-UI + on: push: tags: @@ -6,127 +7,81 @@ on: workflow_dispatch: jobs: - linuxamd64build: - name: build x-ui amd64 version + build: + strategy: + matrix: + platform: [amd64, arm64, arm] runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - name: Checkout repository + uses: actions/checkout@v4.1.1 + + - name: Setup Go + uses: actions/setup-go@v5.0.0 with: go-version: '1.21' - - name: build linux amd64 version - run: | - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o xui-release -v main.go - mkdir x-ui - cp xui-release x-ui/xui-release - cp x-ui.service x-ui/x-ui.service - cp x-ui.sh x-ui/x-ui.sh - cd x-ui - mv xui-release x-ui - mkdir bin - cd bin - wget https://github.com/XTLS/Xray-core/releases/download/v1.8.6/Xray-linux-64.zip - unzip Xray-linux-64.zip - rm -f Xray-linux-64.zip geoip.dat geosite.dat LICENSE README.md - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat - 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 - mv xray xray-linux-amd64 - cd .. - cd .. - - name: package - run: tar -zcvf x-ui-linux-amd64.tar.gz x-ui - - name: upload - uses: svenstaro/upload-release-action@2.7.0 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref }} - file: x-ui-linux-amd64.tar.gz - asset_name: x-ui-linux-amd64.tar.gz - prerelease: true - linuxarm64build: - name: build x-ui arm64 version - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: build linux arm64 version + + - name: Install dependencies for arm64 and arm + if: matrix.platform == 'arm64' || matrix.platform == 'arm' run: | sudo apt-get update sudo apt install gcc-aarch64-linux-gnu - CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o xui-release -v main.go - mkdir x-ui - cp xui-release x-ui/xui-release - cp x-ui.service x-ui/x-ui.service - cp x-ui.sh x-ui/x-ui.sh - cd x-ui - mv xui-release x-ui - mkdir bin - cd bin - wget https://github.com/xtls/xray-core/releases/download/v1.8.6/Xray-linux-arm64-v8a.zip - unzip Xray-linux-arm64-v8a.zip - rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat LICENSE README.md - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat - 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 - mv xray xray-linux-arm64 - cd .. - cd .. - - name: package - run: tar -zcvf x-ui-linux-arm64.tar.gz x-ui - - name: upload - uses: svenstaro/upload-release-action@2.7.0 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref }} - file: x-ui-linux-arm64.tar.gz - asset_name: x-ui-linux-arm64.tar.gz - prerelease: true - linuxs390xbuild: - name: build x-ui s390x version - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: build linux s390x version + if [ "${{ matrix.platform }}" == "arm" ]; then + sudo apt install gcc-arm-linux-gnueabihf + fi + + - name: Build x-ui run: | - sudo apt-get update - sudo apt install gcc-s390x-linux-gnu -y - CGO_ENABLED=1 GOOS=linux GOARCH=s390x CC=s390x-linux-gnu-gcc go build -o xui-release -v main.go + export CGO_ENABLED=1 + export GOOS=linux + export GOARCH=${{ matrix.platform }} + if [ "${{ matrix.platform }}" == "arm64" ]; then + export CC=aarch64-linux-gnu-gcc + elif [ "${{ matrix.platform }}" == "arm" ]; then + export CC=arm-linux-gnueabihf-gcc + fi + go build -o xui-release -v main.go + mkdir x-ui - cp xui-release x-ui/xui-release - cp x-ui.service x-ui/x-ui.service - cp x-ui.sh x-ui/x-ui.sh - cd x-ui - mv xui-release x-ui - mkdir bin - cd bin - wget https://github.com/xtls/xray-core/releases/download/v1.8.6/Xray-linux-s390x.zip - unzip Xray-linux-s390x.zip - rm -f Xray-linux-s390x.zip geoip.dat geosite.dat LICENSE README.md + cp xui-release x-ui/ + cp x-ui.service x-ui/ + cp x-ui.sh x-ui/ + mv x-ui/xui-release x-ui/x-ui + mkdir x-ui/bin + cd x-ui/bin + + # Download dependencies + Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v1.8.7/" + if [ "${{ matrix.platform }}" == "amd64" ]; then + wget ${Xray_URL}Xray-linux-64.zip + unzip Xray-linux-64.zip + rm -f Xray-linux-64.zip + elif [ "${{ matrix.platform }}" == "arm64" ]; then + wget ${Xray_URL}Xray-linux-arm64-v8a.zip + unzip Xray-linux-arm64-v8a.zip + rm -f Xray-linux-arm64-v8a.zip + else + wget ${Xray_URL}Xray-linux-arm32-v7a.zip + unzip Xray-linux-arm32-v7a.zip + rm -f Xray-linux-arm32-v7a.zip + fi + rm -f geoip.dat geosite.dat geoip_IR.dat geosite_IR.dat geoip_VN.dat geosite_VN.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat 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 - mv xray xray-linux-s390x - cd .. - cd .. - - name: package - run: tar -zcvf x-ui-linux-s390x.tar.gz x-ui - - name: upload + mv xray xray-linux-${{ matrix.platform }} + cd ../.. + + - name: Package + run: tar -zcvf x-ui-linux-${{ matrix.platform }}.tar.gz x-ui + + - name: Upload uses: svenstaro/upload-release-action@2.7.0 with: repo_token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ github.ref }} - file: x-ui-linux-s390x.tar.gz - asset_name: x-ui-linux-s390x.tar.gz + file: x-ui-linux-${{ matrix.platform }}.tar.gz + asset_name: x-ui-linux-${{ matrix.platform }}.tar.gz prerelease: true + overwrite: true diff --git a/DockerInitFiles.sh b/DockerInitFiles.sh index 85afb812..d8741cdd 100755 --- a/DockerInitFiles.sh +++ b/DockerInitFiles.sh @@ -1,17 +1,25 @@ #!/bin/sh -if [ $1 == "amd64" ]; then - ARCH="64"; - FNAME="amd64"; -elif [ $1 == "arm64" ]; then - ARCH="arm64-v8a" - FNAME="arm64"; -else - ARCH="64"; - FNAME="amd64"; -fi +case $1 in + amd64) + ARCH="64" + FNAME="amd64" + ;; + armv8 | arm64 | aarch64) + ARCH="arm64-v8a" + FNAME="arm64" + ;; + armv7 | arm | arm32) + ARCH="arm32-v7a" + FNAME="arm32" + ;; + *) + ARCH="64" + FNAME="amd64" + ;; +esac mkdir -p build/bin cd build/bin -wget "https://github.com/XTLS/Xray-core/releases/download/v1.8.6/Xray-linux-${ARCH}.zip" +wget "https://github.com/XTLS/Xray-core/releases/download/v1.8.7/Xray-linux-${ARCH}.zip" unzip "Xray-linux-${ARCH}.zip" rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat LICENSE README.md mv xray "xray-linux-${FNAME}" diff --git a/install.sh b/install.sh index 6bdc3497..27e5b9bb 100755 --- a/install.sh +++ b/install.sh @@ -23,25 +23,15 @@ else fi echo "The OS release is: $release" -arch=$(arch) - -if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then - arch="amd64" -elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then - arch="arm64" -elif [[ $arch == "s390x" ]]; then - arch="s390x" -else - arch="amd64" - echo -e "${red} Failed to check system arch, will use default arch: ${arch}${plain}" -fi - -echo "arch: ${arch}" - -if [ $(getconf WORD_BIT) != '32' ] && [ $(getconf LONG_BIT) != '64' ]; then - echo "x-ui dosen't support 32-bit(x86) system, please use 64 bit operating system(x86_64) instead, if there is something wrong, please get in touch with me!" - exit -1 -fi +arch() { + case "$(uname -m)" in + x86_64 | x64 | amd64) echo 'amd64' ;; + armv8* | armv8 | arm64 | aarch64) echo 'arm64' ;; + armv7* | armv7 | arm | arm32 ) echo 'arm' ;; + *) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;; + esac +} +echo "arch: $(arch)" os_version="" os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1) @@ -122,18 +112,18 @@ install_x-ui() { exit 1 fi echo -e "Got x-ui latest version: ${last_version}, beginning the installation..." - wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz https://github.com/alireza0/x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz + wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch).tar.gz https://github.com/alireza0/x-ui/releases/download/${last_version}/x-ui-linux-$(arch).tar.gz if [[ $? -ne 0 ]]; then - echo -e "${red}Dowanloading x-ui failed, please be sure that your server can access Github ${plain}" + echo -e "${red}Downloading x-ui failed, please be sure that your server can access Github ${plain}" exit 1 fi else last_version=$1 - url="https://github.com/alireza0/x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz" - echo -e "Begining to install x-ui v$1" - wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz ${url} + url="https://github.com/alireza0/x-ui/releases/download/${last_version}/x-ui-linux-$(arch).tar.gz" + echo -e "Beginning to install x-ui v$1" + wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch).tar.gz ${url} if [[ $? -ne 0 ]]; then - echo -e "${red}dowanload x-ui v$1 failed,please check the verison exists${plain}" + echo -e "${red}download x-ui v$1 failed,please check the version exists${plain}" exit 1 fi fi @@ -143,10 +133,10 @@ install_x-ui() { rm /usr/local/x-ui/ -rf fi - tar zxvf x-ui-linux-${arch}.tar.gz - rm x-ui-linux-${arch}.tar.gz -f + tar zxvf x-ui-linux-$(arch).tar.gz + rm x-ui-linux-$(arch).tar.gz -f cd x-ui - chmod +x x-ui bin/xray-linux-${arch} + chmod +x x-ui bin/xray-linux-$(arch) cp -f x-ui.service /etc/systemd/system/ wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/alireza0/x-ui/main/x-ui.sh chmod +x /usr/local/x-ui/x-ui.sh @@ -181,6 +171,6 @@ install_x-ui() { echo "------------------------------------------" } -echo -e "${green}Excuting...${plain}" +echo -e "${green}Running...${plain}" install_base install_x-ui $1 diff --git a/sub/subService.go b/sub/subService.go index 3e2a1c25..d5d48040 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -408,6 +408,10 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { } } + if security != "tls" && security != "reality" { + params["security"] = "none" + } + externalProxies, _ := stream["externalProxy"].([]interface{}) if len(externalProxies) > 0 { @@ -581,6 +585,10 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string } } + if security != "tls" && security != "reality" { + params["security"] = "none" + } + externalProxies, _ := stream["externalProxy"].([]interface{}) if len(externalProxies) > 0 { diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js index 82d5ba61..a3be7abf 100644 --- a/web/assets/js/model/outbound.js +++ b/web/assets/js/model/outbound.js @@ -962,11 +962,11 @@ Outbound.WireguardSettings = class extends CommonClass { } }; Outbound.WireguardSettings.Peer = class extends CommonClass { - constructor(publicKey='', psk='', allowedIPs='0.0.0.0/0,::/0', endpoint='', keepAlive=0) { + constructor(publicKey='', psk='', allowedIPs=['0.0.0.0/0','::/0'], endpoint='', keepAlive=0) { super(); this.publicKey = publicKey; this.psk = psk; - this.allowedIPs = allowedIPs instanceof Array ? allowedIPs.join(',') : allowedIPs; + this.allowedIPs = allowedIPs; this.endpoint = endpoint; this.keepAlive = keepAlive; } diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 19892c75..6870d2d7 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -408,7 +408,7 @@ class HttpStreamSettings extends XrayCommonClass { class QuicStreamSettings extends XrayCommonClass { constructor(security='none', - key='', type='none') { + key=RandomUtil.randomSeq(10), type='none') { super(); this.security = security; this.key = key; @@ -460,7 +460,7 @@ class TlsStreamSettings extends XrayCommonClass { cipherSuites = '', rejectUnknownSni = false, certificates=[new TlsStreamSettings.Cert()], - alpn=[], + alpn=[ALPN_OPTION.H2,ALPN_OPTION.HTTP1], settings=new TlsStreamSettings.Settings()) { super(); this.sni = serverName; @@ -814,7 +814,7 @@ class Sniffing extends XrayCommonClass { class Inbound extends XrayCommonClass { constructor(port=RandomUtil.randomIntRange(10000, 60000), listen='', - protocol=Protocols.VMESS, + protocol=Protocols.VLESS, settings=null, streamSettings=new StreamSettings(), tag='', @@ -1140,7 +1140,7 @@ class Inbound extends XrayCommonClass { } } - if (security === 'reality') { + else if (security === 'reality') { params.set("security", "reality"); params.set("pbk", this.stream.reality.settings.publicKey); params.set("fp", this.stream.reality.settings.fingerprint); @@ -1158,6 +1158,10 @@ class Inbound extends XrayCommonClass { } } + else { + params.set("security", "none"); + } + const link = `vless://${uuid}@${address}:${port}`; const url = new URL(link); for (const [key, value] of params) { @@ -1316,7 +1320,7 @@ class Inbound extends XrayCommonClass { } } - if (security === 'reality') { + else if (security === 'reality') { params.set("security", "reality"); params.set("pbk", this.stream.reality.settings.publicKey); params.set("fp", this.stream.reality.settings.fingerprint); @@ -1330,6 +1334,9 @@ class Inbound extends XrayCommonClass { params.set("spx", this.stream.reality.settings.spiderX); } } + else { + params.set("security", "none"); + } const link = `trojan://${clientPassword}@${address}:${port}`; const url = new URL(link); diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js index 426735b0..44b15955 100644 --- a/web/assets/js/util/common.js +++ b/web/assets/js/util/common.js @@ -20,6 +20,14 @@ function sizeFormat(size) { } } +function cpuCoreFormat(cores) { + if (cores === 1) { + return "1 Core"; + } else { + return cores + " Cores"; + } +} + function base64(str) { return Base64.encode(str); } diff --git a/web/html/xui/form/client.html b/web/html/xui/form/client.html index bbe76e00..27a75165 100644 --- a/web/html/xui/form/client.html +++ b/web/html/xui/form/client.html @@ -19,7 +19,7 @@