Merge pull request #737 from TeamPiped/qhash-path

Include path in qhash
This commit is contained in:
Kavin 2023-11-20 08:33:16 +00:00 committed by GitHub
commit a977355ebf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;