Skip to content

Commit

Permalink
fix: correct error messages and enhance cookie handling in OpenClash …
Browse files Browse the repository at this point in the history
…status script
  • Loading branch information
bin64 committed Dec 25, 2024
1 parent d32d999 commit 21c1431
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Clash Dash/ViewModels/ServerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ class ServerViewModel: NSObject, ObservableObject, URLSessionDelegate, URLSessio
case 200:
return try JSONDecoder().decode(ClashConfig.self, from: data)
case 401:
throw NetworkError.unauthorized(message: "��证失败: 服务器返回 401 未授权")
throw NetworkError.unauthorized(message: "认证失败: 服务器返回 401 未授权")
default:
throw NetworkError.serverError(httpResponse.statusCode)
}
Expand Down Expand Up @@ -887,7 +887,7 @@ class ServerViewModel: NSObject, ObservableObject, URLSessionDelegate, URLSessio
if let error = authResponse.error {
throw NetworkError.unauthorized(message: "认证失败: \(error)")
}
throw NetworkError.unauthorized(message: "认证失败: 服务器没有返回有效的认��令牌")
throw NetworkError.unauthorized(message: "认证失败: 服务器没有返回有效的认证令牌")
}

return token
Expand Down
8 changes: 4 additions & 4 deletions Debug/get_openclash_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ case $status_code in
log "send" "发送状态请求: $status_url"

# 构建状态请求头
status_headers="Cookie: sysauth_http=$token
status_headers="Cookie: sysauth_http=$token; sysauth=$token
Accept: */*
Connection: keep-alive
User-Agent: curl
Expand All @@ -126,7 +126,7 @@ Pragma: no-cache"
print_request "GET" "$status_url" "$status_headers"

status_response=$(curl -s --max-redirs 0 -w "\n%{http_code}" \
-H "Cookie: sysauth_http=$token" \
-H "Cookie: sysauth_http=$token; sysauth=$token" \
-H "Accept: */*" \
-H "Connection: keep-alive" \
-H "User-Agent: curl" \
Expand Down Expand Up @@ -160,7 +160,7 @@ Upgrade-Insecure-Requests: 1"
-H "Accept-Language: en-US,en;q=0.9" \
-H "Cache-Control: no-cache" \
-H "Connection: keep-alive" \
-H "Cookie: sysauth_http=$token" \
-H "Cookie: sysauth_http=$token; sysauth=$token" \
-H "DNT: 1" \
-H "Pragma: no-cache" \
-H "Upgrade-Insecure-Requests: 1" \
Expand Down Expand Up @@ -195,7 +195,7 @@ Content-Type: application/x-www-form-urlencoded; charset=utf-8"
-H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh-TW;q=0.7,zh;q=0.6" \
-H "Cache-Control: no-cache" \
-H "Connection: keep-alive" \
-H "Cookie: sysauth_http=$token" \
-H "Cookie: sysauth_http=$token; sysauth=$token" \
-H "DNT: 1" \
-H "Pragma: no-cache" \
-H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" \
Expand Down

0 comments on commit 21c1431

Please sign in to comment.