geforkt von Mirrors/Velocity
Fully replaced AsyncHttpClient (#1194)
Dieser Commit ist enthalten in:
Ursprung
b22b2dc458
Commit
6d7335b21f
@ -15,7 +15,6 @@ spotless = "com.diffplug.spotless:6.12.0"
|
||||
adventure-bom = "net.kyori:adventure-bom:4.15.0-SNAPSHOT"
|
||||
adventure-facet = "net.kyori:adventure-platform-facet:4.3.0"
|
||||
asm = "org.ow2.asm:asm:9.5"
|
||||
asynchttpclient = "org.asynchttpclient:async-http-client:2.12.3"
|
||||
brigadier = "com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT"
|
||||
bstats = "org.bstats:bstats-base:3.0.1"
|
||||
caffeine = "com.github.ben-manes.caffeine:caffeine:3.1.5"
|
||||
|
@ -119,7 +119,6 @@ dependencies {
|
||||
implementation(platform(libs.adventure.bom))
|
||||
implementation("net.kyori:adventure-nbt")
|
||||
implementation(libs.adventure.facet)
|
||||
implementation(libs.asynchttpclient)
|
||||
implementation(libs.completablefutures)
|
||||
implementation(libs.nightconfig)
|
||||
implementation(libs.bstats)
|
||||
|
@ -101,7 +101,6 @@ import net.kyori.adventure.translation.GlobalTranslator;
|
||||
import net.kyori.adventure.translation.TranslationRegistry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.asynchttpclient.AsyncHttpClient;
|
||||
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@ -595,10 +594,6 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
||||
}
|
||||
|
||||
public HttpClient getHttpClient() {
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public AsyncHttpClient getAsyncHttpClient() {
|
||||
return cm.getHttpClient();
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,11 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
||||
url += "&ip=" + urlFormParameterEscaper().escape(playerIp);
|
||||
}
|
||||
|
||||
HttpRequest httpRequest = HttpRequest.newBuilder().uri(URI.create(url)).build();
|
||||
final HttpRequest httpRequest = HttpRequest.newBuilder()
|
||||
.setHeader("User-Agent",
|
||||
server.getVersion().getName() + "/" + server.getVersion().getVersion())
|
||||
.uri(URI.create(url))
|
||||
.build();
|
||||
server.getHttpClient().sendAsync(httpRequest, HttpResponse.BodyHandlers.ofString())
|
||||
.whenCompleteAsync((response, throwable) -> {
|
||||
if (mcConnection.isClosed()) {
|
||||
|
@ -17,9 +17,6 @@
|
||||
|
||||
package com.velocitypowered.proxy.network;
|
||||
|
||||
import static org.asynchttpclient.Dsl.asyncHttpClient;
|
||||
import static org.asynchttpclient.Dsl.config;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.event.proxy.ListenerBoundEvent;
|
||||
import com.velocitypowered.api.event.proxy.ListenerCloseEvent;
|
||||
@ -37,15 +34,11 @@ import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.WriteBufferWaterMark;
|
||||
import io.netty.util.concurrent.GlobalEventExecutor;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.http.HttpClient;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.asynchttpclient.AsyncHttpClient;
|
||||
import org.asynchttpclient.RequestBuilder;
|
||||
import org.asynchttpclient.filter.FilterContext;
|
||||
import org.asynchttpclient.filter.FilterContext.FilterContextBuilder;
|
||||
import org.asynchttpclient.filter.RequestFilter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@ -69,7 +62,7 @@ public final class ConnectionManager {
|
||||
public final BackendChannelInitializerHolder backendChannelInitializer;
|
||||
|
||||
private final SeparatePoolInetNameResolver resolver;
|
||||
private final AsyncHttpClient httpClient;
|
||||
private final HttpClient httpClient;
|
||||
|
||||
/**
|
||||
* Initalizes the {@code ConnectionManager}.
|
||||
@ -86,21 +79,10 @@ public final class ConnectionManager {
|
||||
this.backendChannelInitializer = new BackendChannelInitializerHolder(
|
||||
new BackendChannelInitializer(this.server));
|
||||
this.resolver = new SeparatePoolInetNameResolver(GlobalEventExecutor.INSTANCE);
|
||||
this.httpClient = asyncHttpClient(config()
|
||||
.setEventLoopGroup(this.workerGroup)
|
||||
.setUserAgent(server.getVersion().getName() + "/" + server.getVersion().getVersion())
|
||||
.addRequestFilter(new RequestFilter() {
|
||||
@Override
|
||||
public <T> FilterContext<T> filter(FilterContext<T> ctx) {
|
||||
return new FilterContextBuilder<>(ctx)
|
||||
.request(new RequestBuilder(ctx.getRequest())
|
||||
.setNameResolver(resolver)
|
||||
.build())
|
||||
this.httpClient = HttpClient.newBuilder()
|
||||
.executor(this.workerGroup)
|
||||
.build();
|
||||
}
|
||||
})
|
||||
.build());
|
||||
}
|
||||
|
||||
public void logChannelInformation() {
|
||||
LOGGER.info("Connections will use {} channels, {} compression, {} ciphers", this.transportType,
|
||||
@ -256,8 +238,8 @@ public final class ConnectionManager {
|
||||
return this.serverChannelInitializer;
|
||||
}
|
||||
|
||||
public AsyncHttpClient getHttpClient() {
|
||||
return httpClient;
|
||||
public HttpClient getHttpClient() {
|
||||
return this.httpClient;
|
||||
}
|
||||
|
||||
public BackendChannelInitializerHolder getBackendChannelInitializer() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren