mirror of
https://github.com/unmojang/authlib-injector.git
synced 2025-09-30 14:50:41 -04:00
Javadoc for URLFilter&URLProcessor&URLRedirector
This commit is contained in:
parent
eeda91c329
commit
cbc1e8c664
@ -6,8 +6,24 @@ import java.util.Optional;
|
||||
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.
|
||||
*/
|
||||
public interface URLFilter {
|
||||
|
||||
/**
|
||||
* Returns true if the filter MAY be interested in the given URL.
|
||||
*
|
||||
* 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 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.
|
||||
*/
|
||||
boolean canHandle(String domain, String path);
|
||||
|
||||
Optional<Response> handle(String domain, String path, IHTTPSession session) throws IOException;
|
||||
|
@ -39,6 +39,16 @@ public class URLProcessor {
|
||||
this.redirector = redirector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the input URL(which is grabbed from the bytecode).
|
||||
*
|
||||
* If any filter is interested in the URL, the URL will be redirected to the local HTTP server.
|
||||
* Otherwise, the URLRedirector will be invoked to determine whether the URL should be modified
|
||||
* and pointed to the customized authentication server.
|
||||
* If none of above happens, empty is returned.
|
||||
*
|
||||
* @return the transformed URL, or empty if it doesn't need to be transformed
|
||||
*/
|
||||
public Optional<String> transformURL(String inputUrl) {
|
||||
Matcher matcher = URL_REGEX.matcher(inputUrl);
|
||||
if (!matcher.find()) {
|
||||
|
@ -2,6 +2,10 @@ package moe.yushi.authlibinjector.httpd;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A URLRedirector modifies the URLs found in the bytecode,
|
||||
* and points them to the customized authentication server.
|
||||
*/
|
||||
public interface URLRedirector {
|
||||
Optional<String> redirect(String domain, String path);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user