From 6f59bab64afc508ddfdcd791ccb141b1b440154a Mon Sep 17 00:00:00 2001 From: ben Gutier Date: Wed, 13 Sep 2023 16:25:36 +0800 Subject: [PATCH] mod readme --- README-EN.md | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 11 +++- 2 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 README-EN.md diff --git a/README-EN.md b/README-EN.md new file mode 100644 index 0000000..44ec8d5 --- /dev/null +++ b/README-EN.md @@ -0,0 +1,165 @@ +The beta version now supports full interface proxy, S + +o even code suggestions go through the proxy, + +Still in testing. + +![输入图片说明](readme/screenshots.gif) +*** +# share-copilot + +- Acts as a proxy server, forwarding requests to the Copilot plugin's API +- Supports both vscode and Jetbrains plugins +- Supports multiple users sharing a single token +- Optimizes request logic +![软件系统网络架构.png](https://img1.imgtp.com/2023/09/10/qTL8A2u9.png) + +*** +# 一、Build It Yourself: +```sh +Test Environment: Linux4.18.0-305.3.1.el8.x86_64 GNU/Linux +Requires Go environment; +resolve any issues chatgpt. +``` +```sh +wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz +tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz + +vim ~/.bashrc +# Add the following environment variables +export PATH=$PATH:/usr/local/go/bin +export GOPATH=$HOME/go +export PATH=$PATH:$GOPATH/bin + +# Make the environment variables effective +source ~/.bashrc +# Verify the installation +go version +# CD to the source directory of main.go +cd /share-copilot/source +go build +``` +*** +# 二、Use the Ready-Made Version: + +### 1.Installation + +```sh +git clone https://gitlab.com/luyoyu/share-copilot.git +``` +```sh +cd share-copilot +``` +```sh +bash install.sh +``` + +### 2.Configuration + +##### 2.1 Explanation of config.json + +```js +domain // Listening domain or IP (can be reverse proxied with nginx) +host // IP +port // Port 80 or 443 +certPath // Public key path - required for 443 +keyPath // Private key path - required for 443 +github_api_url // Default, usually not changed +token // Your Copilot token(s), you can put multiple, they will be used randomly in requests +// After logging into the Copilot plugin, find them in %userprofile%\AppData\Local\github-copilot\host.json (starting with "ghu_") +verification // Custom verification + +``` + +##### 2.2 Example + +```json +{ + "server": { + "domain": "example.com", + "host": "0.0.0.0", + "port": 443, + "certPath":"./example.pem", + "keyPath":"./example.pem" + }, + "copilot_config":{ + "github_api_url": "https://api.github.com/copilot_internal/v2/token", + "token":[ + "yours_token_1", + "yours_token_2", + "yours_token_3" + ]}, + "verification":"" +} + +``` +The format must be correct; + +### 3.启动 + +```sh +scop r # Run [Press Esc to exit] +scop rb # Run in the background +scop st # Stop +scop v # View status +``` + +### 4.Complete Example: + +##### 4.1 Server-side Configuration (Modify config.json) + +```json +{ + "server": { + "domain": "api.example.com", + "host": "0.0.0.0", + "port": 443, + "certPath":"./example.pem", + "keyPath":"./example.pem" + }, + "copilot_config":{ + "github_api_url": "https://api.github.com/copilot_internal/v2/token", + "token":[ + "ghu_xMNAYLcJAPqAfiGoobrWffkJoNcGMVJtETKA", + "ghu_GZgKFwraHorAxXXUvsUclOhxiYERPsSJeNuF", + "ghu_SPUTCLvkMKoeMstPJmhSlYsYvCojhkFjGubl" + ]}, + "verification":"i_am_free" +} +``` + +------ + +##### 4.3Local Configuration Changes: + +**Using Windows as an example** + +- **For Jetbrains Plugin: Modify %userprofile%\AppData\Local\github-copilot\host.json** + +```json +{ + "github.com":{ + "user":"suibian",//Fill in as desired + "oauth_token":"i_am_free",// Corresponds to the "verification" value above + "dev_override":{ + "copilot_token_url":"https://api.example.com/copilot_internal/v2/token" + // Your address + } + } +} +``` +- **For Vscode Plugin: Modify %userprofile%\.vscode\extensions\github.copilot-xxxx\dist\extension.js** + +```js +//Add the following code, note that you'll need to re-add it if the vscode plugin gets updated; Jetbrains does not require this step +process.env.GITHUB_TOKEN="i_am_free"; // Corresponds to the "verification" value above +process.env.GITHUB_API_URL="https://api.example.com"; // Your address +process.env.CODESPACES="true"; +process.env.GITHUB_SERVER_URL="https://github.com"; +``` + +------ + +##### **Successful Testing:** + +![demo2.png](https://img1.imgtp.com/2023/09/09/FHDNLixL.png) diff --git a/README.md b/README.md index c018b1d..18265d0 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ +[中文](README.md) [English](README-EN.md) + +------ + 测试版已经支持全部接口代理, -所有也就是代码提示也走代理。:stuck_out_tongue: +所有也就是代码提示也走代理, +还在测试中。 ![输入图片说明](readme/screenshots.gif) *** -# share-copilot +# share-copilot - 作为代理服务器,中转copilot插件的API的请求 - 支持vscode插件和jetbrains插件 - 支持多用户共享一个token -- 优化请求逻辑,降低token被ban概率(别万人骑基本不可能封) +- 优化请求逻辑,suspended概率(别万人骑基本不会) ![软件系统网络架构.png](https://img1.imgtp.com/2023/09/10/qTL8A2u9.png) ***