btcloud Documentation

repository·main·Indexed 24 days ago

https://github.com/flucont/btcloud

A PHP-based third-party cloud site for Baota (BT) Panel that enables private deployment to ensure privacy, security, and compliance by removing account binding and ads. It includes tools for batch replacing URLs, managing plugin lists, and automating updates. The system provides CLI commands for cleaning ViteJS assets, decrypting BT Panel Python files, and bulk updating plugins across Linux and Windows environments.

Tokens
8.1K
Snippets
14
Records
50
Agent score
84%

What's inside btcloud

  1. Modify Linux Panel official update packages

    main

    To integrate an official Linux Panel update package with a third-party cloud (btcloud), you must perform a series of file replacements, code modifications, and decryption steps.

    Prerequisites:

    • Obtain the latest version number from: https://www.bt.cn/api/panel/get_version?is_version=1
    • Download the official update package: http://download.bt.cn/install/update/LinuxPanel-<VERSION>.zip
    • Assume your third-party cloud URL is http://www.example.com.

    Core Modification Workflow:

    1. Cleanup: Delete all .so files in the class folder.
    2. Plugin Loading: Copy linux/PluginLoader.py into the class folder.
    3. Decryption: Use the following commands to decrypt module files:
      • php think decrypt classdir <path_to_panel_class_folder>
      • php think decrypt all <path_to_panel_mod_folder>
    4. URL Redirection: Perform global search and replace to redirect official bt.cn API and download URLs to your third-party cloud URL (http://www.example.com).
    5. Code Patching: Modify specific Python files (e.g., class/public.py, class/ajax.py) to bypass official checks and use your cloud configuration.
    6. Re-packaging: Unzip the source package (e.g., panel6.zip), overwrite with your modified files, and re-package.
    php think decrypt classdir <面板class文件夹路径>
    php think decrypt all <面板mod文件夹路径>
  2. Modify the BT Monitor installation package

    main

    To customize the BT Monitor installation package (e.g., for redirection or local hosting), follow these modification steps:

    1. File Replacement: Delete core/include/c_loader/PluginLoader.so and hook_import/PluginLoader.so. Copy btmonitor/PluginLoader.py into those directories.
    2. Decryption: Batch decrypt the source code using the following command: php think decrypt all <source_root_directory> Note: A few file decryption failures are normal and can be ignored.
    3. URL Redirection (Global Search & Replace):
      • Replace https://api.bt.cn with http://www.example.com (Exclude /bt_monitor/latest_agent_version and /bt_monitor/ip_info).
      • Replace https://www.bt.cn/api/ with http://www.example.com/api/.
      • Replace https://download.bt.cn with http://www.example.com in modules/configModule/main.py and init.sh.
    4. Code Injection in core/include/public.py:
      • Under def GetConfigValue(key):, add: if key == 'home': return 'http://www.example.com'
      • Under def write_request_log(reques = None):, add return.
    5. Disable Reporting in core/include/basic_monitor.py:
      • Under def report_module_logs(self, force=False):, add return.
      • Under def report_daily_active(self, force=False):, add return.
    6. Update Installation Script: In update/update_btmonitor.sh, modify the download_Url variable within the Install_Monitor method.
    7. Reduce Package Size: Delete all .map files located in the static/js/ directory.
    php think decrypt all <源码根目录>
  3. Modify aaPanel official update packages for btcloud

    main

    To use aaPanel with a third-party cloud (btcloud), you must modify the official update packages to redirect API calls and downloads to your own server (e.g., http://www.example.com).

    1. Preparation

    • Query latest version: https://brandnew.aapanel.com/api/panel/getLatestOfficialVersion
    • Download official package: http://download.bt.cn/install/update/LinuxPanel_EN-<VERSION>.zip
    • Note: Replace http://www.example.com in the instructions below with your actual btcloud URL.

    2. Core File Modifications

    • Cleanup: Delete all .so files in the class folder.
    • Plugin Loader: Copy aapanel/PluginLoader.py into the class folder.
    • Decryption: Batch decrypt module files using the following command:
      php think decrypt classdir <path_to_panel_class_folder>
      php think decrypt classdir <path_to_panel_class_v2_folder>
    • Global Search & Replace:
      • Replace https://wafapi2.aapanel.com and https://wafapi.aapanel.com with http://www.example.com (exclude task.py, ipsModel.py, and .js files).
      • Replace https://node.aapanel.com/install/update_7.x_en.sh with http://www.example.com/install/update_7.x_en.sh.
      • Replace https://node.aapanel.com/install/update_pro_en.sh with http://www.example.com/install/update_7.x_en.sh.
    • Error Reporting: Search for and delete the code that submits error reports in bt_error/index.php.

    3. Python Logic Redirection

    In several files, you must change public.get_url() to public.OfficialApiBase() to redirect traffic to your cloud:

    • class/ajax.py and class_v2/ajax_v2.py
    • class/jobs.py and class_v2/jobs_v2.py
    • class/system.py and class_v2/system_v2.py

    In class/public/common.py, implement the redirection:

    def OfficialApiBase():
        return 'http://www.example.com'

    4. Shell Script Updates

    In install/install_soft.sh, add these lines before execution to redirect download paths:

    sed -i "s/http:\/\/download.bt.cn\/install\/public.sh/http:\/\/www.example.com\/install\/public.sh/" $name.sh"
    sed -i "s/https:\/\/download.bt.cn\/install\/public.sh/http:\/\/www.example.com\/install\/public.sh/" $name.sh

    5. Final Packaging

    1. Unzip the source package (e.g., panel_7_en.zip).
    2. Overwrite the files with your modified versions.
    3. Crucial: Ensure all .so files are deleted from the class folder.
    4. Re-package the files into a new .zip for installation.
  4. Modify Windows Panel official update package

    main

    To modify the official Windows Panel update package, follow these steps:

    1. Locate the latest version: Query the latest version number using the following API: https://www.bt.cn/api/wpanel/get_version?is_version=1
    2. Download the package: Use the version number to construct the download URL: http://download.bt.cn/win/panel/panel_版本号.zip (replace 版本号 with the actual version number).
    3. Modify binary strings: Open btPanel.exe with a hex editor and perform the following replacements:
      • Replace https://api.bt.cn with http://api.bt.cn/
      • Replace https://www.bt.cn with http://www.bt.cn/
      • Replace api.bt.cn with any other domain.
      • Replace the second instance of www.bt.cn with any other domain.
  5. Use btcloud features and management tools

    main

    Once deployed, use the following tools within the administration panel to manage your cloud site:

    • Batch Replacement Tool (批量替换工具): Execute the command displayed on this page to batch replace http://www.example.com with your current website URL inside BT installation packages, update packages, and script files.
    • System Basic Settings (系统基本设置): Configure the Baota Panel interface settings. You must prepare a Baota Panel installed with the latest official scripts and bound to an account to fetch the latest plugin lists and packages. Follow the interface instructions to install the required specialized plugin.
    • Scheduled Tasks (定时任务设置): Execute the displayed command to fetch the latest plugin list from the official Baota source and perform batch downloads (incremental updates). Alternatively, you can download plugins individually from the plugin list.
    • One-click Installation Scripts: Visit /download on your website to access the one-click installation scripts for using this third-party cloud.
  6. Remove CAPTCHA and advertisements (Optional)

    main

    To remove CAPTCHAs (calculation problems) and advertisements from the Vite-based UI:

    1. For CAPTCHAs: Copy bt.js to BTPanel/static/. In BTPanel/templates/default/software.html, insert the following script tag before window.vite_public_request_token:
      <script src="/static/bt.js"></script>
    2. For UI Cleanup: Execute the following command to clean up Vite JS files: php think cleanvitejs <path_to_panel_BTPanel/static/js>
    ```javascript
    <script src="/static/bt.js"></script>

    php think cleanvitejs <面板BTPanel/static/js路径>

  7. Optional aaPanel customizations for btcloud

    main

    Beyond core redirection, you can perform the following optional cleanups to improve the user experience on your btcloud instance:

    • Remove Captchas: Copy the contents of bt.js to the end of BTPanel/static/vite/oldjs/public_backup.js.
    • Remove Auto-generated Files: In class/panelSite.py and class_v2/panel_site_v2.py, delete the blocks responsible for creating .htaccess, index.html, and 404.html.
    • Disable Unbound Domain Prompts: In class/panelSite.py and class_v2/panel_site_v2.py, change root /www/server/nginx/html to return 400.
    • Default File Overwrite: In BTPanel/static/vite/oldjs/upload-drog.js, add the checked attribute to id="all_operation".
    • Clean Vite UI: To remove feedback requests, ads, and captchas from the new Vite-based pages, run:
      php think cleanvitejs <path_to_panel_BTPanel/static/js>
    • Add Simplified Chinese: Modify BTPanel/languages/settings.json and add zh/server.json and all/zh.json.
  8. Patch class/panelPlugin.py for software status and downloads

    main

    Modify class/panelPlugin.py to handle software updates and status checks:

    1. In __set_pyenv, after temp_file = public.readFile(filename), add:
      temp_file = temp_file.replace('http://download.bt.cn/install/public.sh', 'http://www.example.com/install/public.sh')
      temp_file = temp_file.replace('https://download.bt.cn/install/public.sh', 'http://www.example.com/install/public.sh')
    2. In def check_status(self, softInfo):, add at the end:
      if 'endtime' in softInfo:
                  softInfo['endtime'] = time.time() + 86400 * 3650
    3. Rename plugin_bin.pl to plugin_list.json.
    4. Delete calls to public.total_keyword(get.query), public.run_thread(self.get_cloud_list_status, args=(get,)), and public.run_thread(self.is_verify_unbinding, args=(get,)).
    if 'endtime' in softInfo:
                  softInfo['endtime'] = time.time() + 86400 * 3650
  9. Configure class/public.py for third-party cloud

    main

    To ensure the panel uses your third-party cloud instead of official servers, modify class/public.py with the following logic:

    1. Under def GetConfigValue(key):, add:
      if key == 'home': return 'http://www.example.com'
    2. Under def is_bind():, add return True.
    3. Under def check_domain_cloud(domain):, add return.
    4. Under def err_collect, add return.
    5. Under def get_improvement():, add return False.
    6. Inside free_login_area, replace get_free_ips_area with get_ips_area.
    7. Inside get_free_ip_info, update the IP retrieval to: res = get_ips_area([address]).
    8. Inside login_send_body, change free_login_area(login_ip=server_ip_area) to free_login_area(login_ip=login_ip).
    9. Inside check_area_panel, remove the cloud retrieval attempt and keep only: ip_area_dict = get_ip_location(client_ip).
    def GetConfigValue(key):
      if key == 'home': return 'http://www.example.com'
  10. Update btcloud to the latest version

    main

    To update your existing installation:

    1. Download the latest Release package from GitHub Releases.
    2. Upload and overwrite all files except for the data folder.
    3. In the admin dashboard, navigate to Batch Replacement Tool -> Get Latest Plugin List (批量替换工具 -> 获取最新插件列表).
    4. Update the version numbers in the Software Version Settings (修改软件版本设置).
  11. Deploy the btcloud third-party cloud site

    main

    To deploy your own private Baota (BT) Panel cloud site, follow these steps:

    1. Download: Download the latest Release package from the GitHub Releases page.
    2. Dependencies: If you downloaded the source code instead of a Release package, run composer install --no-dev to install dependencies. Release packages do not require this.
    3. Web Server Configuration:
      • Set the website root directory to public.
      • Configure rewrite rules (pseudo-static) to ThinkPHP.
    4. Installation: Access the website URL in a browser. You will be automatically redirected to the installation page. Follow the on-screen prompts to complete the setup.