mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-03-31 21:44:04 +03:00
[FEATURE][EXPERIMENTAL] Экспериментальная связка авторизации для прокси
This commit is contained in:
parent
f1cd39babd
commit
08f811add2
3 changed files with 13 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||||
import ru.gravit.launcher.events.ExceptionEvent;
|
import ru.gravit.launcher.events.ExceptionEvent;
|
||||||
import ru.gravit.launcher.events.RequestEvent;
|
import ru.gravit.launcher.events.RequestEvent;
|
||||||
|
import ru.gravit.launcher.events.request.AuthRequestEvent;
|
||||||
import ru.gravit.launcher.events.request.ErrorRequestEvent;
|
import ru.gravit.launcher.events.request.ErrorRequestEvent;
|
||||||
import ru.gravit.launcher.hasher.HashedEntry;
|
import ru.gravit.launcher.hasher.HashedEntry;
|
||||||
import ru.gravit.launcher.hasher.HashedEntryAdapter;
|
import ru.gravit.launcher.hasher.HashedEntryAdapter;
|
||||||
|
@ -73,8 +74,17 @@ void process(ChannelHandlerContext ctx, TextWebSocketFrame frame, Client client)
|
||||||
}
|
}
|
||||||
LogHelper.debug("Proxy %s request", response.getType());
|
LogHelper.debug("Proxy %s request", response.getType());
|
||||||
ProxyRequest proxyRequest = new ProxyRequest(response, 0);
|
ProxyRequest proxyRequest = new ProxyRequest(response, 0);
|
||||||
|
proxyRequest.isCheckSign = client.checkSign;
|
||||||
try {
|
try {
|
||||||
ResultInterface result = proxyRequest.request();
|
ResultInterface result = proxyRequest.request();
|
||||||
|
if(result instanceof AuthRequestEvent)
|
||||||
|
{
|
||||||
|
LogHelper.debug("Client auth params get successful");
|
||||||
|
AuthRequestEvent authRequestEvent = (AuthRequestEvent) result;
|
||||||
|
client.isAuth = true;
|
||||||
|
client.session = authRequestEvent.session;
|
||||||
|
if(authRequestEvent.playerProfile != null) client.username = authRequestEvent.playerProfile.username;
|
||||||
|
}
|
||||||
sendObject(ctx, result);
|
sendObject(ctx, result);
|
||||||
} catch (RequestException e)
|
} catch (RequestException e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
public class ProxyCommandResponse extends SimpleResponse {
|
public class ProxyCommandResponse extends SimpleResponse {
|
||||||
public JsonResponseInterface response;
|
public JsonResponseInterface response;
|
||||||
public long session;
|
public long session;
|
||||||
|
public boolean isCheckSign;
|
||||||
@Override
|
@Override
|
||||||
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
if(!client.proxy) {
|
if(!client.proxy) {
|
||||||
|
@ -15,6 +16,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Client real_client = server.sessionManager.getOrNewClient(session);
|
Client real_client = server.sessionManager.getOrNewClient(session);
|
||||||
|
real_client.checkSign = isCheckSign;
|
||||||
response.execute(ctx, real_client);
|
response.execute(ctx, real_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
public class ProxyRequest extends Request<ResultInterface> implements RequestInterface {
|
public class ProxyRequest extends Request<ResultInterface> implements RequestInterface {
|
||||||
public RequestInterface response;
|
public RequestInterface response;
|
||||||
public long session;
|
public long session;
|
||||||
|
public boolean isCheckSign;
|
||||||
|
|
||||||
public ProxyRequest(RequestInterface response, long session) {
|
public ProxyRequest(RequestInterface response, long session) {
|
||||||
this.response = response;
|
this.response = response;
|
||||||
|
|
Loading…
Reference in a new issue