feat: Implement CodexAuth proxy pool management with a new frontend configuration page and a dedicated backend service for API, database, and proxy testing.
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"codex-pool/internal/proxyutil"
|
||||
|
||||
"github.com/Noooste/azuretls-client"
|
||||
fhttp "github.com/Noooste/fhttp"
|
||||
"github.com/andybalholm/brotli"
|
||||
http2 "github.com/bogdanfinn/fhttp"
|
||||
tls_client "github.com/bogdanfinn/tls-client"
|
||||
@@ -475,14 +476,29 @@ func (c *TLSClient) PostJSON(urlStr string, body io.Reader) (*http.Response, err
|
||||
|
||||
// GetCookie 获取指定 URL 的 Cookie
|
||||
func (c *TLSClient) GetCookie(urlStr string, name string) string {
|
||||
if c.clientType == ClientTypeAzureTLS {
|
||||
return "" // azuretls cookie 管理待完善,目前主要依赖 tls-client 或手动 handle
|
||||
}
|
||||
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
// azuretls 使用标准的 http.CookieJar
|
||||
if c.clientType == ClientTypeAzureTLS {
|
||||
if c.azureSession == nil || c.azureSession.CookieJar == nil {
|
||||
return ""
|
||||
}
|
||||
cookies := c.azureSession.CookieJar.Cookies(u)
|
||||
for _, cookie := range cookies {
|
||||
if cookie.Name == name {
|
||||
return cookie.Value
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// tls-client
|
||||
if c.tlsClient == nil {
|
||||
return ""
|
||||
}
|
||||
cookies := c.tlsClient.GetCookies(u)
|
||||
for _, cookie := range cookies {
|
||||
if cookie.Name == name {
|
||||
@@ -494,12 +510,29 @@ func (c *TLSClient) GetCookie(urlStr string, name string) string {
|
||||
|
||||
// SetCookie 设置 Cookie
|
||||
func (c *TLSClient) SetCookie(urlStr string, cookie *http.Cookie) {
|
||||
if c.clientType == ClientTypeAzureTLS {
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
// azuretls 使用 Noooste/fhttp 的 Cookie 类型
|
||||
if c.clientType == ClientTypeAzureTLS {
|
||||
if c.azureSession == nil || c.azureSession.CookieJar == nil {
|
||||
return
|
||||
}
|
||||
c.azureSession.CookieJar.SetCookies(u, []*fhttp.Cookie{
|
||||
{
|
||||
Name: cookie.Name,
|
||||
Value: cookie.Value,
|
||||
Path: cookie.Path,
|
||||
Domain: cookie.Domain,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// tls-client
|
||||
if c.tlsClient == nil {
|
||||
return
|
||||
}
|
||||
c.tlsClient.SetCookies(u, []*http2.Cookie{
|
||||
|
||||
Reference in New Issue
Block a user