diff --git a/.github/workflows/RockyX86_64_build.yml b/.github/workflows/Rocky_build.yml similarity index 63% rename from .github/workflows/RockyX86_64_build.yml rename to .github/workflows/Rocky_build.yml index de6579e36a273924fd4b7b6c6afd91049dbea3ca..237ff4b5c43803ee69de164ada2644e026a02a91 100644 --- a/.github/workflows/RockyX86_64_build.yml +++ b/.github/workflows/Rocky_build.yml @@ -1,4 +1,4 @@ -name: rocky x86_64 build workflows +name: rocky build workflows on: push: @@ -14,18 +14,28 @@ permissions: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.runner }} container: image: rockylinux/rockylinux:9.5 + options: --platform ${{ matrix.platform }} + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + artifact: x86-64 + - arch: arm64 + runner: ubuntu-24.04-arm + platform: linux/arm64 + artifact: Arm64 steps: - # 检出您的主仓库代码 - name: Checkout main repository code uses: actions/checkout@v4 with: ref: 'develop' - # 检出依赖的xengine仓库到指定的xengine目录 - name: Checkout dependency repository (xengine) uses: actions/checkout@v4 with: @@ -37,28 +47,23 @@ jobs: with: repository: libxengine/XEngine_OPenSource path: XEngine_Source/XEngine_Depend - + + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + - name: install system package run: | dnf update -y - dnf install gcc g++ make git jq unzip -y - # 设置依赖库的环境变量 - - name: Set up Dependency rocky linux Environment - run: | - cd libxengine - chmod 777 * - ./XEngine_LINEnv.sh -i 0 + dnf install gcc g++ make git jq unzip wget -y - name: install xengine library - run: | + run: | latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_RockyLinux_9_x86-64.zip - unzip ./XEngine_RockyLinux_9_x86-64.zip -d ./XEngine_RockyLinux_9_x86-64 - cd XEngine_RockyLinux_9_x86-64 + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_RockyLinux_9_${{ matrix.artifact }}.zip + unzip ./XEngine_RockyLinux_9_${{ matrix.artifact }}.zip -d ./XEngine_RockyLinux_9_${{ matrix.artifact }} + cd XEngine_RockyLinux_9_${{ matrix.artifact }} - cp -rf ./XEngine_Include /usr/local/include - find ./XEngine_Linux -name "*.so" -exec cp {} /usr/lib64 \; - ldconfig - + chmod 777 * + ./XEngine_LINEnv.sh -i 3 - name: make run: | cd XEngine_Source @@ -78,6 +83,6 @@ jobs: - name: Upload folder as artifact with RockyLinux uses: actions/upload-artifact@v4 with: - name: XEngine_ProxyServiceApp-RockyLinux_9_x86_64 + name: XEngine_ProxyServiceApp-RockyLinux_9_${{ matrix.artifact }} path: XEngine_Release/ retention-days: 1 diff --git a/.github/workflows/UbuntuArm64_build.yml b/.github/workflows/UbuntuArm64_build.yml deleted file mode 100644 index 8a898fcebb98a889867defc0d8856d77be054b96..0000000000000000000000000000000000000000 --- a/.github/workflows/UbuntuArm64_build.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: ubuntu Arm64 build workflows - -on: - push: - branches: - - 'develop' - paths: - - 'XEngine_Source/**' - - 'XEngine_Release/**' - - '.github/**' - -jobs: - build: - runs-on: ubuntu-24.04 - env: - IMAGE_NAME: ubuntu:24.04 - - strategy: - fail-fast: false - matrix: - arch: [linux/arm64] - - steps: - - name: Checkout main repository code - uses: actions/checkout@v4 - with: - ref: 'develop' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Build ${{ matrix.arch }} - run: | - docker run --platform ${{ matrix.arch }} --rm \ - -v ${{ github.workspace }}:/workspace \ - -w /workspace ${{ env.IMAGE_NAME }} /bin/sh -c ' - set -e - apt update -y - apt install git make g++ wget curl jq unzip -y - - git config --global --add safe.directory /workspace - git submodule init - git submodule update - - latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_24.04_Arm64.zip - unzip ./XEngine_UBuntu_24.04_Arm64.zip -d ./XEngine_UBuntu_24.04_Arm64 - cd XEngine_UBuntu_24.04_Arm64 - - chmod 777 ./XEngine_LINEnv.sh - ./XEngine_LINEnv.sh -i 0 - - cp -rf ./XEngine_Include /usr/local/include - find ./XEngine_Linux -name "*.so" -exec cp {} /usr/local/lib \; - ldconfig - cd .. - - cd XEngine_Source - make ARCH=Arm64 RELEASE=1 - make FLAGS=InstallAll - make FLAGS=CleanAll - cd .. - - cd XEngine_Release - ./XEngine_ProxyServiceApp -t - chown -R $(id -u):$(id -g) . - chmod -R a+r . ' - - - name: Upload folder as artifact with ubuntu Arm64 - uses: actions/upload-artifact@v4 - with: - name: XEngine_ProxyServiceApp-Ubuntu_24.04_Arm64 - path: XEngine_Release/ - retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/ubuntu86_64_build.yml b/.github/workflows/Ubuntu_build.yml similarity index 49% rename from .github/workflows/ubuntu86_64_build.yml rename to .github/workflows/Ubuntu_build.yml index 599e8fe2547dea40c3c1012e697f6dd4649e3b02..8a702acbc90b72ba8054a4452b43606b33615687 100644 --- a/.github/workflows/ubuntu86_64_build.yml +++ b/.github/workflows/Ubuntu_build.yml @@ -1,4 +1,4 @@ -name: ubuntu x86_64 build workflows +name: ubuntu build workflows on: push: @@ -17,16 +17,16 @@ jobs: include: - os: ubuntu-22.04 - os: ubuntu-24.04 + - os: ubuntu-22.04-arm + - os: ubuntu-24.04-arm runs-on: ${{ matrix.os }} steps: - # 检出您的主仓库代码 - name: Checkout main repository code uses: actions/checkout@v4 with: ref: 'develop' - # 检出依赖的xengine仓库到指定的xengine目录 - name: Checkout dependency repository (xengine) uses: actions/checkout@v4 with: @@ -38,28 +38,45 @@ jobs: git submodule init git submodule update - - name: Set up Dependency ubuntu24.04 Environment + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + + - name: Set up Dependency ubuntu24.04 x86-64 Environment if: matrix.os == 'ubuntu-24.04' run: | cd libxengine chmod 777 * sudo ./XEngine_LINEnv.sh -i 3 - - name: Set up Dependency ubuntu22.04 Environment + - name: Set up Dependency ubuntu22.04 x86-64 Environment if: matrix.os == 'ubuntu-22.04' run: | - cd libxengine - chmod 777 * - sudo ./XEngine_LINEnv.sh -i 0 - latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_22.04_x86-64.zip unzip ./XEngine_UBuntu_22.04_x86-64.zip -d ./XEngine_UBuntu_22.04_x86-64 cd XEngine_UBuntu_22.04_x86-64 - sudo cp -rf ./XEngine_Include /usr/local/include - sudo find ./XEngine_Linux -name "*.so" -exec cp {} /usr/local/lib \; - sudo ldconfig - + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 + - name: Set up Dependency ubuntu22.04 arm Environment + if: matrix.os == 'ubuntu-22.04-arm' + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_22.04_Arm64.zip + unzip ./XEngine_UBuntu_22.04_Arm64.zip -d ./XEngine_UBuntu_22.04_Arm64 + cd XEngine_UBuntu_22.04_Arm64 + + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 + - name: Set up Dependency ubuntu24.04 arm Environment + if: matrix.os == 'ubuntu-24.04-arm' + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_UBuntu_24.04_Arm64.zip + unzip ./XEngine_UBuntu_24.04_Arm64.zip -d ./XEngine_UBuntu_24.04_Arm64 + cd XEngine_UBuntu_24.04_Arm64 + + chmod 777 * + sudo ./XEngine_LINEnv.sh -i 3 - name: make run: | cd XEngine_Source @@ -76,17 +93,31 @@ jobs: cd XEngine_Release ./XEngine_ProxyServiceApp -t - - name: Upload folder as artifact with ubuntu22.04 + - name: Upload folder as artifact with ubuntu22.04 x86-64 if: matrix.os == 'ubuntu-22.04' uses: actions/upload-artifact@v4 with: name: XEngine_ProxyServiceApp-Ubuntu_22.04_x86_64 path: XEngine_Release/ retention-days: 1 - - name: Upload folder as artifact with ubuntu24.04 + - name: Upload folder as artifact with ubuntu24.04 x86-64 if: matrix.os == 'ubuntu-24.04' uses: actions/upload-artifact@v4 with: name: XEngine_ProxyServiceApp-Ubuntu_24.04_x86_64 path: XEngine_Release/ + retention-days: 1 + - name: Upload folder as artifact with ubuntu22.04 Arm64 + if: matrix.os == 'ubuntu-22.04-arm' + uses: actions/upload-artifact@v4 + with: + name: XEngine_ProxyServiceApp-Ubuntu_22.04_Arm64 + path: XEngine_Release/ + retention-days: 1 + - name: Upload folder as artifact with ubuntu24.04 Arm64 + if: matrix.os == 'ubuntu-24.04-arm' + uses: actions/upload-artifact@v4 + with: + name: XEngine_ProxyServiceApp-Ubuntu_24.04_Arm64 + path: XEngine_Release/ retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/RockyArm64_build.yml b/.github/workflows/debian_build.yml similarity index 33% rename from .github/workflows/RockyArm64_build.yml rename to .github/workflows/debian_build.yml index 5b339785cf56a9b363a36182ffb8fd5f402f9372..6ffa2c1ddf076fc1b61a4bd312dd55937a427cf4 100644 --- a/.github/workflows/RockyArm64_build.yml +++ b/.github/workflows/debian_build.yml @@ -1,78 +1,85 @@ -name: rocky Arm64 build workflows +name: debian build workflows on: push: - branches: + branches: - 'develop' paths: - 'XEngine_Source/**' - 'XEngine_Release/**' - '.github/**' - + permissions: contents: read - + jobs: build: - runs-on: ubuntu-24.04 - env: - IMAGE_NAME: rockylinux/rockylinux:9.5 - + runs-on: ${{ matrix.runner }} + container: + image: debian:bookworm + options: --platform ${{ matrix.platform }} strategy: - fail-fast: false matrix: - arch: [linux/arm64] + include: + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + artifact: x86-64 steps: - # 检出您的主仓库代码 - name: Checkout main repository code uses: actions/checkout@v4 with: ref: 'develop' - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Build ${{ matrix.arch }} - run: | - docker run --platform ${{ matrix.arch }} --rm \ - -v ${{ github.workspace }}:/workspace \ - -w /workspace ${{ env.IMAGE_NAME }} /bin/sh -c ' - set -e - dnf update -y - dnf install --allowerasing git make g++ wget curl jq unzip -y - - git config --global --add safe.directory /workspace - git submodule init - git submodule update - latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_RockyLinux_9_Arm64.zip - unzip ./XEngine_RockyLinux_9_Arm64.zip -d ./XEngine_RockyLinux_9_Arm64 - cd XEngine_RockyLinux_9_Arm64 + - name: Checkout dependency repository (xengine) + uses: actions/checkout@v4 + with: + repository: libxengine/libxengine + path: libxengine - chmod 777 ./XEngine_LINEnv.sh - ./XEngine_LINEnv.sh -i 0 + - name: sub module checkout (opensource) + uses: actions/checkout@v4 + with: + repository: libxengine/XEngine_OPenSource + path: XEngine_Source/XEngine_Depend - cp -rf ./XEngine_Include /usr/local/include - find ./XEngine_Linux -name "*.so" -exec cp {} /usr/lib64 \; - ldconfig - cd .. + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + + - name: install system package + run: | + apt update -y + apt install gcc g++ make git jq unzip curl wget -y + - name: install xengine library + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Debian_12_${{ matrix.artifact }}.zip + unzip ./XEngine_Debian_12_${{ matrix.artifact }}.zip -d ./XEngine_Debian_12_${{ matrix.artifact }} + cd XEngine_Debian_12_${{ matrix.artifact }} + + chmod 777 * + ./XEngine_LINEnv.sh -i 3 + - name: make + run: | cd XEngine_Source - make ARCH=Arm64 RELEASE=1 + make make FLAGS=InstallAll - make FLAGS=CleanAll - cd .. + make FLAGS=CleanAll + make RELEASE=1 + make FLAGS=InstallAll + make FLAGS=CleanAll + cd .. + - name: test + run: | cd XEngine_Release ./XEngine_ProxyServiceApp -t - chown -R $(id -u):$(id -g) . - chmod -R a+r . ' - - name: Upload folder as artifact with RockyLinux + - name: Upload folder as artifact uses: actions/upload-artifact@v4 with: - name: XEngine_ProxyServiceApp-RockyLinux_9_Arm64 + name: XEngine_ProxyServiceApp-Debian_12_x86-64 path: XEngine_Release/ - retention-days: 1 + retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/fedora_build.yml b/.github/workflows/fedora_build.yml new file mode 100644 index 0000000000000000000000000000000000000000..fe1d161ef8c5de09527c4b168d3e5025380a5e1f --- /dev/null +++ b/.github/workflows/fedora_build.yml @@ -0,0 +1,89 @@ +name: fedora build workflows + +on: + push: + branches: + - 'develop' + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + - '.github/**' + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ matrix.runner }} + container: + image: fedora:${{ matrix.fedora-version }} + options: --platform ${{ matrix.platform }} + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + fedora-version: 42 + artifact: x86-64 + - arch: amd64 + runner: ubuntu-24.04 + platform: linux/amd64 + fedora-version: 41 + artifact: x86-64 + + steps: + - name: Checkout main repository code + uses: actions/checkout@v4 + + - name: Checkout dependency repository (xengine) + uses: actions/checkout@v4 + with: + repository: libxengine/libxengine + path: libxengine + + - name: sub module checkout (opensource) + uses: actions/checkout@v4 + with: + repository: libxengine/XEngine_OPenSource + path: XEngine_Source/XEngine_Depend + + - name: install system package + run: | + dnf update -y + dnf install gcc g++ make git jq unzip wget -y + + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + + - name: install xengine library + run: | + latest_tag=$(curl -s https://api.github.com/repos/libxengine/libxengine/releases/latest | jq -r .tag_name) + wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }}.zip + unzip ./XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }}.zip -d ./XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }} + cd XEngine_Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }} + + chmod 777 * + ./XEngine_LINEnv.sh -i 3 + - name: make + run: | + cd XEngine_Source + make + make FLAGS=InstallAll + make FLAGS=CleanAll + + make RELEASE=1 + make FLAGS=InstallAll + make FLAGS=CleanAll + cd .. + - name: test + run: | + cd XEngine_Release + ./XEngine_ProxyServiceApp -t + + - name: Upload folder as artifact + uses: actions/upload-artifact@v4 + with: + name: XEngine_ProxyServiceApp-Fedora_${{ matrix.fedora-version }}_${{ matrix.artifact }} + path: XEngine_Release/ + retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/macbuild.yml b/.github/workflows/macbuild.yml index b069251ed3b53c8f11d9fb4840dbfdb0bd982817..e07fc55551a6cb26ed871dbdbb8ff87ec04fd11b 100644 --- a/.github/workflows/macbuild.yml +++ b/.github/workflows/macbuild.yml @@ -36,9 +36,12 @@ jobs: git submodule init git submodule update + - name: Set TERM variable + run: echo "TERM=xterm" >> $GITHUB_ENV + - name: brew install run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - + - name: Set up Dependency x86_64 Environment if: matrix.os == 'macos-13' run: | @@ -48,21 +51,13 @@ jobs: - name: Set up Dependency Arm64 Environment if: matrix.os == 'macos-14' run: | - cd libxengine - chmod 777 * - ./XEngine_LINEnv.sh -i 0 - latest_tag=$(git ls-remote --tags --sort="v:refname" https://github.com/libxengine/libxengine.git | awk '{print $2}' | sed 's/refs\/tags\///' | tail -n 1) - wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Mac_Arm64.zip unzip ./XEngine_Mac_Arm64.zip -d ./XEngine_Mac_Arm64 cd XEngine_Mac_Arm64 - sudo mkdir -p /usr/local/include - sudo mkdir -p /usr/local/lib - sudo cp -rf ./XEngine_Include /usr/local/include - sudo find ./XEngine_Mac -name "*.dylib" -exec cp {} /usr/local/lib \; - + chmod 777 * + ./XEngine_LINEnv.sh -i 3 - name: make debug run: | cd XEngine_Source diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2dda2ce4f014b6ca9a741d9c25de52a878476c86..607a17e083443032c50c6cb90b23c5dcebd3e0fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,37 +16,37 @@ jobs: with: fetch-depth: 0 - - name: Download x86_64 ubuntubuild + - name: Download ubuntu build uses: dawidd6/action-download-artifact@v6 with: - workflow: ubuntu86_64_build.yml + workflow: Ubuntu_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true if_no_artifact_found: fail path: ./XRelease/ - - name: Download Arm64 ubuntubuild + - name: Download fedora build uses: dawidd6/action-download-artifact@v6 with: - workflow: UbuntuArm64_build.yml + workflow: fedora_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true if_no_artifact_found: fail path: ./XRelease/ - - name: Download x86_64 Rockylinux + - name: Download debian build uses: dawidd6/action-download-artifact@v6 with: - workflow: RockyX86_64_build.yml + workflow: debian_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true if_no_artifact_found: fail path: ./XRelease/ - - name: Download Arm64 Rockylinux + - name: Download Rockylinux uses: dawidd6/action-download-artifact@v6 with: - workflow: RockyArm64_build.yml + workflow: Rocky_build.yml workflow_conclusion: success check_artifacts: false skip_unpack: true diff --git a/CHANGELOG b/CHANGELOG index d0693664542676599ea9e93d6c68029872a0c9aa..fcda20de69e4a3ab28acf3645d83031b43042155 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,23 @@ +XEngine_ProxyServer V1.13.0.1001 + +增加:帮助模块 +增加:代理转发多后端支持 +增加:代理转发支持hash ip,随机,最小选择模式 +增加:更多CI发布编译支持 +更新:依赖库 +优化:makefile 编译选项 +修改:信息报告仅在release发布版本生效 +修改:代理转发删除原始端口规则匹配 + +added:module help +added:proxy forward dest list support +added:hash ip,random,min forward mode support for proxy +added:ci more release build support +update:depend library +improved:make file build flags +modify:only release work for info report +modify:delete source port rule match for proxy forward +====================================================================================== XEngine_ProxyServer V1.12.0.1001 增加:windows arm64编译支持 diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx index 34ebcc3ef02706a7b586fce00d6b87d6ed290368..f6af63922100a3731232e1ca0632588b9190ce89 100644 Binary files a/XEngine_Docment/Docment_en.docx and b/XEngine_Docment/Docment_en.docx differ diff --git a/XEngine_Docment/Docment_zh.docx b/XEngine_Docment/Docment_zh.docx index 8598b9739f7b551f06b4741338eae2a279651cfd..6bf8df71c57dd5e8243023baea15a040fcf546db 100644 Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index 849dfa7f3aaad4d66c8d83a2a18f490c59cdfced..adac7ab1694833a7d291d18eca164f03128eec04 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -31,10 +31,14 @@ "tszServiceName":"XEngine_ProxyServer" }, "XProxy": { - "tszDefaultAddr": "10.0.4.69:5403", + "nRuleMode": 0, + "tszDestIPAddr": [ + "127.0.0.1:5501", + "118.25.14.242:5501" + ], "tszRuleIPAddr": [ "10.0.0.1-10.0.4.69:5403", - "5000-10.0.4.69:5403" + "10.0.0.2-10.0.4.69:5403" ] } } \ No newline at end of file diff --git a/XEngine_Release/XEngine_Config/XEngine_Version.json b/XEngine_Release/XEngine_Config/XEngine_Version.json index 175bd8c47b0ded708a4e46f651a7a43c9f1fb49d..f87e0465a30dbd1cfd1469df5075725259f5b9f7 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Version.json +++ b/XEngine_Release/XEngine_Config/XEngine_Version.json @@ -1,5 +1,6 @@ { "XVer": [ + "1.13.0.1001 Build20250519", "1.12.0.1001 Build20250325", "1.11.0.1001 Build20250121", "1.10.0.1001 Build20241115", diff --git a/XEngine_Source/Makefile b/XEngine_Source/Makefile index a4aae7cf85a9606c5c780c4bf42db6ccb105b823..c9cb5263363198006ad355c627a5756518e634c7 100644 --- a/XEngine_Source/Makefile +++ b/XEngine_Source/Makefile @@ -9,6 +9,7 @@ THIRDPART_MODULE_REPORT = ./XEngine_Depend/XEngine_Module/XEngine_InfoReport MODULE_CONFIGURE_PATH = ./XEngine_ModuleConfigure MODULE_PROTOCOL_PATH = ./XEngine_ModuleProtocol MODULE_SESSION_PATH = ./XEngine_ModuleSession +MODULE_HELP_PATH = ./XEngine_ModuleHelp APP_SERVICE_PATH = ./XEngine_ServiceApp ifeq ($(PLATFORM),linux) @@ -18,7 +19,7 @@ else ifeq ($(PLATFORM),mac) endif XENGINE_MODULES = libjsoncpp.so libXEngine_InfoReport.so \ - libXEngine_ModuleConfigure.so libXEngine_ModuleProtocol.so libXEngine_ModuleSession.so \ + libXEngine_ModuleConfigure.so libXEngine_ModuleProtocol.so libXEngine_ModuleSession.so libXEngine_ModuleHelp.so \ XEngine_ServiceApp.exe .PHONY:MakeAll @@ -34,14 +35,16 @@ libXEngine_InfoReport.so: ifeq ($(FLAGS), InstallAll) cp $(THIRDPART_MODULE_REPORT)/libXEngine_InfoReport.$(FILEEXT) ../XEngine_Release/ else - make -C $(THIRDPART_MODULE_REPORT) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(THIRDPART_MODULE_REPORT) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) endif libXEngine_ModuleConfigure.so: - make -C $(MODULE_CONFIGURE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_CONFIGURE_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) libXEngine_ModuleProtocol.so: - make -C $(MODULE_PROTOCOL_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(MODULE_PROTOCOL_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) libXEngine_ModuleSession.so: - make -C $(MODULE_SESSION_PATH) PLATFORM=$(PLATFORM) $(FLAGS) - + make -C $(MODULE_SESSION_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) +libXEngine_ModuleHelp.so: + make -C $(MODULE_HELP_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) + XEngine_ServiceApp.exe: - make -C $(APP_SERVICE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) + make -C $(APP_SERVICE_PATH) PLATFORM=$(PLATFORM) UNICODE=$(UNICODE) RELEASE=$(RELEASE) $(FLAGS) diff --git a/XEngine_Source/XEngine.sln b/XEngine_Source/XEngine.sln index 93076f1e7211a6b6f95a55a54458a8b72a3a7c99..bc116844501dc36745b7ecf2aa66cc082dc9d68e 100644 --- a/XEngine_Source/XEngine.sln +++ b/XEngine_Source/XEngine.sln @@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_ServiceApp", "XEngine_ServiceApp\XEngine_ServiceApp.vcxproj", "{B94018F9-541B-4BE4-A2A8-AD49DD35357B}" ProjectSection(ProjectDependencies) = postProject {237AF017-9AD2-44D8-A6C4-ECDEF7674FF2} = {237AF017-9AD2-44D8-A6C4-ECDEF7674FF2} + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB} = {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB} {9512A610-7197-4522-9AEF-1486619C99FE} = {9512A610-7197-4522-9AEF-1486619C99FE} {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} {F54F152C-594F-4465-A44E-2DB915B39760} = {F54F152C-594F-4465-A44E-2DB915B39760} @@ -38,6 +39,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_InfoReport", "XEngi {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_ModuleHelp", "XEngine_ModuleHelp\XEngine_ModuleHelp.vcxproj", "{7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -120,6 +123,18 @@ Global {F6520D2C-BB8E-45BB-964B-F5D6A4318A89}.Release|x64.Build.0 = Release|x64 {F6520D2C-BB8E-45BB-964B-F5D6A4318A89}.Release|x86.ActiveCfg = Release|Win32 {F6520D2C-BB8E-45BB-964B-F5D6A4318A89}.Release|x86.Build.0 = Release|Win32 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Debug|ARM64.Build.0 = Debug|ARM64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Debug|x64.ActiveCfg = Debug|x64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Debug|x64.Build.0 = Debug|x64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Debug|x86.ActiveCfg = Debug|Win32 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Debug|x86.Build.0 = Debug|Win32 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Release|ARM64.ActiveCfg = Release|ARM64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Release|ARM64.Build.0 = Release|ARM64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Release|x64.ActiveCfg = Release|x64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Release|x64.Build.0 = Release|x64 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Release|x86.ActiveCfg = Release|Win32 + {7A864141-B878-4A5E-B2A1-D5BB4CF58FCB}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/XEngine_Source/XEngine_Depend b/XEngine_Source/XEngine_Depend index fda9f7d9140cc6a32eecb499e2acb67e8e1c7e6f..5bc816462c2c1f04e282ecce6c4c12db0ec11029 160000 --- a/XEngine_Source/XEngine_Depend +++ b/XEngine_Source/XEngine_Depend @@ -1 +1 @@ -Subproject commit fda9f7d9140cc6a32eecb499e2acb67e8e1c7e6f +Subproject commit 5bc816462c2c1f04e282ecce6c4c12db0ec11029 diff --git a/XEngine_Source/XEngine_ModuleAuthorize/Makefile b/XEngine_Source/XEngine_ModuleAuthorize/Makefile index ccadc88a84f976c1b6cd24743644ebfb4f09e91f..79695ce2e4ddf5df8a535f9ae8c03fbc06af1000 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/Makefile +++ b/XEngine_Source/XEngine_ModuleAuthorize/Makefile @@ -1,11 +1,7 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ LOADSO = LIB = @@ -13,31 +9,29 @@ LIBEX = OBJECTS = ModuleAuthorize_User.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleConfigure/Makefile b/XEngine_Source/XEngine_ModuleConfigure/Makefile index 55722b118754c37d66acb1bbcf0adf5d5e35b403..83b206732c2b4449581fc7982021a31bf3208c84 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/Makefile +++ b/XEngine_Source/XEngine_ModuleConfigure/Makefile @@ -1,11 +1,7 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp LIB = -ljsoncpp @@ -13,31 +9,29 @@ LIBEX = OBJECTS = ModuleConfigure_Json.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h index e230a74c231c05218510766bf524787ddaa178e9..b4d18988042d52537e0b6592bbdcdf701ce7c09c 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h @@ -52,7 +52,8 @@ typedef struct tag_XEngine_ServiceConfig }st_XReport; struct { - XCHAR tszDefaultAddr[128]; + int nRuleMode; //模式 + std::list* pStl_ListDestAddr; std::list* pStl_ListRuleAddr; }st_XProxy; struct diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp index 9299982cbc834c45ec358e872ed48c76dfefc58e..02b3cc1eafb0fbf73bd02fec9a39e3a054191d4f 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp @@ -145,9 +145,17 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE return false; } Json::Value st_JsonXProxy = st_JsonRoot["XProxy"]; - pSt_ServerConfig->st_XProxy.pStl_ListRuleAddr = new list; - _tcsxcpy(pSt_ServerConfig->st_XProxy.tszDefaultAddr, st_JsonXProxy["tszDefaultAddr"].asCString()); + pSt_ServerConfig->st_XProxy.pStl_ListDestAddr = new list; + + pSt_ServerConfig->st_XProxy.nRuleMode = st_JsonXProxy["nRuleMode"].asInt(); + if (!st_JsonXProxy["tszDestIPAddr"].isNull()) + { + for (unsigned int i = 0; i < st_JsonXProxy["tszDestIPAddr"].size(); i++) + { + pSt_ServerConfig->st_XProxy.pStl_ListDestAddr->push_back(st_JsonXProxy["tszDestIPAddr"][i].asCString()); + } + } if (!st_JsonXProxy["tszRuleIPAddr"].isNull()) { for (unsigned int i = 0; i < st_JsonXProxy["tszRuleIPAddr"].size(); i++) diff --git a/XEngine_Source/XEngine_ModuleHelp/Makefile b/XEngine_Source/XEngine_ModuleHelp/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6101972f73bb440ad8e353c935ded2cdd5d48b13 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/Makefile @@ -0,0 +1,69 @@ +CC = g++ -Wall -std=c++20 -fPIC +PLATVER = +FILEEXT = +LIBFLAG = +LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp +LOADSO = +LIB = -lXEngine_BaseLib +LIBEX = +OBJECTS = ModuleHelp_APIHelp.o pch.o + +ifeq ($(RELEASE),1) +FLAGS = -c -D _RELEASE +DEBUG = -O2 +else + ifeq ($(PLATFORM),mac) + FLAGS = -c + DEBUG = -g -D _DEBUG + else + FLAGS = -c -lc_p + DEBUG = -g -pg -D _DEBUG + endif +endif + +ifeq ($(UNICODE),1) +override UNICODE := -D __UNICODE__ +else +override UNICODE := -D __ANSI__ +endif + +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + else + PLATVER = -D __UBUNTU__ + endif + FILEEXT = so + LIBFLAG = -shared + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + FILEEXT = dylib + LIBFLAG = -dynamiclib + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ +endif + + +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o libXEngine_ModuleHelp.$(FILEEXT) $(LIBFLAG) $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) + +ModuleHelp_APIHelp.o:./ModuleHelp_APIHelp/ModuleHelp_APIHelp.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleHelp_APIHelp/ModuleHelp_APIHelp.cpp + +pch.o:./pch.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp + + +InstallAll:InstallSo +InstallSo:./libXEngine_ModuleHelp.$(FILEEXT) + cp ./libXEngine_ModuleHelp.$(FILEEXT) ../../XEngine_Release/libXEngine_ModuleHelp.$(FILEEXT) + + +CleanAll:CleanObj CleanMk +CleanObj: + rm *.o +CleanMk: + rm *.$(FILEEXT) diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_APIHelp/ModuleHelp_APIHelp.cpp b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_APIHelp/ModuleHelp_APIHelp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c960cabf4ac230209d7f424bc4978aead5fbb6a4 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_APIHelp/ModuleHelp_APIHelp.cpp @@ -0,0 +1,75 @@ +#include "pch.h" +#include "ModuleHelp_APIHelp.h" +/******************************************************************** +// Created: 2025/05/14 15:11:37 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\ModuleHelp_APIHelp\ModuleHelp_APIHelp.cpp +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\ModuleHelp_APIHelp +// File Base: ModuleHelp_APIHelp +// File Ext: cpp +// Project: XEngine +// Author: qyt +// Purpose: 帮助函数 +// History: +*********************************************************************/ +CModuleHelp_APIHelp::CModuleHelp_APIHelp() +{ + +} +CModuleHelp_APIHelp::~CModuleHelp_APIHelp() +{ + +} +////////////////////////////////////////////////////////////////////////// +// 公用函数 +////////////////////////////////////////////////////////////////////////// +/******************************************************************** +函数名称:ModuleHelp_APIHelp_QSort +函数功能:快速排序算法 + 参数.一:lPBase + In/Out:In/Out + 类型:五类型指针 + 可空:N + 意思:输入:要排序的结构,输出:排序好的 + 参数.二:nNumber + In/Out:In + 类型:整数型 + 可空:N + 意思:输入要排序的个数 + 参数.三:nSize + In/Out:In + 类型:整数型 + 可空:N + 意思:输入要排序的结构大小 +返回值 + 类型:逻辑型 + 意思:是否排序成功 +备注: +*********************************************************************/ +bool CModuleHelp_APIHelp::ModuleHelp_APIHelp_QSort(XPVOID lPBase, int nNumber, int nSize) +{ + APIHelp_IsErrorOccur = false; + + qsort(lPBase, nNumber, nSize, ModuleHelp_APIHelp_QSortCmp); + + return true; +} +////////////////////////////////////////////////////////////////////////// +// 保护函数 +////////////////////////////////////////////////////////////////////////// +int CModuleHelp_APIHelp::ModuleHelp_APIHelp_QSortCmp(const void* lParam, const void* WParam) +{ + // 先把 a/b 当作指向 “SESSION_IPCONUT*” 的指针来处理 + const SESSION_IPCONUT* pSt_IPAParam = *(const SESSION_IPCONUT* const*)lParam; + const SESSION_IPCONUT* pSt_IPWParam = *(const SESSION_IPCONUT* const*)WParam; + + // 然后比较它们的字段 + if (pSt_IPAParam->nIPCount < pSt_IPWParam->nIPCount) + { + return -1; + } + else if (pSt_IPAParam->nIPCount > pSt_IPWParam->nIPCount) + { + return +1; + } + return 0; +} \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_APIHelp/ModuleHelp_APIHelp.h b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_APIHelp/ModuleHelp_APIHelp.h new file mode 100644 index 0000000000000000000000000000000000000000..125919123120fcdae19de9662a9d62e476d8cb16 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_APIHelp/ModuleHelp_APIHelp.h @@ -0,0 +1,23 @@ +#pragma once +/******************************************************************** +// Created: 2025/05/14 15:11:29 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\ModuleHelp_APIHelp\ModuleHelp_APIHelp.h +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\ModuleHelp_APIHelp +// File Base: ModuleHelp_APIHelp +// File Ext: h +// Project: XEngine +// Author: qyt +// Purpose: 帮助函数 +// History: +*********************************************************************/ + +class CModuleHelp_APIHelp +{ +public: + CModuleHelp_APIHelp(); + ~CModuleHelp_APIHelp(); +public: + bool ModuleHelp_APIHelp_QSort(XPVOID lPBase, int nNumber, int nSize); +private: + static int ModuleHelp_APIHelp_QSortCmp(const void* lParam, const void* WParam); +}; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Define.h b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Define.h new file mode 100644 index 0000000000000000000000000000000000000000..46caa30eeb04b4e8f4268d2f3fe2aaef87ea9a68 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Define.h @@ -0,0 +1,43 @@ +#pragma once +/******************************************************************** +// Created: 2025/05/14 14:29:52 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\ModuleHelp_Define.h +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp +// File Base: ModuleHelp_Define +// File Ext: h +// Project: XEngine +// Author: qyt +// Purpose: 导出定义 +// History: +*********************************************************************/ +////////////////////////////////////////////////////////////////////////// +// 导出函数 +////////////////////////////////////////////////////////////////////////// +extern "C" XLONG ModuleHelp_GetLastError(int* pInt_SysError = NULL); +/************************************************************************/ +/* 帮助函数 */ +/************************************************************************/ +/******************************************************************** +函数名称:ModuleHelp_APIHelp_QSort +函数功能:快速排序算法 + 参数.一:lPBase + In/Out:In/Out + 类型:五类型指针 + 可空:N + 意思:输入:要排序的结构,输出:排序好的 + 参数.二:nNumber + In/Out:In + 类型:整数型 + 可空:N + 意思:输入要排序的个数 + 参数.三:nSize + In/Out:In + 类型:整数型 + 可空:N + 意思:输入要排序的结构大小 +返回值 + 类型:逻辑型 + 意思:是否排序成功 +备注: +*********************************************************************/ +extern "C" bool ModuleHelp_APIHelp_QSort(XPVOID lPBase, int nNumber, int nSize); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Error.h b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Error.h new file mode 100644 index 0000000000000000000000000000000000000000..60cb6568337457254733798b095787b92b339286 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/ModuleHelp_Error.h @@ -0,0 +1,40 @@ +#pragma once +/******************************************************************** +// Created: 2021/12/29 10:29:54 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleAuthorize\ModuleAuth_Error.h +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleAuthorize +// File Base: ModuleAuth_Error +// File Ext: h +// Project: XEngine(网络通信引擎) +// Author: qyt +// Purpose: 导出错误 +// History: +*********************************************************************/ +/************************************************************************/ +/* 转发代理服务器错误 */ +/************************************************************************/ +#define ERROR_MODULE_SESSION_FORWARD_PARAMENT 0xC0001 //参数错误 +#define ERROR_MODULE_SESSION_FORWARD_NOTFOUND 0xC0002 //没有找到 +#define ERROR_MODULE_SESSION_FORWARD_BIND 0xC0003 //已经绑定 +#define ERROR_MODULE_SESSION_FORWARD_NOTFORWARD 0xC0004 //没有转发 +#define ERROR_MODULE_SESSION_FORWARD_EXIST 0xC0005 //已经存在 +/************************************************************************/ +/* SOCKS5服务器错误 */ +/************************************************************************/ +#define ERROR_MODULE_SESSION_SOCKS_PARAMENT 0xC1001 //参数错误 +#define ERROR_MODULE_SESSION_SOCKS_MALLOC 0xC1002 //申请内存失败 +#define ERROR_MODULE_SESSION_SOCKS_NOTFOUND 0xC1003 //没有找到 +#define ERROR_MODULE_SESSION_SOCKS_VERSION 0xC1004 //协议错误 +#define ERROR_MODULE_SESSION_SOCKS_NOTSET 0xC1005 //没有设置客户端数据 +/************************************************************************/ +/* 隧道代理服务错误 */ +/************************************************************************/ +#define ERROR_MODULE_SESSION_TUNNEL_PARAMENT 0xC2001 //参数错误 +#define ERROR_MODULE_SESSION_TUNNEL_MALLOC 0xC2002 //申请内存失败 +#define ERROR_MODULE_SESSION_TUNNEL_NOTFOUND 0xC2003 //没有找到 +#define ERROR_MODULE_SESSION_TUNNEL_NOTSET 0xC2004 //没有设置内容 +/************************************************************************/ +/* 全转发代理服务错误 */ +/************************************************************************/ +#define ERROR_MODULE_SESSION_PROXY_PARAMENT 0xC3001 //参数错误 +#define ERROR_MODULE_SESSION_PROXY_NOTFOUND 0xC3002 //没有找到 \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.def b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.def new file mode 100644 index 0000000000000000000000000000000000000000..956849b8ddbe0ecefd4f5dd2fe0a74cce40f179b --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.def @@ -0,0 +1,6 @@ +LIBRARY + +EXPORTS + ModuleHelp_GetLastError + + ModuleHelp_APIHelp_QSort \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj new file mode 100644 index 0000000000000000000000000000000000000000..2a4819e4cde74f0ca806d4f45f64b28794644c12 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj @@ -0,0 +1,257 @@ + + + + + Debug + ARM64 + + + Debug + Win32 + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {7a864141-b878-4a5e-b2a1-d5bb4cf58fcb} + XEngineModuleHelp + 10.0 + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + $(XEngine_Include);$(IncludePath) + $(XEngine_Lib32);$(LibraryPath) + + + $(XEngine_Include);$(IncludePath) + $(XEngine_Lib32);$(LibraryPath) + + + $(XEngine_Include);$(IncludePath) + $(XEngine_Lib64);$(LibraryPath) + + + $(XEngine_Include);$(IncludePath) + $(XEngine_LibArm64);$(LibraryPath) + + + $(XEngine_Include);$(IncludePath) + $(XEngine_Lib64);$(LibraryPath) + + + $(XEngine_Include);$(IncludePath) + $(XEngine_LibArm64);$(LibraryPath) + + + + Level3 + true + WIN32;_DEBUG;XENGINEMODULEHELP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + XEngine_ModuleHelp.def + + + + + Level3 + true + true + true + WIN32;NDEBUG;XENGINEMODULEHELP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + XEngine_ModuleHelp.def + + + + + Level3 + true + _DEBUG;XENGINEMODULEHELP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + XEngine_ModuleHelp.def + + + + + Level3 + true + _DEBUG;XENGINEMODULEHELP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + XEngine_ModuleHelp.def + + + + + Level3 + true + true + true + NDEBUG;XENGINEMODULEHELP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + XEngine_ModuleHelp.def + + + + + Level3 + true + true + true + NDEBUG;XENGINEMODULEHELP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + XEngine_ModuleHelp.def + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj.filters b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj.filters new file mode 100644 index 0000000000000000000000000000000000000000..28a3751070cd315e20a41149afcb84d4ef342620 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj.filters @@ -0,0 +1,56 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {d116225a-ee7b-456e-9994-ef9cd89381ac} + + + {199c4dc2-2c18-451f-92df-0ce0cde24ba2} + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件\ModuleHelp_APIHelp + + + + + 源文件 + + + 源文件 + + + 源文件\ModuleHelp_APIHelp + + + + + 源文件 + + + \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj.user b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj.user new file mode 100644 index 0000000000000000000000000000000000000000..88a550947edbc3c5003a41726f0749201fdb6822 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/XEngine_ModuleHelp.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/dllmain.cpp b/XEngine_Source/XEngine_ModuleHelp/dllmain.cpp new file mode 100644 index 0000000000000000000000000000000000000000..daed8c8f7ac50ca1466016a0529648d18125a7e7 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/dllmain.cpp @@ -0,0 +1,19 @@ +// dllmain.cpp : 定义 DLL 应用程序的入口点。 +#include "pch.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/XEngine_Source/XEngine_ModuleHelp/framework.h b/XEngine_Source/XEngine_ModuleHelp/framework.h new file mode 100644 index 0000000000000000000000000000000000000000..80cbbc9b06a9b0141f92ee19eceaed71328caff4 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/framework.h @@ -0,0 +1,5 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 +// Windows 头文件 +#include diff --git a/XEngine_Source/XEngine_ModuleHelp/pch.cpp b/XEngine_Source/XEngine_ModuleHelp/pch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c49d42977b5079ac3681cd675fbb9e49c2a1cfa --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/pch.cpp @@ -0,0 +1,35 @@ +#include "pch.h" +#include "ModuleHelp_APIHelp/ModuleHelp_APIHelp.h" +/******************************************************************** +// Created: 2025/05/14 15:06:43 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\pch.cpp +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp +// File Base: pch +// File Ext: cpp +// Project: XEngine +// Author: qyt +// Purpose: 导出实现 +// History: +*********************************************************************/ +bool APIHelp_IsErrorOccur = false; +XLONG APIHelp_dwErrorCode = 0; +////////////////////////////////////////////////////////////////////////// +CModuleHelp_APIHelp m_APIHelp; +////////////////////////////////////////////////////////////////////////// +// 导出函数 +////////////////////////////////////////////////////////////////////////// +extern "C" XLONG ModuleHelp_GetLastError(int* pInt_SysError) +{ + if (NULL != pInt_SysError) + { + *pInt_SysError = errno; + } + return APIHelp_dwErrorCode; +} +/************************************************************************/ +/* 帮助函数 */ +/************************************************************************/ +extern "C" bool ModuleHelp_APIHelp_QSort(XPVOID lPBase, int nNumber, int nSize) +{ + return m_APIHelp.ModuleHelp_APIHelp_QSort(lPBase, nNumber, nSize); +} \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleHelp/pch.h b/XEngine_Source/XEngine_ModuleHelp/pch.h new file mode 100644 index 0000000000000000000000000000000000000000..10fd7d943e50982bd2b104f46e2655dbe9b5e24e --- /dev/null +++ b/XEngine_Source/XEngine_ModuleHelp/pch.h @@ -0,0 +1,47 @@ +// pch.h: 这是预编译标头文件。 +// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 +// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 +// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 +// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 + +#ifndef PCH_H +#define PCH_H + +#ifdef _MSC_BUILD +// 添加要在此处预编译的标头 +#include "framework.h" +#include +#endif +#endif //PCH_H +#include +#include +#include +#include +#include +using namespace std; +#include +#include +#include +#include +#include +#include "../XEngine_ModuleSession/ModuleSession_Define.h" +#include "../XEngine_ModuleSession/ModuleSession_Error.h" +#include "ModuleHelp_Define.h" +#include "ModuleHelp_Error.h" +/******************************************************************** +// Created: 2025/05/14 15:07:11 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp\pch.h +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleHelp +// File Base: pch +// File Ext: h +// Project: XEngine +// Author: qyt +// Purpose: 公用头文件 +// History: +*********************************************************************/ +extern bool APIHelp_IsErrorOccur; +extern XLONG APIHelp_dwErrorCode; + +#ifdef _MSC_BUILD +#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib") +#endif \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/Makefile b/XEngine_Source/XEngine_ModuleProtocol/Makefile index 57f32329878b4f14023ff0b1261d7a79b5c11e84..ec96726b4228c18dee38a3b143a04a94a1558c67 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/Makefile +++ b/XEngine_Source/XEngine_ModuleProtocol/Makefile @@ -1,11 +1,7 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp LIB = -ljsoncpp @@ -13,31 +9,29 @@ LIBEX = OBJECTS = ModuleProtocol_Packet.o ModuleProtocol_Parse.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl diff --git a/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj b/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj index 7595bb0878b185d91a6a5ad53dd001448963b8f4..e69598ee9b2e31f4a01baca7f610731f0224ee53 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj +++ b/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.vcxproj @@ -98,7 +98,7 @@ - $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;$(IncludePath) + $(XEngine_Include);../XEngine_Depend/XEngine_Module/jsoncpp;..\XEngine_ModuleProtocol;$(IncludePath) $(XEngine_Lib32);$(LibraryPath) diff --git a/XEngine_Source/XEngine_ModuleSession/Makefile b/XEngine_Source/XEngine_ModuleSession/Makefile index 6f3b3792a00294c7b2e5534062c9edd588a469f3..586321d70363bea5aba49acb1f94640262822b08 100644 --- a/XEngine_Source/XEngine_ModuleSession/Makefile +++ b/XEngine_Source/XEngine_ModuleSession/Makefile @@ -1,43 +1,37 @@ CC = g++ -Wall -std=c++20 -fPIC -PLATFORM = linux PLATVER = -PLATDIR = FILEEXT = LIBFLAG = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp LOADSO = LIB = -lXEngine_BaseLib -lXEngine_Algorithm LIBEX = -OBJECTS = ModuleSession_Forward.o ModuleSession_Socks.o ModuleSession_Tunnel.o ModuleSession_Proxy.o pch.o +OBJECTS = ModuleSession_Forward.o ModuleSession_Socks.o ModuleSession_Tunnel.o ModuleSession_Proxy.o ModuleSession_ProxyRule.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif FILEEXT = so LIBFLAG = -shared @@ -46,7 +40,6 @@ ifeq ($(PLATFORM),linux) else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac FILEEXT = dylib LIBFLAG = -dynamiclib LIBEX = -lpthread -ldl @@ -65,6 +58,8 @@ ModuleSession_Tunnel.o:./ModuleSession_Tunnel/ModuleSession_Tunnel.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleSession_Tunnel/ModuleSession_Tunnel.cpp ModuleSession_Proxy.o:./ModuleSession_Proxy/ModuleSession_Proxy.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleSession_Proxy/ModuleSession_Proxy.cpp +ModuleSession_ProxyRule.o:./ModuleSession_Proxy/ModuleSession_ProxyRule.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleSession_Proxy/ModuleSession_ProxyRule.cpp pch.o:./pch.cpp $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h index 4c3ac2d15ace8d28f8d3ea8aa5ff43ef2efe5999..6c4fa599f0a28e79aac115af061e8a82e6e48461 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h @@ -27,6 +27,11 @@ typedef struct bool bForward; bool bAnony; }SESSION_FORWARD, * LPSESSION_FORWARD; +typedef struct +{ + int nIPCount; + XCHAR tszIPAddr[128]; +}SESSION_IPCONUT; ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// @@ -576,4 +581,94 @@ extern "C" bool ModuleSession_Proxy_List(SESSION_FORWARD*** pppSt_ListUser, int* 意思:是否成功 备注: *********************************************************************/ -extern "C" bool ModuleSession_Proxy_Delete(LPCXSTR lpszIPAddr); \ No newline at end of file +extern "C" bool ModuleSession_Proxy_Delete(LPCXSTR lpszIPAddr); +/******************************************************************** +函数名称:ModuleSession_ProxyRule_Insert +函数功能:插入一个后台服务 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要插入的后台服务 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_ProxyRule_Insert(LPCXSTR lpszIPAddr); +/******************************************************************** +函数名称:ModuleSession_ProxyRule_Delete +函数功能:删除一个后台服务地址 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的后台服务地址 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_ProxyRule_Delete(LPCXSTR lpszIPAddr); +/******************************************************************** +函数名称:ModuleSession_ProxyRule_Set +函数功能:设置后台服务信息 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的地址 + 参数.二:lpszUseAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入使用的客户端地址 + 参数.三:bAdd + In/Out:In + 类型:逻辑型 + 可空:Y + 意思:添加还是删除 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_ProxyRule_Set(LPCXSTR lpszIPAddr, LPCXSTR lpszUseAddr, bool bAdd = true); +/******************************************************************** +函数名称:ModuleSession_ProxyRule_GetCount +函数功能:获取统计信息 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的地址 + 参数.二:pInt_Count + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出个数 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_ProxyRule_GetCount(LPCXSTR lpszIPAddr, int* pInt_Count); +/******************************************************************** +函数名称:ModuleSession_ProxyRule_GetList +函数功能:获取所有列表 + 参数.一:pppSt_IPCount + In/Out:In + 类型:三级指针 + 可空:N + 意思:输出获取到的列表信息 + 参数.二:pInt_Count + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出列表个数 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleSession_ProxyRule_GetList(SESSION_IPCONUT*** pppSt_IPCount, int* pInt_Count); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Proxy/ModuleSession_ProxyRule.cpp b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Proxy/ModuleSession_ProxyRule.cpp new file mode 100644 index 0000000000000000000000000000000000000000..feaddb7714903a4158c59b7e0e43224891af7192 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Proxy/ModuleSession_ProxyRule.cpp @@ -0,0 +1,231 @@ +#include "pch.h" +#include "ModuleSession_ProxyRule.h" +/******************************************************************** +// Created: 2025/05/15 11:35:12 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleSession\ModuleSession_Proxy\ModuleSession_ProxyRule.cpp +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleSession\ModuleSession_Proxy +// File Base: ModuleSession_ProxyRule +// File Ext: cpp +// Project: XEngine +// Author: qyt +// Purpose: 负载转发规则处理 +// History: +*********************************************************************/ +CModuleSession_ProxyRule::CModuleSession_ProxyRule() +{ + +} +CModuleSession_ProxyRule::~CModuleSession_ProxyRule() +{ + +} +////////////////////////////////////////////////////////////////////////// +// 公用函数 +////////////////////////////////////////////////////////////////////////// +/******************************************************************** +函数名称:ModuleSession_ProxyRule_Insert +函数功能:插入一个后台服务 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要插入的后台服务 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_ProxyRule::ModuleSession_ProxyRule_Insert(LPCXSTR lpszIPAddr) +{ + Session_IsErrorOccur = false; + + if (NULL == lpszIPAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_PARAMENT; + return false; + } + std::list stl_ListRule; + + st_Locker.lock(); + stl_MapProxyRule.insert(make_pair(lpszIPAddr, stl_ListRule)); + st_Locker.unlock(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_ProxyRule_Delete +函数功能:删除一个后台服务地址 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的后台服务地址 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_ProxyRule::ModuleSession_ProxyRule_Delete(LPCXSTR lpszIPAddr) +{ + Session_IsErrorOccur = false; + + if (NULL == lpszIPAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_PARAMENT; + return false; + } + st_Locker.lock(); + auto stl_MapIterator = stl_MapProxyRule.find(lpszIPAddr); + if (stl_MapIterator != stl_MapProxyRule.end()) + { + stl_MapProxyRule.erase(stl_MapIterator); + } + st_Locker.unlock(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_ProxyRule_Set +函数功能:设置后台服务信息 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的地址 + 参数.二:lpszUseAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入使用的客户端地址 + 参数.三:bAdd + In/Out:In + 类型:逻辑型 + 可空:Y + 意思:添加还是删除 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_ProxyRule::ModuleSession_ProxyRule_Set(LPCXSTR lpszIPAddr, LPCXSTR lpszUseAddr, bool bAdd /* = true */) +{ + Session_IsErrorOccur = false; + + if (NULL == lpszIPAddr) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_PARAMENT; + return false; + } + st_Locker.lock(); + auto stl_MapIterator = stl_MapProxyRule.find(lpszIPAddr); + if (stl_MapIterator == stl_MapProxyRule.end()) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_NOTFOUND; + st_Locker.unlock(); + return false; + } + //增加还是删除 + if (bAdd) + { + SESSION_PROXYRULE st_ProxyRule = {}; + _tcsxcpy(st_ProxyRule.tszIPAddr, lpszUseAddr); + stl_MapIterator->second.push_back(st_ProxyRule); + } + else + { + for (auto stl_ListIterator = stl_MapIterator->second.begin(); stl_ListIterator != stl_MapIterator->second.end(); stl_ListIterator++) + { + if (0 == _tcsxnicmp(lpszUseAddr, stl_ListIterator->tszIPAddr, _tcsxlen(lpszUseAddr))) + { + stl_MapIterator->second.erase(stl_ListIterator); + break; + } + } + } + st_Locker.unlock(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_ProxyRule_GetCount +函数功能:获取统计信息 + 参数.一:lpszIPAddr + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入要操作的地址 + 参数.二:pInt_Count + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出个数 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_ProxyRule::ModuleSession_ProxyRule_GetCount(LPCXSTR lpszIPAddr, int* pInt_Count) +{ + Session_IsErrorOccur = false; + + if (NULL == pInt_Count) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_PARAMENT; + return false; + } + st_Locker.lock_shared(); + auto stl_MapIterator = stl_MapProxyRule.find(lpszIPAddr); + if (stl_MapIterator == stl_MapProxyRule.end()) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_NOTFOUND; + st_Locker.unlock_shared(); + return false; + } + *pInt_Count = stl_MapIterator->second.size(); + st_Locker.unlock_shared(); + return true; +} +/******************************************************************** +函数名称:ModuleSession_ProxyRule_GetList +函数功能:获取所有列表 + 参数.一:pppSt_IPCount + In/Out:In + 类型:三级指针 + 可空:N + 意思:输出获取到的列表信息 + 参数.二:pInt_Count + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出列表个数 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleSession_ProxyRule::ModuleSession_ProxyRule_GetList(SESSION_IPCONUT*** pppSt_IPCount, int* pInt_Count) +{ + Session_IsErrorOccur = false; + + if (NULL == pppSt_IPCount || NULL == pInt_Count) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_MODULE_SESSION_PROXY_PARAMENT; + return false; + } + st_Locker.lock_shared(); + *pInt_Count = stl_MapProxyRule.size(); + BaseLib_Memory_Malloc((XPPPMEM)pppSt_IPCount, *pInt_Count, sizeof(SESSION_IPCONUT)); + //遍历 + auto stl_MapIterator = stl_MapProxyRule.begin(); + for (int i = 0; stl_MapIterator != stl_MapProxyRule.end(); stl_MapIterator++, i++) + { + (*pppSt_IPCount)[i]->nIPCount = stl_MapIterator->second.size(); + _tcsxcpy((*pppSt_IPCount)[i]->tszIPAddr, stl_MapIterator->first.c_str()); + } + st_Locker.unlock_shared(); + return true; +} \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Proxy/ModuleSession_ProxyRule.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Proxy/ModuleSession_ProxyRule.h new file mode 100644 index 0000000000000000000000000000000000000000..9bb58e06cebfcd7fc438f6eaf513285a5d8fc026 --- /dev/null +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Proxy/ModuleSession_ProxyRule.h @@ -0,0 +1,33 @@ +#pragma once +/******************************************************************** +// Created: 2025/05/15 11:33:09 +// File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleSession\ModuleSession_Proxy\ModuleSession_ProxyRule.h +// File Path: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleSession\ModuleSession_Proxy +// File Base: ModuleSession_ProxyRule +// File Ext: h +// Project: XEngine +// Author: qyt +// Purpose: 负载转发规则处理 +// History: +*********************************************************************/ +typedef struct +{ + XCHAR tszIPAddr[128]; +}SESSION_PROXYRULE; + +class CModuleSession_ProxyRule +{ +public: + CModuleSession_ProxyRule(); + ~CModuleSession_ProxyRule(); +public: + bool ModuleSession_ProxyRule_Insert(LPCXSTR lpszIPAddr); + bool ModuleSession_ProxyRule_Delete(LPCXSTR lpszIPAddr); + bool ModuleSession_ProxyRule_Set(LPCXSTR lpszIPAddr, LPCXSTR lpszUseAddr, bool bAdd = true); + bool ModuleSession_ProxyRule_GetCount(LPCXSTR lpszIPAddr, int* pInt_Count); + bool ModuleSession_ProxyRule_GetList(SESSION_IPCONUT*** pppSt_IPCount, int* pInt_Count); +private: + std::shared_mutex st_Locker; +private: + std::unordered_map > stl_MapProxyRule; +}; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def index 2a603cd9c092a4038528a0efc053ec3c7db40b84..fc28f03971242be1364d3bdc368cf1fec74a484a 100644 --- a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def +++ b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def @@ -31,4 +31,9 @@ EXPORTS ModuleSession_Proxy_GetForAddr ModuleSession_Proxy_GetForToken ModuleSession_Proxy_List - ModuleSession_Proxy_Delete \ No newline at end of file + ModuleSession_Proxy_Delete + ModuleSession_ProxyRule_Insert + ModuleSession_ProxyRule_Delete + ModuleSession_ProxyRule_Set + ModuleSession_ProxyRule_GetCount + ModuleSession_ProxyRule_GetList \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj index c36ef886fd4b4dc2dc40d7bad407e383389b0079..4b048417aa682384932ddf4a9f1f024964d96b23 100644 --- a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj +++ b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj @@ -250,6 +250,7 @@ + @@ -258,6 +259,7 @@ + diff --git a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj.filters b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj.filters index b7e61855227d67728603804d2ef7828367035b80..cd29b03cc04b9a71e99366237127a5ffce7ad195 100644 --- a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj.filters +++ b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.vcxproj.filters @@ -63,6 +63,9 @@ 头文件\ModuleSession_Proxy + + 头文件\ModuleSession_Proxy + @@ -83,6 +86,9 @@ 源文件\ModuleSession_Proxy + + 源文件\ModuleSession_Proxy + diff --git a/XEngine_Source/XEngine_ModuleSession/pch.cpp b/XEngine_Source/XEngine_ModuleSession/pch.cpp index f45db1d520b42d6355760f1fd1b148793f63ff9b..abd7ebb26ffa3f78865c7177c348b8d029b57e55 100644 --- a/XEngine_Source/XEngine_ModuleSession/pch.cpp +++ b/XEngine_Source/XEngine_ModuleSession/pch.cpp @@ -3,6 +3,7 @@ #include "ModuleSession_Socks/ModuleSession_Socks.h" #include "ModuleSession_Tunnel/ModuleSession_Tunnel.h" #include "ModuleSession_Proxy/ModuleSession_Proxy.h" +#include "ModuleSession_Proxy/ModuleSession_ProxyRule.h" /******************************************************************** // Created: 2022/06/08 10:10:52 // File Name: D:\XEngine_ProxyServer\XEngine_Source\XEngine_ModuleSession\pch.cpp @@ -21,6 +22,7 @@ CModuleSession_Forward m_Forward; CModuleSession_Socks m_Socks; CModuleSession_Tunnel m_Tunnel; CModuleSession_Proxy m_Proxy; +CModuleSession_ProxyRule m_ProxyRule; ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// @@ -147,4 +149,24 @@ extern "C" bool ModuleSession_Proxy_List(SESSION_FORWARD*** pppSt_ListUser, int* extern "C" bool ModuleSession_Proxy_Delete(LPCXSTR lpszIPAddr) { return m_Proxy.ModuleSession_Proxy_Delete(lpszIPAddr); +} +extern "C" bool ModuleSession_ProxyRule_Insert(LPCXSTR lpszIPAddr) +{ + return m_ProxyRule.ModuleSession_ProxyRule_Insert(lpszIPAddr); +} +extern "C" bool ModuleSession_ProxyRule_Delete(LPCXSTR lpszIPAddr) +{ + return m_ProxyRule.ModuleSession_ProxyRule_Delete(lpszIPAddr); +} +extern "C" bool ModuleSession_ProxyRule_Set(LPCXSTR lpszIPAddr, LPCXSTR lpszUseAddr, bool bAdd) +{ + return m_ProxyRule.ModuleSession_ProxyRule_Set(lpszIPAddr, lpszUseAddr, bAdd); +} +extern "C" bool ModuleSession_ProxyRule_GetCount(LPCXSTR lpszIPAddr, int* pInt_Count) +{ + return m_ProxyRule.ModuleSession_ProxyRule_GetCount(lpszIPAddr, pInt_Count); +} +extern "C" bool ModuleSession_ProxyRule_GetList(SESSION_IPCONUT*** pppSt_IPCount, int* pInt_Count) +{ + return m_ProxyRule.ModuleSession_ProxyRule_GetList(pppSt_IPCount, pInt_Count); } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/Makefile b/XEngine_Source/XEngine_ServiceApp/Makefile index 65f63e508f637896c4c549938ff8255f9cb3d942..371417e73b0dc97f5f1afcedbccdf9948110b3f8 100644 --- a/XEngine_Source/XEngine_ServiceApp/Makefile +++ b/XEngine_Source/XEngine_ServiceApp/Makefile @@ -1,51 +1,44 @@ CC = g++ -Wall -std=c++20 -PLATFORM = linux PLATVER = -PLATDIR = -RELEASE = 0 -UNICODE = 0 LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp -LOADSO = -L ../XEngine_ModuleConfigure -L ../XEngine_ModuleSession -L ../XEngine_ModuleProtocol \ +LOADSO = -L ../XEngine_ModuleConfigure -L ../XEngine_ModuleSession -L ../XEngine_ModuleProtocol -L ../XEngine_ModuleHelp \ -L ../XEngine_Depend/XEngine_Module/jsoncpp -L ../XEngine_Depend/XEngine_Module/XEngine_InfoReport LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_Cryption -lXEngine_ManagePool -lXClient_Socket -lXClient_APIHelp -lHelpComponents_XLog -lHelpComponents_Packets -lRfcComponents_ProxyProtocol -lNetHelp_APIHelp -lNetHelp_APIAddr -lNetHelp_XSocket \ - -lXEngine_ModuleConfigure -lXEngine_ModuleSession -lXEngine_ModuleProtocol \ + -lXEngine_ModuleConfigure -lXEngine_ModuleSession -lXEngine_ModuleProtocol -lXEngine_ModuleHelp \ -ljsoncpp -lXEngine_InfoReport LIBEX = OBJECTS = XEngine_Configure.o XEngine_Network.o XEngine_SocksTask.o XEngine_TunnelTask.o XEngine_ForwardTask.o XEngine_ProxyTask.o XEngine_ServiceApp.o ifeq ($(RELEASE),1) -FLAGS = -c -DEBUG = +FLAGS = -c -D _RELEASE +DEBUG = -O2 else ifeq ($(PLATFORM),mac) FLAGS = -c - DEBUG = -g + DEBUG = -g -D _DEBUG else FLAGS = -c -lc_p - DEBUG = -g -pg + DEBUG = -g -pg -D _DEBUG endif endif ifeq ($(UNICODE),1) -UNICODE = -D _UNICODE +override UNICODE := -D __UNICODE__ else -UNICODE = +override UNICODE := -D __ANSI__ endif ifeq ($(PLATFORM),linux) ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) PLATVER = -D __CENTOS__ - PLATDIR = XEngine_Linux/Centos else PLATVER = -D __UBUNTU__ - PLATDIR = XEngine_Linux/Ubuntu endif LIBEX = -lpthread -lrt -ldl LOADBIN = -Wl,-rpath=./,--disable-new-dtags else ifeq ($(PLATFORM),mac) CC += -Wno-deprecated-declarations PLATVER = -D __MACOS__ - PLATDIR = XEngine_Mac LIBEX = -lpthread -ldl LOADBIN = -Wl,-rpath,@loader_path/./ endif diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h b/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h index ccf54c50563dccda44a427abc6205c70afeb374a..62e8a5b4ad5464bbf1107c02f8fa87b65ad826f8 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef _MSC_BUILD #include #include @@ -58,6 +59,8 @@ using namespace std; #include "../XEngine_ModuleSession/ModuleSession_Error.h" #include "../XEngine_ModuleProtocol/ModuleProtocol_Define.h" #include "../XEngine_ModuleProtocol/ModuleProtocol_Error.h" +#include "../XEngine_ModuleHelp/ModuleHelp_Define.h" +#include "../XEngine_ModuleHelp/ModuleHelp_Error.h" //加载自己的头文件 #include "XEngine_Configure.h" #include "XEngine_Network.h" @@ -138,16 +141,19 @@ typedef struct #pragma comment(lib,"../x64/Debug/XEngine_ModuleConfigure.lib") #pragma comment(lib,"../x64/Debug/XEngine_ModuleSession.lib") #pragma comment(lib,"../x64/Debug/XEngine_ModuleProtocol.lib") +#pragma comment(lib,"../x64/Debug/XEngine_ModuleHelp.lib") #elif _M_ARM64 #pragma comment(lib,"../ARM64/Debug/XEngine_InfoReport.lib") #pragma comment(lib,"../ARM64/Debug/XEngine_ModuleConfigure.lib") #pragma comment(lib,"../ARM64/Debug/XEngine_ModuleSession.lib") #pragma comment(lib,"../ARM64/Debug/XEngine_ModuleProtocol.lib") +#pragma comment(lib,"../ARM64/Debug/XEngine_ModuleHelp.lib") #elif _M_IX86 #pragma comment(lib,"../Debug/XEngine_InfoReport.lib") #pragma comment(lib,"../Debug/XEngine_ModuleConfigure.lib") #pragma comment(lib,"../Debug/XEngine_ModuleSession.lib") #pragma comment(lib,"../Debug/XEngine_ModuleProtocol.lib") +#pragma comment(lib,"../Debug/XEngine_ModuleHelp.lib") #endif #else #ifdef _M_X64 @@ -155,16 +161,19 @@ typedef struct #pragma comment(lib,"../x64/Release/XEngine_ModuleConfigure.lib") #pragma comment(lib,"../x64/Release/XEngine_ModuleSession.lib") #pragma comment(lib,"../x64/Release/XEngine_ModuleProtocol.lib") +#pragma comment(lib,"../x64/Release/XEngine_ModuleHelp.lib") #elif _M_ARM64 #pragma comment(lib,"../ARM64/Release/XEngine_InfoReport.lib") #pragma comment(lib,"../ARM64/Release/XEngine_ModuleConfigure.lib") #pragma comment(lib,"../ARM64/Release/XEngine_ModuleSession.lib") #pragma comment(lib,"../ARM64/Release/XEngine_ModuleProtocol.lib") +#pragma comment(lib,"../ARM64/Release/XEngine_ModuleHelp.lib") #elif _M_IX86 #pragma comment(lib,"../Release/XEngine_InfoReport.lib") #pragma comment(lib,"../Release/XEngine_ModuleConfigure.lib") #pragma comment(lib,"../Release/XEngine_ModuleSession.lib") #pragma comment(lib,"../Release/XEngine_ModuleProtocol.lib") +#pragma comment(lib,"../Release/XEngine_ModuleHelp.lib") #endif #endif #endif \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp index 3b410458a27ab0fa47cccbff4519474cf36a917a..47c41d6ad173440ddf251c2125f9f6ec2694b4ec 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp @@ -250,6 +250,7 @@ void XEngine_Network_Close(LPCXSTR lpszClientAddr, int nIPProto, int nCloseType) XClient_TCPSelect_DeleteEx(xhProxyClient, st_ProxyInfo.xhClient); } ModuleSession_Proxy_Delete(lpszClientAddr); + ModuleSession_ProxyRule_Set(lpszClientAddr, st_ProxyInfo.tszDstAddr, false); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Proxy客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); } else diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_ProxyTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_ProxyTask.cpp index a73f2308284907d72643cf21756792f227b60a84..91a3ee8210eb0cd14180b8375434b99ec3878507 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ProxyTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ProxyTask.cpp @@ -14,6 +14,7 @@ bool XEngine_Proxy_Connect(LPCXSTR lpszClientAddr) { int nSrcPort = 0; int nDstPort = 0; + bool bFound = false; XNETHANDLE xhClient = 0; XCHAR tszIPAddr[128] = {}; XCHAR tszSrcIPAddr[128] = {}; @@ -21,15 +22,14 @@ bool XEngine_Proxy_Connect(LPCXSTR lpszClientAddr) _tcsxcpy(tszSrcIPAddr, lpszClientAddr); APIAddr_IPAddr_SegAddr(tszSrcIPAddr, &nSrcPort); - - bool bFound = false; - auto stl_ListIterator = st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->begin(); - for (; stl_ListIterator != st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->end(); stl_ListIterator++) + //是否有单独的转发规则 + if (!st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->empty()) { - XCHAR tszTmpIPAddr[128] = {}; - _stxscanf(stl_ListIterator->c_str(), _X("%[^-]-%s"), tszTmpIPAddr, tszDstIPAddr); - if (APIAddr_IPAddr_IsIPV4Addr(tszTmpIPAddr)) + //有规则,需要进行匹配 + for (auto stl_ListIterator = st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->begin(); stl_ListIterator != st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->end(); stl_ListIterator++) { + XCHAR tszTmpIPAddr[128] = {}; + _stxscanf(stl_ListIterator->c_str(), _X("%[^-]-%s"), tszTmpIPAddr, tszDstIPAddr); //ip if (0 == _tcsxnicmp(tszSrcIPAddr, tszTmpIPAddr, _tcsxlen(tszSrcIPAddr))) { @@ -39,24 +39,45 @@ bool XEngine_Proxy_Connect(LPCXSTR lpszClientAddr) break; } } - else - { - //port - if (_ttxoi(tszTmpIPAddr) == nSrcPort) - { - bFound = true; - _tcsxcpy(tszIPAddr, tszDstIPAddr); - APIAddr_IPAddr_SegAddr(tszDstIPAddr, &nDstPort); - break; - } - } } - + //未命中 if (!bFound) { - _tcsxcpy(tszDstIPAddr, st_ServiceConfig.st_XProxy.tszDefaultAddr); - APIAddr_IPAddr_SegAddr(tszDstIPAddr, &nDstPort); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Proxy客户端:%s,代理转未命中,使用默认地址:%s:%d"), lpszClientAddr, tszDstIPAddr, nDstPort); + //没有匹配到 + if (0 == st_ServiceConfig.st_XProxy.nRuleMode) + { + int nIPCount = 0; + SESSION_IPCONUT** ppSt_IPCount; + ModuleSession_ProxyRule_GetList(&ppSt_IPCount, &nIPCount); + //排序 + ModuleHelp_APIHelp_QSort(ppSt_IPCount, nIPCount, sizeof(SESSION_IPCONUT*)); + _tcsxcpy(tszIPAddr, ppSt_IPCount[0]->tszIPAddr); + _tcsxcpy(tszDstIPAddr, ppSt_IPCount[0]->tszIPAddr); + APIAddr_IPAddr_SegAddr(tszDstIPAddr, &nDstPort); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Proxy客户端:%s,代理转发规则地址未命中,使用最小原则规则地址:%s:%d"), lpszClientAddr, tszDstIPAddr, nDstPort); + } + else if (1 == st_ServiceConfig.st_XProxy.nRuleMode) + { + size_t nHashValue = std::hash{}(tszSrcIPAddr); + size_t nIndex = nHashValue % st_ServiceConfig.st_XProxy.pStl_ListDestAddr->size(); + auto stl_ListIterator = st_ServiceConfig.st_XProxy.pStl_ListDestAddr->begin(); + std::advance(stl_ListIterator, nIndex); + _tcsxcpy(tszIPAddr, stl_ListIterator->c_str()); + _tcsxcpy(tszDstIPAddr, stl_ListIterator->c_str()); + APIAddr_IPAddr_SegAddr(tszDstIPAddr, &nDstPort); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Proxy客户端:%s,代理转发规则地址未命中,使用HASH规则,规则地址:%s:%d"), lpszClientAddr, tszDstIPAddr, nDstPort); + } + else if (2 == st_ServiceConfig.st_XProxy.nRuleMode) + { + XNETHANDLE xhIndex = 0; + BaseLib_Handle_Create(&xhIndex, 0, st_ServiceConfig.st_XProxy.pStl_ListDestAddr->size()); + auto stl_ListIterator = st_ServiceConfig.st_XProxy.pStl_ListDestAddr->begin(); + std::advance(stl_ListIterator, xhIndex); + _tcsxcpy(tszIPAddr, stl_ListIterator->c_str()); + _tcsxcpy(tszDstIPAddr, stl_ListIterator->c_str()); + APIAddr_IPAddr_SegAddr(tszDstIPAddr, &nDstPort); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Proxy客户端:%s,代理转发规则地址未命中,使用随机规则,规则地址:%s:%d"), lpszClientAddr, tszDstIPAddr, nDstPort); + } } if (!XClient_TCPSelect_InsertEx(xhProxyClient, &xhClient, tszDstIPAddr, nDstPort, false)) { @@ -65,6 +86,7 @@ bool XEngine_Proxy_Connect(LPCXSTR lpszClientAddr) } SocketOpt_HeartBeat_InsertAddrEx(xhProxyHeart, lpszClientAddr); ModuleSession_Proxy_Insert(lpszClientAddr, tszIPAddr, xhClient); + ModuleSession_ProxyRule_Set(tszIPAddr, lpszClientAddr); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Proxy客户端:%s,连接到服务器:%s:%d 成功"), lpszClientAddr, tszDstIPAddr, nDstPort); return true; } diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp index 785b7837409ace2d93e4882d6c04e4f9dd0d7102..f3a3573ba53432fef8e6a5c90de4f65a5979ac2f 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp @@ -334,7 +334,7 @@ int main(int argc, char** argv) XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动Proxy网络服务器失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Proxy网络服务器成功,Proxy端口:%d,默认地址:%s 配置个数:%d,IO:%d"), st_ServiceConfig.nProxyPort, st_ServiceConfig.st_XProxy.tszDefaultAddr, st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->size(), st_ServiceConfig.st_XMax.nIOThread); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Proxy网络服务器成功,Proxy端口:%d,转发目标个数:%d 规则个数:%d,IO:%d"), st_ServiceConfig.nProxyPort, st_ServiceConfig.st_XProxy.pStl_ListDestAddr->size(), st_ServiceConfig.st_XProxy.pStl_ListRuleAddr->size(), st_ServiceConfig.st_XMax.nIOThread); NetCore_TCPXCore_RegisterCallBackEx(xhProxySocket, Network_Callback_ProxyLogin, Network_Callback_ProxyRecv, Network_Callback_ProxyLeave); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册Proxy网络事件成功")); //客户端 @@ -345,11 +345,18 @@ int main(int argc, char** argv) goto XENGINE_SERVICEAPP_EXIT; } XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Proxy客户端服务成功")); + + for (auto stl_ListIterator = st_ServiceConfig.st_XProxy.pStl_ListDestAddr->begin(); stl_ListIterator != st_ServiceConfig.st_XProxy.pStl_ListDestAddr->end(); stl_ListIterator++) + { + ModuleSession_ProxyRule_Insert(stl_ListIterator->c_str()); + } + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化负载均衡后台服务端成功,个数:%d"), st_ServiceConfig.st_XProxy.pStl_ListDestAddr->size()); } else { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Proxy服务没有被启用")); } +#ifndef _DEBUG //发送信息报告 if (st_ServiceConfig.st_XReport.bEnable && !bIsTest) { @@ -367,7 +374,7 @@ int main(int argc, char** argv) { XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,信息报告给API服务器没有启用")); } - +#endif XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("所有服务成功启动,服务运行中,XEngine版本:%s%s,服务版本:%s,发行次数:%d。。。"), BaseLib_Version_XNumberStr(), BaseLib_Version_XTypeStr(), st_ServiceConfig.st_XVer.pStl_ListVer->front().c_str(), st_ServiceConfig.st_XVer.pStl_ListVer->size()); while (true) diff --git a/XEngine_Source/XEngine_UserProtocol.h b/XEngine_Source/XEngine_UserProtocol.h index 2ba6a0b5332e8f26cbc92b8d2a43e67b4e59e7b9..cbd41875382e6fb1b079d8f92afc8d51e3d6323c 100644 --- a/XEngine_Source/XEngine_UserProtocol.h +++ b/XEngine_Source/XEngine_UserProtocol.h @@ -27,7 +27,7 @@ typedef enum en_XEngine_XUser_Protocol #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_ANONYREQ 0xE1006 //匿名转发 #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_ANONYREP 0xE1007 /////////////////////////////////////////////////////////////////////////// -// 导出的数据结构 +// 导出的错误信息 /////////////////////////////////////////////////////////////////////////// #define ERROR_XENGINE_PROXY_PROTOCOL_FORMAT 0x01 //协议格式内容错误 #define ERROR_XENGINE_PROXY_PROTOCOL_SERVER 0x02 //服务器内部处理错误