[FEATURE][EXPERIMENTAL] Экспериментальная связка авторизации для прокси

This commit is contained in:
Gravit 2019-05-03 23:16:00 +07:00
parent f1cd39babd
commit 08f811add2
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 13 additions and 0 deletions

View file

@ -9,6 +9,7 @@
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import ru.gravit.launcher.events.ExceptionEvent;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.launcher.events.request.AuthRequestEvent;
import ru.gravit.launcher.events.request.ErrorRequestEvent;
import ru.gravit.launcher.hasher.HashedEntry;
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());
ProxyRequest proxyRequest = new ProxyRequest(response, 0);
proxyRequest.isCheckSign = client.checkSign;
try {
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);
} catch (RequestException e)
{

View file

@ -8,6 +8,7 @@
public class ProxyCommandResponse extends SimpleResponse {
public JsonResponseInterface response;
public long session;
public boolean isCheckSign;
@Override
public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
if(!client.proxy) {
@ -15,6 +16,7 @@ public void execute(ChannelHandlerContext ctx, Client client) throws Exception {
return;
}
Client real_client = server.sessionManager.getOrNewClient(session);
real_client.checkSign = isCheckSign;
response.execute(ctx, real_client);
}

View file

@ -7,6 +7,7 @@
public class ProxyRequest extends Request<ResultInterface> implements RequestInterface {
public RequestInterface response;
public long session;
public boolean isCheckSign;
public ProxyRequest(RequestInterface response, long session) {
this.response = response;