mirror of
https://gitee.com/chuangxxt/share-copilot
synced 2025-04-16 10:13:26 +00:00
fix some bug
This commit is contained in:
parent
390aa9429b
commit
15e82057af
@ -51,9 +51,11 @@ set "GITHUB_SERVER_URL=https://github.com"
|
||||
|
||||
##### 2.测试
|
||||
|
||||
如图,代码提示已经走代理服务器了,这样就全是走一个ip了,虽然不知道有没有意义
|
||||
代码提示已经走代理服务器了,这样就全是走一个ip了,虽然不知道有没有意义
|
||||
|
||||
如果你是贩子,甚至可以搞点小动作
|
||||
|
||||
|
||||
如果你是贩子,甚至可以搞点有意思的东西
|
||||
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ type Config struct {
|
||||
Token []string `json:"token"`
|
||||
} `json:"copilot_config"`
|
||||
Verification string `json:"verification"`
|
||||
DiyMsg string `json:"diyMsg"`
|
||||
IsModMsg bool `json:"isModMsg"`
|
||||
}
|
||||
|
||||
// 全局变量
|
||||
@ -38,12 +40,7 @@ var (
|
||||
requestCount = 0
|
||||
//请求成功计数
|
||||
successCount = 0
|
||||
)
|
||||
|
||||
// 测试的玩意儿
|
||||
var (
|
||||
diyMsg = ";//授权已经过期,重新获取-> https://www.sharecopilot.top"
|
||||
completionUrl = "https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex/completions"
|
||||
telemetryUrl = "https://copilot-telemetry.githubusercontent.com/telemetry"
|
||||
isModMsg = false //是否修改代码提示返回的信息
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ func VerifyRequestMiddleware() gin.HandlerFunc {
|
||||
if configFile.Verification != "" {
|
||||
authHeader := c.GetHeader("Authorization")
|
||||
if authHeader != "token "+configFile.Verification {
|
||||
c.JSON(401, gin.H{"error": "Unauthorized"})
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ func registerProxyRoute(r *gin.Engine, routePath, targetURL string) {
|
||||
proxy := &httputil.ReverseProxy{
|
||||
Director: func(req *http.Request) {
|
||||
req.URL.Host = target.Host
|
||||
req.URL.Scheme = "https"
|
||||
req.URL.Scheme = "http"
|
||||
req.Host = target.Host
|
||||
},
|
||||
ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) {
|
||||
@ -103,10 +103,12 @@ func registerProxyRoute(r *gin.Engine, routePath, targetURL string) {
|
||||
req.URL.Scheme = "https"
|
||||
req.Host = target.Host
|
||||
}
|
||||
if isModMsg {
|
||||
if configFile.IsModMsg {
|
||||
modProxyResp(c, proxy)
|
||||
}
|
||||
proxy.ServeHTTP(c.Writer, c.Request)
|
||||
|
||||
c.Writer.Header().Set("X-Forwarded-Proto", "http")
|
||||
})
|
||||
}
|
||||
|
||||
@ -133,7 +135,7 @@ func modProxyResp(c *gin.Context, proxy *httputil.ReverseProxy) {
|
||||
fmt.Println("No match found.")
|
||||
}
|
||||
// 将字符串转换为[]rune类型的字符数组
|
||||
runes := []rune(diyMsg)
|
||||
runes := []rune(configFile.DiyMsg)
|
||||
newStr := ""
|
||||
// 遍历字符数组,对每个字符进行处理
|
||||
for _, r := range runes {
|
||||
|
Loading…
Reference in New Issue
Block a user