Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加KeepRetry值校验 #56

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/kotlin/com/rsplwe/esurfing/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class Client(private val options: Options) {
termUrl = doc.getElementsByTag("term-url").first()?.text() ?: ""
keepRetry = doc.getElementsByTag("keep-retry").first()?.text() ?: ""

// 检查keepRetry值是否正确,不正确则设置为默认值60
if (keepRetry.isBlank() || keepRetry.toInt() <= 0) {
keepRetry = "60"
logger.warn("KeepRetry value is incorrect, setting to default: $keepRetry")
}

logger.info("Keep Url: $keepUrl")
logger.info("Term Url: $termUrl")
logger.info("Keep Retry: $keepRetry")
Expand Down Expand Up @@ -192,6 +198,12 @@ class Client(private val options: Options) {
val data = session!!.decrypt(result.data.string())
val doc = Jsoup.parse(data, Parser.xmlParser())
keepRetry = doc.getElementsByTag("interval").first()?.text() ?: ""

// 再次检查keepRetry值是否正确,不正确则设置为默认值60
if (keepRetry.isBlank() || keepRetry.toInt() <= 0) {
keepRetry = "60"
logger.warn("KeepRetry value is incorrect after heartbeat, setting to default: $keepRetry")
}
}

is NetResult.Error -> {
Expand Down Expand Up @@ -222,4 +234,4 @@ class Client(private val options: Options) {
}
}
}
}
}
Loading