forked from MirrorHub/authlib-injector
remove 'path' param from URLFilter.canHandle
This commit is contained in:
parent
1ba5bbb678
commit
20224ede05
5 changed files with 11 additions and 16 deletions
|
@ -52,7 +52,7 @@ public class LegacySkinAPIFilter implements URLFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(String domain, String path) {
|
||||
public boolean canHandle(String domain) {
|
||||
return domain.equals("skins.minecraft.net");
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class QueryProfileFilter implements URLFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(String domain, String path) {
|
||||
public boolean canHandle(String domain) {
|
||||
return domain.equals("sessionserver.mojang.com");
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class QueryUUIDsFilter implements URLFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(String domain, String path) {
|
||||
public boolean canHandle(String domain) {
|
||||
return domain.equals("api.mojang.com");
|
||||
}
|
||||
|
||||
|
|
|
@ -23,24 +23,19 @@ import moe.yushi.authlibinjector.internal.fi.iki.elonen.IHTTPSession;
|
|||
import moe.yushi.authlibinjector.internal.fi.iki.elonen.Response;
|
||||
|
||||
/**
|
||||
* A URLFilter filters the URLs in the bytecode, and intercepts those he is interested in.
|
||||
* A URLFilter filters the URLs in the bytecode, and intercepts those it is interested in.
|
||||
*/
|
||||
public interface URLFilter {
|
||||
|
||||
/**
|
||||
* Returns true if the filter MAY be interested in the given URL.
|
||||
* Returns true if the filter MAY be interested in the given domain.
|
||||
*
|
||||
* The URL is grabbed from the bytecode, and it may be different from the URL being used at runtime.
|
||||
* Therefore, the URLs may be incomplete or malformed, or contain some template symbols. eg:
|
||||
* https://api.mojang.com/profiles/ (the actual one being used is https://api.mojang.com/profiles/minecraft)
|
||||
* https://sessionserver.mojang.com/session/minecraft/profile/<uuid> (template symbols)
|
||||
*
|
||||
* If this method returns true for the given URL, the URL will be intercepted.
|
||||
* And when a request is sent to this URL, handle() will be invoked.
|
||||
* If this method returns true, the domain will be intercepted.
|
||||
* And when a request is sent to this domain, handle() will be invoked.
|
||||
* If it turns out that the filter doesn't really want to intercept the URL (handle() returns empty),
|
||||
* the request will be reverse-proxied to the original URL, as if nothing happened.
|
||||
* the request will be reverse-proxied to the original URL, as if nothing has happened.
|
||||
*/
|
||||
boolean canHandle(String domain, String path);
|
||||
boolean canHandle(String domain);
|
||||
|
||||
Optional<Response> handle(String domain, String path, IHTTPSession session) throws IOException;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class URLProcessor {
|
|||
private Optional<String> transform(String protocol, String domain, String path) {
|
||||
boolean handleLocally = false;
|
||||
for (URLFilter filter : filters) {
|
||||
if (filter.canHandle(domain, path)) {
|
||||
if (filter.canHandle(domain)) {
|
||||
handleLocally = true;
|
||||
break;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class URLProcessor {
|
|||
String domain = matcher.group("domain");
|
||||
String path = matcher.group("path");
|
||||
for (URLFilter filter : filters) {
|
||||
if (filter.canHandle(domain, path)) {
|
||||
if (filter.canHandle(domain)) {
|
||||
Optional<Response> result;
|
||||
try {
|
||||
result = filter.handle(domain, path, session);
|
||||
|
|
Loading…
Reference in a new issue