Skip to content

Commit f6f410f

Browse files
committed
chore: Changing the User-Agent used to retrieve subscription-userinfo
ClashForWindows is no longer able to retrieve information from some providers.
1 parent fda769c commit f6f410f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

service/src/main/java/com/github/kr328/clash/service/ProfileManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ class ProfileManager(private val context: Context) : IProfileManager,
139139
suspend fun updateFlow(old: Imported) {
140140
val client = OkHttpClient()
141141
try {
142+
val versionName = context.packageManager.getPackageInfo(context.packageName, 0).versionName
142143
val request = Request.Builder()
143144
.url(old.source)
144-
.header("User-Agent", "ClashforWindows/0.19.23")
145+
.header("User-Agent", "ClashMetaForAndroid/$versionName")
145146
.build()
146147

147148
client.newCall(request).execute().use { response ->

service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ object ProfileProcessor {
7676
if (snapshot?.type == Profile.Type.Url) {
7777
if (snapshot.source.startsWith("https://", true)) {
7878
val client = OkHttpClient()
79+
val versionName = context.packageManager.getPackageInfo(context.packageName, 0).versionName
7980
val request = Request.Builder()
8081
.url(snapshot.source)
81-
.header("User-Agent", "ClashforWindows/0.19.23")
82+
.header("User-Agent", "ClashMetaForAndroid/$versionName")
8283
.build()
8384

8485
client.newCall(request).execute().use { response ->

0 commit comments

Comments
 (0)