Go to file
luyoyu 9cc98d6114
update README.md.
Signed-off-by: luyoyu <8829470+chuangxxt@user.noreply.gitee.com>
2023-09-12 06:34:47 +00:00
readme readme图片 2023-09-12 06:29:58 +00:00
source 优化 2023-09-11 12:24:04 +08:00
config.json 0.21 2023-09-10 16:06:52 +08:00
install.sh 2023.9.9 2023-09-09 10:35:39 +08:00
LICENSE add LICENSE. 2023-09-10 12:04:34 +00:00
README.md update README.md. 2023-09-12 06:34:47 +00:00
share-copilot 修复多个token请求混乱问题 2023-09-11 01:31:07 +08:00
uninstall.sh 2023.9.9 2023-09-09 10:35:39 +08:00

测试版以支持全部接口代理, 所有也就是代码提示也走代理。😛

输入图片说明


share-copilot

  • 作为代理服务器中转copilot插件的API的请求
  • 支持vscode插件和jetbrains插件
  • 支持多用户共享一个token
  • 优化请求逻辑降低token被ban概率别万人骑基本不可能封 软件系统网络架构.png

一、自行编译:

测试环境:Linux4.18.0-305.3.1.el8.x86_64 GNU/Linux
需要 go环境 出问题自行chatgpt
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
#添加下列环境
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

#使生效环境变量
source ~/.bashrc
#验证安装
go version 
#cd到main.go源码目录
cd /share-copilot/source
go build

二、使用现成:

1.安装

git clone https://gitlab.com/luyoyu/share-copilot.git
cd share-copilot
bash install.sh

2.配置

2.1 config.json文件说明
domain//监听域名或ip   可用nginx反代

host //ip

port //端口 80或443

certPath//公钥路径-443必须

keyPath//私钥路径-443必须

github_api_url//默认不改

token//自己的副驾驶token,可放多个,请求时随机使用
//登录插件后在%userprofile%\AppData\Local\github-copilot\host.json     ghu_开头

verification//自定义验证
2.2 示例
{
	"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":""
}

格式不能错,不确定的去这里验证 ->https://www.json.cn/

3.启动

scop r  --运行 [Esc退出]
scop rb --后台运行
scop st --停止
scop v  --查看状态

4.完整例子:

4.1 服务端配置修改config.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.2 运行成功截图:

微信截图_20230910202900.png

正常情况下GithubApi request小于User Request因为请求的Token 几十分钟才过期


4.3本地配置修改:

以windows为例

  • jetbrains插件修改%userprofile%\AppData\Local\github-copilot\host.json
{
    "github.com":{
        "user":"suibian",//随意填写
        "oauth_token":"i_am_free",//与上面verification对应
        "dev_override":{
            "copilot_token_url":"https://api.example.com/copilot_internal/v2/token"  
            					//你的地址
        }
    }
}
  • vscode插件修改%userprofile%\.vscode\extensions\github.copilot-xxxx\dist\extension.js
//添加下列代码注意vscode插件更新需要重新添加jetbrains则不用
process.env.GITHUB_TOKEN="i_am_free"; //与上面verification对应
process.env.GITHUB_API_URL="https://api.example.com"; //你的地址
process.env.CODESPACES="true";
process.env.GITHUB_SERVER_URL="https://github.com";

4.4测试成功:

demo2.png