Include path in qhash

This commit is contained in:
Kavin 2023-11-20 08:31:19 +00:00
parent e0225d3e63
commit 39d3168227
No known key found for this signature in database
GPG Key ID: 6E4598CA5C92C41F
1 changed files with 10 additions and 9 deletions

View File

@ -109,6 +109,12 @@ public class URLUtils {
queryPairs.add(List.of("host", host));
}
String path = url.getPath();
if (path.contains("=")) {
path = StringUtils.substringBefore(path, "=") + "=" + StringUtils.substringAfter(path, "=").replace("-rj", "-rw");
}
if (PROXY_HASH_SECRET != null)
try {
MessageDigest md = MessageDigest.getInstance("BLAKE3-256");
@ -117,6 +123,8 @@ public class URLUtils {
md.update(pair.get(1).getBytes(StandardCharsets.UTF_8));
}
md.update(path.getBytes(StandardCharsets.UTF_8));
md.update(PROXY_HASH_SECRET);
queryPairs.add(List.of("qhash", Hex.encodeHexString(md.digest()).substring(0, 8)));
@ -124,13 +132,6 @@ public class URLUtils {
e.printStackTrace();
}
String path = url.getPath();
if (path.contains("=")) {
path = StringUtils.substringBefore(path, "=") + "=" + StringUtils.substringAfter(path, "=").replace("-rj", "-rw");
}
String newUrl = proxy + path;
StringBuilder qstring = null;
@ -142,9 +143,9 @@ public class URLUtils {
qstring.append("&");
}
qstring.append(pair.get(0));
qstring.append(silentEncode(pair.get(0)));
qstring.append("=");
qstring.append(pair.get(1));
qstring.append(silentEncode(pair.get(1)));
}
newUrl += "?" + qstring;