From 838c667a874f8cfb2fab0b7c192679eafb480900 Mon Sep 17 00:00:00 2001 From: Senis Date: Thu, 27 Oct 2022 08:26:23 +0800 Subject: [PATCH] fix: typo --- .github/build/friendly-filenames.json | 126 ++++++++++++++++++------- .github/workflows/codeql-analysis.yml | 50 +++++----- .github/workflows/docker.yml | 12 +-- .github/workflows/release.yml | 16 ++-- README.md | 9 ++ api/pmpanel/pmpanel.go | 7 +- api/pmpanel/pmpanel_test.go | 4 +- api/proxypanel/proxypanel.go | 7 +- api/proxypanel/proypanel_test.go | 2 +- api/sspanel/sspanel.go | 9 +- api/sspanel/sspanel_test.go | 4 +- api/v2board/model.go | 6 +- api/v2board/v2board.go | 7 +- api/v2board/v2board_test.go | 2 +- api/v2raysocks/v2raysocks.go | 7 +- api/v2raysocks/v2raysocks_test.go | 2 +- app/mydispatcher/default.go | 5 +- common/legocmd/cmd/accounts_storage.go | 44 ++++----- common/legocmd/cmd/certs_storage.go | 16 ++-- common/legocmd/cmd/cmd_before.go | 3 +- common/legocmd/cmd/cmd_renew.go | 3 +- common/legocmd/cmd/cmd_revoke.go | 3 +- common/legocmd/cmd/cmd_run.go | 3 +- common/legocmd/cmd/setup.go | 3 +- common/legocmd/cmd/setup_challenges.go | 3 +- common/legocmd/lego.go | 5 +- common/legocmd/log/log.go | 1 - common/limiter/limiter.go | 3 +- common/limiter/rate.go | 3 +- common/rule/rule.go | 3 +- main/custom_inbound.json | 30 +++--- main/custom_outbound.json | 52 +++++----- main/distro/all/all.go | 5 +- main/dns.json | 12 +-- main/main.go | 5 +- main/route.json | 68 ++++++------- panel/panel.go | 15 +-- service/controller/control.go | 3 +- service/controller/controller.go | 29 +++--- service/controller/controller_test.go | 7 +- service/controller/inboundbuilder.go | 9 +- service/controller/outboundbuilder.go | 5 +- service/controller/userbuilder.go | 3 +- 43 files changed, 351 insertions(+), 260 deletions(-) diff --git a/.github/build/friendly-filenames.json b/.github/build/friendly-filenames.json index d885565..2c7fad4 100644 --- a/.github/build/friendly-filenames.json +++ b/.github/build/friendly-filenames.json @@ -1,33 +1,95 @@ { - "android-arm64": { "friendlyName": "android-arm64-v8a" }, - "darwin-amd64": { "friendlyName": "macos-64" }, - "darwin-arm64": { "friendlyName": "macos-arm64-v8a" }, - "dragonfly-amd64": { "friendlyName": "dragonfly-64" }, - "freebsd-386": { "friendlyName": "freebsd-32" }, - "freebsd-amd64": { "friendlyName": "freebsd-64" }, - "freebsd-arm64": { "friendlyName": "freebsd-arm64-v8a" }, - "freebsd-arm7": { "friendlyName": "freebsd-arm32-v7a" }, - "linux-386": { "friendlyName": "linux-32" }, - "linux-amd64": { "friendlyName": "linux-64" }, - "linux-arm5": { "friendlyName": "linux-arm32-v5" }, - "linux-arm64": { "friendlyName": "linux-arm64-v8a" }, - "linux-arm6": { "friendlyName": "linux-arm32-v6" }, - "linux-arm7": { "friendlyName": "linux-arm32-v7a" }, - "linux-mips64le": { "friendlyName": "linux-mips64le" }, - "linux-mips64": { "friendlyName": "linux-mips64" }, - "linux-mipslesoftfloat": { "friendlyName": "linux-mips32le-softfloat" }, - "linux-mipsle": { "friendlyName": "linux-mips32le" }, - "linux-mipssoftfloat": { "friendlyName": "linux-mips32-softfloat" }, - "linux-mips": { "friendlyName": "linux-mips32" }, - "linux-ppc64le": { "friendlyName": "linux-ppc64le" }, - "linux-ppc64": { "friendlyName": "linux-ppc64" }, - "linux-riscv64": { "friendlyName": "linux-riscv64" }, - "linux-s390x": { "friendlyName": "linux-s390x" }, - "openbsd-386": { "friendlyName": "openbsd-32" }, - "openbsd-amd64": { "friendlyName": "openbsd-64" }, - "openbsd-arm64": { "friendlyName": "openbsd-arm64-v8a" }, - "openbsd-arm7": { "friendlyName": "openbsd-arm32-v7a" }, - "windows-386": { "friendlyName": "windows-32" }, - "windows-amd64": { "friendlyName": "windows-64" }, - "windows-arm7": { "friendlyName": "windows-arm32-v7a" } - } \ No newline at end of file + "android-arm64": { + "friendlyName": "android-arm64-v8a" + }, + "darwin-amd64": { + "friendlyName": "macos-64" + }, + "darwin-arm64": { + "friendlyName": "macos-arm64-v8a" + }, + "dragonfly-amd64": { + "friendlyName": "dragonfly-64" + }, + "freebsd-386": { + "friendlyName": "freebsd-32" + }, + "freebsd-amd64": { + "friendlyName": "freebsd-64" + }, + "freebsd-arm64": { + "friendlyName": "freebsd-arm64-v8a" + }, + "freebsd-arm7": { + "friendlyName": "freebsd-arm32-v7a" + }, + "linux-386": { + "friendlyName": "linux-32" + }, + "linux-amd64": { + "friendlyName": "linux-64" + }, + "linux-arm5": { + "friendlyName": "linux-arm32-v5" + }, + "linux-arm64": { + "friendlyName": "linux-arm64-v8a" + }, + "linux-arm6": { + "friendlyName": "linux-arm32-v6" + }, + "linux-arm7": { + "friendlyName": "linux-arm32-v7a" + }, + "linux-mips64le": { + "friendlyName": "linux-mips64le" + }, + "linux-mips64": { + "friendlyName": "linux-mips64" + }, + "linux-mipslesoftfloat": { + "friendlyName": "linux-mips32le-softfloat" + }, + "linux-mipsle": { + "friendlyName": "linux-mips32le" + }, + "linux-mipssoftfloat": { + "friendlyName": "linux-mips32-softfloat" + }, + "linux-mips": { + "friendlyName": "linux-mips32" + }, + "linux-ppc64le": { + "friendlyName": "linux-ppc64le" + }, + "linux-ppc64": { + "friendlyName": "linux-ppc64" + }, + "linux-riscv64": { + "friendlyName": "linux-riscv64" + }, + "linux-s390x": { + "friendlyName": "linux-s390x" + }, + "openbsd-386": { + "friendlyName": "openbsd-32" + }, + "openbsd-amd64": { + "friendlyName": "openbsd-64" + }, + "openbsd-arm64": { + "friendlyName": "openbsd-arm64-v8a" + }, + "openbsd-arm7": { + "friendlyName": "openbsd-arm32-v7a" + }, + "windows-386": { + "friendlyName": "windows-32" + }, + "windows-amd64": { + "friendlyName": "windows-64" + }, + "windows-arm7": { + "friendlyName": "windows-arm32-v7a" + } +} \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d9ef584..0821246 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,34 +34,34 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language - #- run: | - # make bootstrap - # make release + #- run: | + # make bootstrap + # make release - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a75079a..ff407a3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,24 +21,20 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v2 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - - name: Log in to the Container registry + - name: Log in to the Container registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker meta + - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: ghcr.io/${{ github.repository }} - - - name: Build and push + - name: Build and push uses: docker/build-push-action@v2 with: context: . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8a685f..f53e952 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,14 +11,14 @@ on: - "go.sum" - ".github/workflows/*.yml" pull_request: - types: [opened, synchronize, reopened] + types: [ opened, synchronize, reopened ] paths: - "**/*.go" - "go.mod" - "go.sum" - ".github/workflows/*.yml" release: - types: [published] + types: [ published ] jobs: @@ -26,8 +26,8 @@ jobs: strategy: matrix: # Include amd64 on all platforms. - goos: [windows, freebsd, openbsd, linux, dragonfly, darwin] - goarch: [amd64, 386] + goos: [ windows, freebsd, openbsd, linux, dragonfly, darwin ] + goarch: [ amd64, 386 ] exclude: # Exclude i386 on darwin and dragonfly. - goarch: 386 @@ -92,7 +92,7 @@ jobs: # END S390X # END Other architectures fail-fast: false - + runs-on: ubuntu-latest env: GOOS: ${{ matrix.goos }} @@ -102,14 +102,14 @@ jobs: steps: - name: Checkout codebase uses: actions/checkout@v2 - - name: Show workflow information + - name: Show workflow information id: get_filename run: | export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" echo "::set-output name=ASSET_NAME::$_NAME" echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - + - name: Set up Go uses: actions/setup-go@v2 with: @@ -123,7 +123,7 @@ jobs: run: | mkdir -p build_assets go build -v -o build_assets/XrayR -trimpath -ldflags "-s -w -buildid=" ./main - + - name: Build Mips softfloat XrayR if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle' run: | diff --git a/README.md b/README.md index d5dbcb7..aa9e052 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # XrayR + [![](https://img.shields.io/badge/TgChat-@XrayR讨论-blue.svg)](https://t.me/XrayR_project) [![](https://img.shields.io/badge/Channel-@XrayR通知-blue.svg)](https://t.me/XrayR_channel) ![](https://img.shields.io/github/stars/XrayR-project/XrayR) @@ -14,11 +15,13 @@ A Xray backend framework that can easily support many panels. 如果您喜欢本项目,可以右上角点个star+watch,持续关注本项目的进展。 使用教程:[详细使用教程](https://xrayr-project.github.io/XrayR-doc/) + ## 免责声明 本项目只是本人个人学习开发并维护,本人不保证任何可用性,也不对使用本软件造成的任何后果负责。 ## 特点 + * 永久开源且免费。 * 支持V2ray,Trojan, Shadowsocks多种协议。 * 支持Vless和XTLS等新特性。 @@ -45,6 +48,7 @@ A Xray backend framework that can easily support many panels. | 节点端口限速 | √ | √ | √ | | 按照用户限速 | √ | √ | √ | | 自定义DNS | √ | √ | √ | + ## 支持前端 | 前端 | v2ray | trojan | shadowsocks | @@ -56,14 +60,19 @@ A Xray backend framework that can easily support many panels. | [WHMCS (V2RaySocks)](https://v2raysocks.doxtex.com/) | √ | √ | √ | ## 软件安装 + ### 一键安装 + ``` wget -N https://raw.githubusercontent.com/XrayR-project/XrayR-release/master/install.sh && bash install.sh ``` + ### 使用Docker部署软件 + [Docker部署教程](https://xrayr-project.github.io/XrayR-doc/xrayr-xia-zai-he-an-zhuang/install/docker) ### 手动安装 + [手动安装教程](https://xrayr-project.github.io/XrayR-doc/xrayr-xia-zai-he-an-zhuang/install/manual) ## 配置文件及详细使用教程 diff --git a/api/pmpanel/pmpanel.go b/api/pmpanel/pmpanel.go index dc2383e..76c25e6 100644 --- a/api/pmpanel/pmpanel.go +++ b/api/pmpanel/pmpanel.go @@ -11,8 +11,9 @@ import ( "strconv" "time" - "github.com/XrayR-project/XrayR/api" "github.com/go-resty/resty/v2" + + "github.com/XrayR-project/XrayR/api" ) // APIClient create a api client to the panel. @@ -76,7 +77,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) { // open the file file, err := os.Open(path) - //handle errors while opening + // handle errors while opening if err != nil { log.Printf("Error when opening file: %s", err) return LocalRuleList @@ -234,7 +235,7 @@ func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) { return nil } -//ReportNodeOnlineUsers reports online user ip +// ReportNodeOnlineUsers reports online user ip func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error { var nodeType = "" switch c.NodeType { diff --git a/api/pmpanel/pmpanel_test.go b/api/pmpanel/pmpanel_test.go index 7261426..acd860e 100644 --- a/api/pmpanel/pmpanel_test.go +++ b/api/pmpanel/pmpanel_test.go @@ -107,7 +107,7 @@ func TestReportReportNodeOnlineUsers(t *testing.T) { IP: fmt.Sprintf("1.1.1.%d", i), } } - //client.Debug() + // client.Debug() err = client.ReportNodeOnlineUsers(&onlineUserList) if err != nil { t.Error(err) @@ -128,7 +128,7 @@ func TestReportReportUserTraffic(t *testing.T) { Download: 114514, } } - //client.Debug() + // client.Debug() err = client.ReportUserTraffic(&generalUserTraffic) if err != nil { t.Error(err) diff --git a/api/proxypanel/proxypanel.go b/api/proxypanel/proxypanel.go index c096104..5b16235 100644 --- a/api/proxypanel/proxypanel.go +++ b/api/proxypanel/proxypanel.go @@ -11,8 +11,9 @@ import ( "strconv" "time" - "github.com/XrayR-project/XrayR/api" "github.com/go-resty/resty/v2" + + "github.com/XrayR-project/XrayR/api" ) // APIClient create a api client to the panel. @@ -72,7 +73,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) { // open the file file, err := os.Open(path) - //handle errors while opening + // handle errors while opening if err != nil { log.Printf("Error when opening file: %s", err) return LocalRuleList @@ -258,7 +259,7 @@ func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) { return nil } -//ReportNodeOnlineUsers reports online user ip +// ReportNodeOnlineUsers reports online user ip func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error { var path string diff --git a/api/proxypanel/proypanel_test.go b/api/proxypanel/proypanel_test.go index 7b7bb0a..7ce1f4e 100644 --- a/api/proxypanel/proypanel_test.go +++ b/api/proxypanel/proypanel_test.go @@ -111,7 +111,7 @@ func TestReportReportNodeOnlineUsers(t *testing.T) { IP: fmt.Sprintf("1.1.1.%d", i), } } - //client.Debug() + // client.Debug() err = client.ReportNodeOnlineUsers(&onlineUserList) if err != nil { t.Error(err) diff --git a/api/sspanel/sspanel.go b/api/sspanel/sspanel.go index d62d3ac..20940b6 100644 --- a/api/sspanel/sspanel.go +++ b/api/sspanel/sspanel.go @@ -13,8 +13,9 @@ import ( "sync" "time" - "github.com/XrayR-project/XrayR/api" "github.com/go-resty/resty/v2" + + "github.com/XrayR-project/XrayR/api" ) var ( @@ -89,7 +90,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) { // open the file file, err := os.Open(path) - //handle errors while opening + // handle errors while opening if err != nil { log.Printf("Error when opening file: %s", err) return LocalRuleList @@ -257,7 +258,7 @@ func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) { return nil } -//ReportNodeOnlineUsers reports online user ip +// ReportNodeOnlineUsers reports online user ip func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error { c.access.Lock() defer c.access.Unlock() @@ -380,7 +381,7 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *NodeInfoResponse) ( if nodeInfoResponse.RawServerString == "" { return nil, fmt.Errorf("No server info in response") } - //nodeInfo.RawServerString = strings.ToLower(nodeInfo.RawServerString) + // nodeInfo.RawServerString = strings.ToLower(nodeInfo.RawServerString) serverConf := strings.Split(nodeInfoResponse.RawServerString, ";") parsedPort, err := strconv.ParseInt(serverConf[1], 10, 32) diff --git a/api/sspanel/sspanel_test.go b/api/sspanel/sspanel_test.go index 7ef4a28..a87ccd5 100644 --- a/api/sspanel/sspanel_test.go +++ b/api/sspanel/sspanel_test.go @@ -105,7 +105,7 @@ func TestReportReportNodeOnlineUsers(t *testing.T) { IP: fmt.Sprintf("1.1.1.%d", i), } } - //client.Debug() + // client.Debug() err = client.ReportNodeOnlineUsers(&onlineUserList) if err != nil { t.Error(err) @@ -126,7 +126,7 @@ func TestReportReportUserTraffic(t *testing.T) { Download: 114514, } } - //client.Debug() + // client.Debug() err = client.ReportUserTraffic(&generalUserTraffic) if err != nil { t.Error(err) diff --git a/api/v2board/model.go b/api/v2board/model.go index 606995a..36f1507 100644 --- a/api/v2board/model.go +++ b/api/v2board/model.go @@ -1,7 +1,7 @@ package v2board type UserTraffic struct { - UID int `json:"user_id"` - Upload int64 `json:"u"` - Download int64 `json:"d"` + UID int `json:"user_id"` + Upload int64 `json:"u"` + Download int64 `json:"d"` } diff --git a/api/v2board/v2board.go b/api/v2board/v2board.go index edbb6dc..b2b32a3 100644 --- a/api/v2board/v2board.go +++ b/api/v2board/v2board.go @@ -12,9 +12,10 @@ import ( "sync" "time" - "github.com/XrayR-project/XrayR/api" "github.com/bitly/go-simplejson" "github.com/go-resty/resty/v2" + + "github.com/XrayR-project/XrayR/api" ) // APIClient create an api client to the panel. @@ -81,7 +82,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) { // open the file file, err := os.Open(path) - //handle errors while opening + // handle errors while opening if err != nil { log.Printf("Error when opening file: %s", err) return LocalRuleList @@ -294,7 +295,7 @@ func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) { return nil } -//ReportNodeOnlineUsers implements the API interface +// ReportNodeOnlineUsers implements the API interface func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error { return nil } diff --git a/api/v2board/v2board_test.go b/api/v2board/v2board_test.go index 68572fa..c3f6ed3 100644 --- a/api/v2board/v2board_test.go +++ b/api/v2board/v2board_test.go @@ -82,7 +82,7 @@ func TestReportReportUserTraffic(t *testing.T) { Download: 114514, } } - //client.Debug() + // client.Debug() err = client.ReportUserTraffic(&generalUserTraffic) if err != nil { t.Error(err) diff --git a/api/v2raysocks/v2raysocks.go b/api/v2raysocks/v2raysocks.go index b4d9ed9..9e1c64e 100644 --- a/api/v2raysocks/v2raysocks.go +++ b/api/v2raysocks/v2raysocks.go @@ -12,9 +12,10 @@ import ( "sync" "time" - "github.com/XrayR-project/XrayR/api" "github.com/bitly/go-simplejson" "github.com/go-resty/resty/v2" + + "github.com/XrayR-project/XrayR/api" ) // APIClient create an api client to the panel. @@ -80,7 +81,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) { // open the file file, err := os.Open(path) - //handle errors while opening + // handle errors while opening if err != nil { log.Printf("Error when opening file: %s", err) return LocalRuleList @@ -287,7 +288,7 @@ func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) { return nil } -//ReportNodeOnlineUsers implements the API interface +// ReportNodeOnlineUsers implements the API interface func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error { return nil } diff --git a/api/v2raysocks/v2raysocks_test.go b/api/v2raysocks/v2raysocks_test.go index b065d0a..76dc35f 100644 --- a/api/v2raysocks/v2raysocks_test.go +++ b/api/v2raysocks/v2raysocks_test.go @@ -83,7 +83,7 @@ func TestReportReportUserTraffic(t *testing.T) { Download: 114514, } } - //client.Debug() + // client.Debug() err = client.ReportUserTraffic(&generalUserTraffic) if err != nil { t.Error(err) diff --git a/app/mydispatcher/default.go b/app/mydispatcher/default.go index d99fa22..2d0cd2a 100644 --- a/app/mydispatcher/default.go +++ b/app/mydispatcher/default.go @@ -9,8 +9,6 @@ import ( "sync" "time" - "github.com/XrayR-project/XrayR/common/limiter" - "github.com/XrayR-project/XrayR/common/rule" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/log" @@ -26,6 +24,9 @@ import ( "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/pipe" + + "github.com/XrayR-project/XrayR/common/limiter" + "github.com/XrayR-project/XrayR/common/rule" ) var errSniffingTimeout = newError("timeout on sniffing") diff --git a/common/legocmd/cmd/accounts_storage.go b/common/legocmd/cmd/accounts_storage.go index e87440f..3051a7d 100644 --- a/common/legocmd/cmd/accounts_storage.go +++ b/common/legocmd/cmd/accounts_storage.go @@ -13,11 +13,12 @@ import ( "path/filepath" "strings" - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) const ( @@ -30,36 +31,35 @@ const ( // // rootPath: // -// ./.lego/accounts/ -// │ └── root accounts directory -// └── "path" option +// ./.lego/accounts/ +// │ └── root accounts directory +// └── "path" option // // rootUserPath: // -// ./.lego/accounts/localhost_14000/hubert@hubert.com/ -// │ │ │ └── userID ("email" option) -// │ │ └── CA server ("server" option) -// │ └── root accounts directory -// └── "path" option +// ./.lego/accounts/localhost_14000/hubert@hubert.com/ +// │ │ │ └── userID ("email" option) +// │ │ └── CA server ("server" option) +// │ └── root accounts directory +// └── "path" option // // keysPath: // -// ./.lego/accounts/localhost_14000/hubert@hubert.com/keys/ -// │ │ │ │ └── root keys directory -// │ │ │ └── userID ("email" option) -// │ │ └── CA server ("server" option) -// │ └── root accounts directory -// └── "path" option +// ./.lego/accounts/localhost_14000/hubert@hubert.com/keys/ +// │ │ │ │ └── root keys directory +// │ │ │ └── userID ("email" option) +// │ │ └── CA server ("server" option) +// │ └── root accounts directory +// └── "path" option // // accountFilePath: // -// ./.lego/accounts/localhost_14000/hubert@hubert.com/account.json -// │ │ │ │ └── account file -// │ │ │ └── userID ("email" option) -// │ │ └── CA server ("server" option) -// │ └── root accounts directory -// └── "path" option -// +// ./.lego/accounts/localhost_14000/hubert@hubert.com/account.json +// │ │ │ │ └── account file +// │ │ │ └── userID ("email" option) +// │ │ └── CA server ("server" option) +// │ └── root accounts directory +// └── "path" option type AccountsStorage struct { userID string rootPath string diff --git a/common/legocmd/cmd/certs_storage.go b/common/legocmd/cmd/certs_storage.go index 3e3575e..8d09ff7 100644 --- a/common/legocmd/cmd/certs_storage.go +++ b/common/legocmd/cmd/certs_storage.go @@ -11,11 +11,12 @@ import ( "strings" "time" - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" "github.com/urfave/cli" "golang.org/x/net/idna" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) const ( @@ -27,16 +28,15 @@ const ( // // rootPath: // -// ./.lego/certificates/ -// │ └── root certificates directory -// └── "path" option +// ./.lego/certificates/ +// │ └── root certificates directory +// └── "path" option // // archivePath: // -// ./.lego/archives/ -// │ └── archived certificates directory -// └── "path" option -// +// ./.lego/archives/ +// │ └── archived certificates directory +// └── "path" option type CertificatesStorage struct { rootPath string archivePath string diff --git a/common/legocmd/cmd/cmd_before.go b/common/legocmd/cmd/cmd_before.go index 2901742..f1326dd 100644 --- a/common/legocmd/cmd/cmd_before.go +++ b/common/legocmd/cmd/cmd_before.go @@ -1,8 +1,9 @@ package cmd import ( - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) func Before(ctx *cli.Context) error { diff --git a/common/legocmd/cmd/cmd_renew.go b/common/legocmd/cmd/cmd_renew.go index fa63c02..ebb47f7 100644 --- a/common/legocmd/cmd/cmd_renew.go +++ b/common/legocmd/cmd/cmd_renew.go @@ -5,11 +5,12 @@ import ( "crypto/x509" "time" - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) const ( diff --git a/common/legocmd/cmd/cmd_revoke.go b/common/legocmd/cmd/cmd_revoke.go index 6d2d664..9e80b93 100644 --- a/common/legocmd/cmd/cmd_revoke.go +++ b/common/legocmd/cmd/cmd_revoke.go @@ -1,8 +1,9 @@ package cmd import ( - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) func createRevoke() cli.Command { diff --git a/common/legocmd/cmd/cmd_run.go b/common/legocmd/cmd/cmd_run.go index 505fe60..7193d79 100644 --- a/common/legocmd/cmd/cmd_run.go +++ b/common/legocmd/cmd/cmd_run.go @@ -6,11 +6,12 @@ import ( "os" "strings" - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) func createRun() cli.Command { diff --git a/common/legocmd/cmd/setup.go b/common/legocmd/cmd/setup.go index 4fb6fda..9207e68 100644 --- a/common/legocmd/cmd/setup.go +++ b/common/legocmd/cmd/setup.go @@ -9,11 +9,12 @@ import ( "strings" "time" - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) const filePerm os.FileMode = 0o600 diff --git a/common/legocmd/cmd/setup_challenges.go b/common/legocmd/cmd/setup_challenges.go index eeb3970..b4003f1 100644 --- a/common/legocmd/cmd/setup_challenges.go +++ b/common/legocmd/cmd/setup_challenges.go @@ -5,7 +5,6 @@ import ( "strings" "time" - "github.com/XrayR-project/XrayR/common/legocmd/log" "github.com/go-acme/lego/v4/challenge" "github.com/go-acme/lego/v4/challenge/dns01" "github.com/go-acme/lego/v4/challenge/http01" @@ -15,6 +14,8 @@ import ( "github.com/go-acme/lego/v4/providers/http/memcached" "github.com/go-acme/lego/v4/providers/http/webroot" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/log" ) func setupChallenges(ctx *cli.Context, client *lego.Client) { diff --git a/common/legocmd/lego.go b/common/legocmd/lego.go index 9f292a1..71bca17 100644 --- a/common/legocmd/lego.go +++ b/common/legocmd/lego.go @@ -11,8 +11,9 @@ import ( "runtime" "strings" - "github.com/XrayR-project/XrayR/common/legocmd/cmd" "github.com/urfave/cli" + + "github.com/XrayR-project/XrayR/common/legocmd/cmd" ) var version = "dev" @@ -134,7 +135,7 @@ func (l *LegoCMD) HTTPCert(domain, email string) (CertPath string, KeyPath strin return CertPath, KeyPath, nil } -//RenewCert renew a domain cert +// RenewCert renew a domain cert func (l *LegoCMD) RenewCert(domain, email, certMode, provider string, DNSEnv map[string]string) (CertPath string, KeyPath string, err error) { var argstring string defer func() (string, string, error) { diff --git a/common/legocmd/log/log.go b/common/legocmd/log/log.go index b1335b0..35d5c93 100644 --- a/common/legocmd/log/log.go +++ b/common/legocmd/log/log.go @@ -57,4 +57,3 @@ func Warnf(format string, args ...interface{}) { func Infof(format string, args ...interface{}) { Printf("[INFO] "+format, args...) } - diff --git a/common/limiter/limiter.go b/common/limiter/limiter.go index b270153..678422b 100644 --- a/common/limiter/limiter.go +++ b/common/limiter/limiter.go @@ -5,8 +5,9 @@ import ( "fmt" "sync" - "github.com/XrayR-project/XrayR/api" "golang.org/x/time/rate" + + "github.com/XrayR-project/XrayR/api" ) type UserInfo struct { diff --git a/common/limiter/rate.go b/common/limiter/rate.go index 8f5b877..e891121 100644 --- a/common/limiter/rate.go +++ b/common/limiter/rate.go @@ -1,9 +1,8 @@ package limiter import ( - "io" - "context" + "io" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" diff --git a/common/rule/rule.go b/common/rule/rule.go index 731447b..6923d95 100644 --- a/common/rule/rule.go +++ b/common/rule/rule.go @@ -8,8 +8,9 @@ import ( "strings" "sync" - "github.com/XrayR-project/XrayR/api" mapset "github.com/deckarep/golang-set" + + "github.com/XrayR-project/XrayR/api" ) type RuleManager struct { diff --git a/main/custom_inbound.json b/main/custom_inbound.json index e7c8b54..1dc20e8 100644 --- a/main/custom_inbound.json +++ b/main/custom_inbound.json @@ -1,19 +1,19 @@ [ - { - "listen": "0.0.0.0", - "port": 1234, - "protocol": "socks", - "settings": { - "auth": "noauth", - "accounts": [ - { - "user": "my-username", - "pass": "my-password" - } - ], - "udp": false, - "ip": "127.0.0.1", - "userLevel": 0 + { + "listen": "0.0.0.0", + "port": 1234, + "protocol": "socks", + "settings": { + "auth": "noauth", + "accounts": [ + { + "user": "my-username", + "pass": "my-password" } + ], + "udp": false, + "ip": "127.0.0.1", + "userLevel": 0 } + } ] \ No newline at end of file diff --git a/main/custom_outbound.json b/main/custom_outbound.json index 03bde8d..f02ba10 100644 --- a/main/custom_outbound.json +++ b/main/custom_outbound.json @@ -1,28 +1,30 @@ [ - { - "tag": "IPv4_out", - "protocol": "freedom", - "settings": {} - }, - { - "tag": "IPv6_out", - "protocol": "freedom", - "settings": { - "domainStrategy": "UseIPv6" - } - }, - { - "tag": "socks5-warp", - "protocol": "socks", - "settings": { - "servers": [{ - "address": "127.0.0.1", - "port": 1080 - }] - } - }, - { - "protocol": "blackhole", - "tag": "block" + { + "tag": "IPv4_out", + "protocol": "freedom", + "settings": {} + }, + { + "tag": "IPv6_out", + "protocol": "freedom", + "settings": { + "domainStrategy": "UseIPv6" } + }, + { + "tag": "socks5-warp", + "protocol": "socks", + "settings": { + "servers": [ + { + "address": "127.0.0.1", + "port": 1080 + } + ] + } + }, + { + "protocol": "blackhole", + "tag": "block" + } ] \ No newline at end of file diff --git a/main/distro/all/all.go b/main/distro/all/all.go index f217203..29f99af 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -3,11 +3,12 @@ package all import ( // The following are necessary as they register handlers in their init functions. + _ "github.com/xtls/xray-core/app/proxyman/inbound" + _ "github.com/xtls/xray-core/app/proxyman/outbound" + // Required features. Can't remove unless there is replacements. // _ "github.com/xtls/xray-core/app/dispatcher" _ "github.com/XrayR-project/XrayR/app/mydispatcher" - _ "github.com/xtls/xray-core/app/proxyman/inbound" - _ "github.com/xtls/xray-core/app/proxyman/outbound" // Default commander and all its services. This is an optional feature. _ "github.com/xtls/xray-core/app/commander" diff --git a/main/dns.json b/main/dns.json index 27f1b61..f5bf199 100644 --- a/main/dns.json +++ b/main/dns.json @@ -1,8 +1,8 @@ { - "servers": [ - "1.1.1.1", - "8.8.8.8", - "localhost" - ], - "tag": "dns_inbound" + "servers": [ + "1.1.1.1", + "8.8.8.8", + "localhost" + ], + "tag": "dns_inbound" } \ No newline at end of file diff --git a/main/main.go b/main/main.go index 0673bc4..e1a9994 100644 --- a/main/main.go +++ b/main/main.go @@ -12,9 +12,10 @@ import ( "syscall" "time" - "github.com/XrayR-project/XrayR/panel" "github.com/fsnotify/fsnotify" "github.com/spf13/viper" + + "github.com/XrayR-project/XrayR/panel" ) var ( @@ -96,7 +97,7 @@ func main() { p.Start() defer p.Close() - //Explicitly triggering GC to remove garbage from config loading. + // Explicitly triggering GC to remove garbage from config loading. runtime.GC() // Running backend { diff --git a/main/route.json b/main/route.json index f8c8c13..57e3f16 100644 --- a/main/route.json +++ b/main/route.json @@ -1,36 +1,36 @@ { - "domainStrategy": "IPOnDemand", - "rules": [ - { - "type": "field", - "outboundTag": "block", - "ip": [ - "geoip:private" - ] - }, - { - "type": "field", - "outboundTag": "block", - "protocol": [ - "bittorrent" - ] - }, - { - "type": "field", - "outboundTag": "socks5-warp", - "domain": [] - }, - { - "type": "field", - "outboundTag": "IPv6_out", - "domain": [ - "geosite:netflix" - ] - }, - { - "type": "field", - "outboundTag": "IPv4_out", - "network": "udp,tcp" - } - ] + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "block", + "ip": [ + "geoip:private" + ] + }, + { + "type": "field", + "outboundTag": "block", + "protocol": [ + "bittorrent" + ] + }, + { + "type": "field", + "outboundTag": "socks5-warp", + "domain": [] + }, + { + "type": "field", + "outboundTag": "IPv6_out", + "domain": [ + "geosite:netflix" + ] + }, + { + "type": "field", + "outboundTag": "IPv4_out", + "network": "udp,tcp" + } + ] } \ No newline at end of file diff --git a/panel/panel.go b/panel/panel.go index 4d6d4fe..874ebaa 100644 --- a/panel/panel.go +++ b/panel/panel.go @@ -8,6 +8,14 @@ import ( "github.com/XrayR-project/XrayR/app/mydispatcher" + "github.com/imdario/mergo" + "github.com/r3labs/diff/v2" + "github.com/xtls/xray-core/app/proxyman" + "github.com/xtls/xray-core/app/stats" + "github.com/xtls/xray-core/common/serial" + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/infra/conf" + "github.com/XrayR-project/XrayR/api" "github.com/XrayR-project/XrayR/api/pmpanel" "github.com/XrayR-project/XrayR/api/proxypanel" @@ -17,13 +25,6 @@ import ( _ "github.com/XrayR-project/XrayR/main/distro/all" "github.com/XrayR-project/XrayR/service" "github.com/XrayR-project/XrayR/service/controller" - "github.com/imdario/mergo" - "github.com/r3labs/diff/v2" - "github.com/xtls/xray-core/app/proxyman" - "github.com/xtls/xray-core/app/stats" - "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/core" - "github.com/xtls/xray-core/infra/conf" ) // Panel Structure diff --git a/service/controller/control.go b/service/controller/control.go index a11052c..d29dfac 100644 --- a/service/controller/control.go +++ b/service/controller/control.go @@ -4,13 +4,14 @@ import ( "context" "fmt" - "github.com/XrayR-project/XrayR/api" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/inbound" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/proxy" + + "github.com/XrayR-project/XrayR/api" ) func (c *Controller) removeInbound(tag string) error { diff --git a/service/controller/controller.go b/service/controller/controller.go index 0f66068..ca60cbd 100644 --- a/service/controller/controller.go +++ b/service/controller/controller.go @@ -6,10 +6,6 @@ import ( "reflect" "time" - "github.com/XrayR-project/XrayR/api" - "github.com/XrayR-project/XrayR/app/mydispatcher" - "github.com/XrayR-project/XrayR/common/legocmd" - "github.com/XrayR-project/XrayR/common/serverstatus" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/core" @@ -17,6 +13,11 @@ import ( "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/features/stats" + + "github.com/XrayR-project/XrayR/api" + "github.com/XrayR-project/XrayR/app/mydispatcher" + "github.com/XrayR-project/XrayR/common/legocmd" + "github.com/XrayR-project/XrayR/common/serverstatus" ) type LimitInfo struct { @@ -85,7 +86,7 @@ func (c *Controller) Start() error { if err != nil { return err } - //sync controller userList + // sync controller userList c.userList = userInfo // Add Limiter @@ -387,31 +388,31 @@ func (c *Controller) addNewUser(userInfo *[]api.UserInfo, nodeInfo *api.NodeInfo } func compareUserList(old, new *[]api.UserInfo) (deleted, added []api.UserInfo) { - msrc := make(map[api.UserInfo]byte) //按源数组建索引 - mall := make(map[api.UserInfo]byte) //源+目所有元素建索引 + msrc := make(map[api.UserInfo]byte) // 按源数组建索引 + mall := make(map[api.UserInfo]byte) // 源+目所有元素建索引 - var set []api.UserInfo //交集 + var set []api.UserInfo // 交集 - //1.源数组建立map + // 1.源数组建立map for _, v := range *old { msrc[v] = 0 mall[v] = 0 } - //2.目数组中,存不进去,即重复元素,所有存不进去的集合就是并集 + // 2.目数组中,存不进去,即重复元素,所有存不进去的集合就是并集 for _, v := range *new { l := len(mall) mall[v] = 1 - if l != len(mall) { //长度变化,即可以存 + if l != len(mall) { // 长度变化,即可以存 l = len(mall) - } else { //存不了,进并集 + } else { // 存不了,进并集 set = append(set, v) } } - //3.遍历交集,在并集中找,找到就从并集中删,删完后就是补集(即并-交=所有变化的元素) + // 3.遍历交集,在并集中找,找到就从并集中删,删完后就是补集(即并-交=所有变化的元素) for _, v := range set { delete(mall, v) } - //4.此时,mall是补集,所有元素去源中找,找到就是删除的,找不到的必定能在目数组中找到,即新加的 + // 4.此时,mall是补集,所有元素去源中找,找到就是删除的,找不到的必定能在目数组中找到,即新加的 for v := range mall { _, exist := msrc[v] if exist { diff --git a/service/controller/controller_test.go b/service/controller/controller_test.go index d5d1cd2..0631cae 100644 --- a/service/controller/controller_test.go +++ b/service/controller/controller_test.go @@ -8,12 +8,13 @@ import ( "syscall" "testing" + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/infra/conf" + "github.com/XrayR-project/XrayR/api" "github.com/XrayR-project/XrayR/api/sspanel" _ "github.com/XrayR-project/XrayR/main/distro/all" . "github.com/XrayR-project/XrayR/service/controller" - "github.com/xtls/xray-core/core" - "github.com/xtls/xray-core/infra/conf" ) func TestController(t *testing.T) { @@ -68,7 +69,7 @@ func TestController(t *testing.T) { if err != nil { t.Error(err) } - //Explicitly triggering GC to remove garbage from config loading. + // Explicitly triggering GC to remove garbage from config loading. runtime.GC() { diff --git a/service/controller/inboundbuilder.go b/service/controller/inboundbuilder.go index dc0bd16..dd17c3b 100644 --- a/service/controller/inboundbuilder.go +++ b/service/controller/inboundbuilder.go @@ -1,19 +1,20 @@ -//Package generate the InbounderConfig used by add inbound +// Package generate the InbounderConfig used by add inbound package controller import ( "encoding/json" "fmt" - "github.com/XrayR-project/XrayR/api" - "github.com/XrayR-project/XrayR/common/legocmd" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/infra/conf" + + "github.com/XrayR-project/XrayR/api" + "github.com/XrayR-project/XrayR/common/legocmd" ) -//InboundBuilder build Inbound config for different protocol +// InboundBuilder build Inbound config for different protocol func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.InboundHandlerConfig, error) { inboundDetourConfig := &conf.InboundDetourConfig{} // Build Listen IP address diff --git a/service/controller/outboundbuilder.go b/service/controller/outboundbuilder.go index 6253edc..8cf821b 100644 --- a/service/controller/outboundbuilder.go +++ b/service/controller/outboundbuilder.go @@ -4,13 +4,14 @@ import ( "encoding/json" "fmt" - "github.com/XrayR-project/XrayR/api" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/infra/conf" + + "github.com/XrayR-project/XrayR/api" ) -//OutboundBuilder build freedom outbund config for addoutbound +// OutboundBuilder build freedom outbund config for addoutbound func OutboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.OutboundHandlerConfig, error) { outboundDetourConfig := &conf.OutboundDetourConfig{} outboundDetourConfig.Protocol = "freedom" diff --git a/service/controller/userbuilder.go b/service/controller/userbuilder.go index f27faa4..4c807cc 100644 --- a/service/controller/userbuilder.go +++ b/service/controller/userbuilder.go @@ -4,13 +4,14 @@ import ( "fmt" "strings" - "github.com/XrayR-project/XrayR/api" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/infra/conf" "github.com/xtls/xray-core/proxy/shadowsocks" "github.com/xtls/xray-core/proxy/trojan" "github.com/xtls/xray-core/proxy/vless" + + "github.com/XrayR-project/XrayR/api" ) var AEADMethod = []shadowsocks.CipherType{shadowsocks.CipherType_AES_128_GCM, shadowsocks.CipherType_AES_256_GCM, shadowsocks.CipherType_CHACHA20_POLY1305, shadowsocks.CipherType_XCHACHA20_POLY1305}