Ð޸´ȫÏîĿÉó²éÎÊÌⲢ·¢²¼ v1.1.9

¸ÄÓñ¾»ú¶ÀÁ¢ CA£¬»ָ´ CLI TLS УÑ飬±£»¤ƾ¾ÝÓëÅäÖò¢·¢±£´档
Ð޸´ Cursor Êý¾ݡ¢»Ự·¾¶¡¢´úÀíÉúÃüÖÜÆڡ¢ģÐÍÇëÇóÓë Skills Îļþ²Ù×÷¡£
Ϊ¶ÀÁ¢ Tab ·þÎñÔö¼ӿͻ§¶˼øȨ£¬Éý¼¶ÒÀÀµÓ빤¾ßÁ´£¬ÍêÉƷ¢²¼ԪÐÅϢͬ²½¡£

Ñé֤£ºÁ½¸ö Go ģ¿éµIJâÊÔ/vet¡¢¹ؼüģ¿é race¡¢ǰ¶˲âÊÔ/Éú²ú¹¹½¨/Éó¼ơ¢
Go ¿ɴï©¶´ɨÃèÓë macOS/Linux ¿ÉÐÐģ¿齻²æ±àÒë¾ùͨ¹ý¡£
Windows ¸ôÀëÆô¶¯ͨ¹ý£»δÍê³ɵĵã»÷ðÑ̺ÍԭÉúƽ̨Ñé֤¼ûÉó²鱨¸档
This commit is contained in:
FuDie0915
2026-11-10 09:59:34 +08:00
parent db73cf5a39
commit 188225fae6
98 changed files with 3324 additions and 930 deletions

View File

@@ -18,6 +18,7 @@ import (
"time"
"cursor/internal/certs"
"cursor/internal/localaccess"
"cursor/internal/logger"
"cursor/internal/netproxy"
@@ -31,6 +32,7 @@ const (
// ProxyServer 定义了当前模块中的 ProxyServer 类型。
type ProxyServer struct {
lifecycleMu sync.Mutex
// addr 表示当前声明中的 addr。
addr string
// baseURL 表示当前声明中的 baseURL。
@@ -264,6 +266,8 @@ func (s *ProxyServer) ListenAndServe() error {
// Start 用于处理与 Start 相关的逻辑。
func (s *ProxyServer) Start() error {
s.lifecycleMu.Lock()
defer s.lifecycleMu.Unlock()
s.runMu.Lock()
defer s.runMu.Unlock()
if s.httpServer != nil {
@@ -308,15 +312,24 @@ func (s *ProxyServer) Start() error {
// Stop 用于处理与 Stop 相关的逻辑。
func (s *ProxyServer) Stop(ctx context.Context) error {
s.runMu.Lock()
httpServer := s.httpServer
if httpServer == nil {
s.runMu.Unlock()
s.lifecycleMu.Lock()
defer s.lifecycleMu.Unlock()
s.runMu.RLock()
server := s.httpServer
s.runMu.RUnlock()
if server == nil {
return nil
}
s.httpServer = nil
err := server.Shutdown(ctx)
if err != nil {
_ = server.Close()
}
s.runMu.Lock()
if s.httpServer == server {
s.httpServer = nil
}
s.runMu.Unlock()
return httpServer.Shutdown(ctx)
return err
}
// IsRunning 用于处理与 IsRunning 相关的逻辑。
@@ -706,6 +719,9 @@ func shouldHandleLocalCORSPreflight(req *http.Request) bool {
// buildLocalCORSPreflightResponse 用于处理与 buildLocalCORSPreflightResponse 相关的逻辑。
func buildLocalCORSPreflightResponse(req *http.Request) *http.Response {
if req != nil && !localaccess.AllowedOrigin(req.Header.Get("Origin")) {
return &http.Response{StatusCode: http.StatusForbidden, Status: "403 Forbidden", Header: make(http.Header), Body: io.NopCloser(strings.NewReader("untrusted browser origin")), Request: req}
}
allowOrigin := "*"
if req != nil {
origin := strings.TrimSpace(req.Header.Get("Origin"))