mirror of
https://github.com/ayunami2000/ayunViaProxyEagUtils.git
synced 2024-11-09 06:16:04 -08:00
Add Eaglercraft header passthrough
This commit is contained in:
parent
350296d2bb
commit
0f2425f4fa
|
@ -11,6 +11,7 @@ import com.viaversion.viaversion.protocols.base.ServerboundStatusPackets;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToMessageCodec;
|
import io.netty.handler.codec.MessageToMessageCodec;
|
||||||
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
|
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||||
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
|
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
|
||||||
|
@ -49,6 +50,7 @@ public class EaglercraftHandler extends MessageToMessageCodec<WebSocketFrame, By
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static final AttributeKey<ProfileData> profileDataKey = AttributeKey.newInstance("eagx-profile-data");
|
public static final AttributeKey<ProfileData> profileDataKey = AttributeKey.newInstance("eagx-profile-data");
|
||||||
|
public static final AttributeKey<HttpHeaders> httpHeadersKey = AttributeKey.newInstance("eag-http-headers");
|
||||||
private HostAndPort host;
|
private HostAndPort host;
|
||||||
public State state;
|
public State state;
|
||||||
public VersionEnum version;
|
public VersionEnum version;
|
||||||
|
@ -332,6 +334,7 @@ public class EaglercraftHandler extends MessageToMessageCodec<WebSocketFrame, By
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.host = HostAndPort.fromString(handshake.requestHeaders().get("Host").replaceAll("__", ".")).withDefaultPort(80);
|
this.host = HostAndPort.fromString(handshake.requestHeaders().get("Host").replaceAll("__", ".")).withDefaultPort(80);
|
||||||
|
ctx.channel().attr(httpHeadersKey).set(handshake.requestHeaders());
|
||||||
}
|
}
|
||||||
super.userEventTriggered(ctx, evt);
|
super.userEventTriggered(ctx, evt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,9 +174,8 @@ public class Main extends ViaProxyPlugin {
|
||||||
url.append("/").append(path);
|
url.append("/").append(path);
|
||||||
}
|
}
|
||||||
URI uri = new URI(url.toString());
|
URI uri = new URI(url.toString());
|
||||||
HttpHeaders headers = new DefaultHttpHeaders();
|
HttpHeaders headers = c2p.hasAttr(EaglercraftHandler.httpHeadersKey) ? c2p.attr(EaglercraftHandler.httpHeadersKey).get() : new DefaultHttpHeaders().set(HttpHeaderNames.ORIGIN, "via.shhnowisnottheti.me");
|
||||||
headers.set(HttpHeaderNames.HOST, uri.getHost() + (addPort ? ":" + uri.getPort() : ""));
|
headers.set(HttpHeaderNames.HOST, uri.getHost() + (addPort ? ":" + uri.getPort() : ""));
|
||||||
headers.set(HttpHeaderNames.ORIGIN, "via.shhnowisnottheti.me");
|
|
||||||
ch.pipeline().addAfter("eag-server-http-codec", "eag-server-http-aggregator", new HttpObjectAggregator(2097152, true));
|
ch.pipeline().addAfter("eag-server-http-codec", "eag-server-http-aggregator", new HttpObjectAggregator(2097152, true));
|
||||||
ch.pipeline().addAfter("eag-server-http-aggregator", "eag-server-ws-compression", WebSocketClientCompressionHandler.INSTANCE);
|
ch.pipeline().addAfter("eag-server-http-aggregator", "eag-server-ws-compression", WebSocketClientCompressionHandler.INSTANCE);
|
||||||
ch.pipeline().addAfter("eag-server-ws-compression", "eag-server-ws-handshaker", new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, WebSocketVersion.V13, null, true, headers, 2097152)));
|
ch.pipeline().addAfter("eag-server-ws-compression", "eag-server-ws-handshaker", new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(uri, WebSocketVersion.V13, null, true, headers, 2097152)));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user