Add user agent support for subscription updates

https://github.com/2dust/v2rayNG/issues/5043
This commit is contained in:
2dust
2025-11-22 18:01:49 +08:00
parent e782da7c71
commit ed9c26b012
14 changed files with 41 additions and 4 deletions
@@ -425,17 +425,18 @@ object AngConfigManager {
}
}
Log.i(AppConfig.TAG, url)
val userAgent = it.second.userAgent
var configText = try {
val httpPort = SettingsManager.getHttpPort()
HttpUtil.getUrlContentWithUserAgent(url, 15000, httpPort)
HttpUtil.getUrlContentWithUserAgent(url, userAgent, 15000, httpPort)
} catch (e: Exception) {
Log.e(AppConfig.ANG_PACKAGE, "Update subscription: proxy not ready or other error", e)
""
}
if (configText.isEmpty()) {
configText = try {
HttpUtil.getUrlContentWithUserAgent(url)
HttpUtil.getUrlContentWithUserAgent(url, userAgent)
} catch (e: Exception) {
Log.e(AppConfig.TAG, "Update subscription: Failed to get URL content with user agent", e)
""