mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 20:30:51 +08:00
feat(provider/gemini-web): Prioritize explicit label for account identification
This commit is contained in:
@@ -88,6 +88,11 @@ func (s *GeminiWebState) Label() string {
|
|||||||
if s == nil {
|
if s == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
if s.token != nil {
|
||||||
|
if lbl := strings.TrimSpace(s.token.Label); lbl != "" {
|
||||||
|
return lbl
|
||||||
|
}
|
||||||
|
}
|
||||||
if s.storagePath != "" {
|
if s.storagePath != "" {
|
||||||
base := strings.TrimSuffix(filepath.Base(s.storagePath), filepath.Ext(s.storagePath))
|
base := strings.TrimSuffix(filepath.Base(s.storagePath), filepath.Ext(s.storagePath))
|
||||||
if base != "" {
|
if base != "" {
|
||||||
@@ -169,8 +174,12 @@ func (s *GeminiWebState) Refresh(ctx context.Context) error {
|
|||||||
s.client.Cookies["__Secure-1PSIDTS"] = newTS
|
s.client.Cookies["__Secure-1PSIDTS"] = newTS
|
||||||
}
|
}
|
||||||
s.tokenMu.Unlock()
|
s.tokenMu.Unlock()
|
||||||
// Detailed debug log: provider and account.
|
// Detailed debug log: provider and account label.
|
||||||
log.Debugf("gemini web account %s rotated 1PSIDTS: %s", s.accountID, MaskToken28(newTS))
|
label := strings.TrimSpace(s.Label())
|
||||||
|
if label == "" {
|
||||||
|
label = s.accountID
|
||||||
|
}
|
||||||
|
log.Debugf("gemini web account %s rotated 1PSIDTS: %s", label, MaskToken28(newTS))
|
||||||
}
|
}
|
||||||
s.lastRefresh = time.Now()
|
s.lastRefresh = time.Now()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ func parseGeminiWebToken(auth *cliproxyauth.Auth) (*gemini.GeminiWebTokenStorage
|
|||||||
if psid == "" || psidts == "" {
|
if psid == "" || psidts == "" {
|
||||||
return nil, fmt.Errorf("gemini-web executor: incomplete cookie metadata")
|
return nil, fmt.Errorf("gemini-web executor: incomplete cookie metadata")
|
||||||
}
|
}
|
||||||
return &gemini.GeminiWebTokenStorage{Secure1PSID: psid, Secure1PSIDTS: psidts}, nil
|
label := strings.TrimSpace(stringFromMetadata(auth.Metadata, "label"))
|
||||||
|
return &gemini.GeminiWebTokenStorage{Secure1PSID: psid, Secure1PSIDTS: psidts, Label: label}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringFromMetadata(meta map[string]any, keys ...string) string {
|
func stringFromMetadata(meta map[string]any, keys ...string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user