Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
various things
Dieser Commit ist enthalten in:
Ursprung
8c22b50fa4
Commit
5e708e9136
11
build.gradle
11
build.gradle
@ -7,17 +7,20 @@ group 'com.velocitypowered'
|
|||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'io.netty:netty-handler:4.1.27.Final'
|
compile 'com.google.code.gson:gson:2.8.5'
|
||||||
|
compile 'com.google.guava:guava:25.1-jre'
|
||||||
compile 'io.netty:netty-codec:4.1.27.Final'
|
compile 'io.netty:netty-codec:4.1.27.Final'
|
||||||
compile 'io.netty:netty-codec-http:4.1.27.Final'
|
compile 'io.netty:netty-codec-http:4.1.27.Final'
|
||||||
compile 'com.google.guava:guava:25.1-jre'
|
compile 'io.netty:netty-handler:4.1.27.Final'
|
||||||
compile 'com.google.code.gson:gson:2.8.5'
|
|
||||||
compile 'net.kyori:text:1.12-1.5.0'
|
compile 'net.kyori:text:1.12-1.5.0'
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
testCompile 'org.junit.jupiter:junit-jupiter-api:5.3.0-M1'
|
||||||
|
testCompile 'org.junit.jupiter:junit-jupiter-engine:5.3.0-M1'
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1 @@
|
|||||||
rootProject.name = 'velocity'
|
rootProject.name = 'velocity'
|
||||||
|
|
||||||
|
@ -5,9 +5,6 @@ public class Velocity {
|
|||||||
VelocityServer server = new VelocityServer();
|
VelocityServer server = new VelocityServer();
|
||||||
server.initialize();
|
server.initialize();
|
||||||
|
|
||||||
while (true) {
|
Thread.currentThread().join();
|
||||||
// temporary until jline is added.
|
|
||||||
Thread.sleep(999999);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.velocitypowered.proxy.protocol;
|
package com.velocitypowered.proxy.protocol;
|
||||||
|
|
||||||
import com.velocitypowered.proxy.protocol.packets.*;
|
import com.velocitypowered.proxy.protocol.packets.*;
|
||||||
|
import io.netty.util.collection.IntObjectHashMap;
|
||||||
|
import io.netty.util.collection.IntObjectMap;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -49,7 +51,7 @@ public enum StateRegistry {
|
|||||||
public static class ProtocolMappings {
|
public static class ProtocolMappings {
|
||||||
private final ProtocolConstants.Direction direction;
|
private final ProtocolConstants.Direction direction;
|
||||||
private final StateRegistry state;
|
private final StateRegistry state;
|
||||||
private final Map<Integer, Supplier<? extends MinecraftPacket>> idsToSuppliers = new HashMap<>();
|
private final IntObjectMap<Supplier<? extends MinecraftPacket>> idsToSuppliers = new IntObjectHashMap<>();
|
||||||
private final Map<Class<? extends MinecraftPacket>, Integer> packetClassesToIds = new HashMap<>();
|
private final Map<Class<? extends MinecraftPacket>, Integer> packetClassesToIds = new HashMap<>();
|
||||||
|
|
||||||
public ProtocolMappings(ProtocolConstants.Direction direction, StateRegistry state) {
|
public ProtocolMappings(ProtocolConstants.Direction direction, StateRegistry state) {
|
||||||
|
@ -6,22 +6,32 @@ import io.netty.handler.timeout.ReadTimeoutHandler;
|
|||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class MinecraftPipelineUtils {
|
public interface MinecraftPipelineUtils {
|
||||||
public static void strapPipelineForProxy(Channel ch) {
|
String FRAME_DECODER = "frame-decoder";
|
||||||
ch.pipeline().addLast("read-timeout", new ReadTimeoutHandler(30, TimeUnit.SECONDS));
|
String FRAME_ENCODER = "frame-encoder";
|
||||||
ch.pipeline().addLast("legacy-ping-decode", new LegacyPingDecoder());
|
String LEGACY_PING_DECODER = "legacy-ping-decoder";
|
||||||
ch.pipeline().addLast("frame-decoder", new MinecraftVarintFrameDecoder());
|
String LEGACY_PING_ENCODER = "legacy-ping-encoder";
|
||||||
ch.pipeline().addLast("legacy-ping-encode", LegacyPingEncoder.INSTANCE);
|
String MINECRAFT_DECODER = "minecraft-decoder";
|
||||||
ch.pipeline().addLast("frame-encoder", MinecraftVarintLengthEncoder.INSTANCE);
|
String MINECRAFT_ENCODER = "minecraft-encoder";
|
||||||
ch.pipeline().addLast("minecraft-decoder", new MinecraftDecoder(ProtocolConstants.Direction.TO_SERVER));
|
String READ_TIMEOUT = "read-timeout";
|
||||||
ch.pipeline().addLast("minecraft-encoder", new MinecraftEncoder(ProtocolConstants.Direction.TO_CLIENT));
|
|
||||||
|
static void strapPipelineForProxy(Channel ch) {
|
||||||
|
ch.pipeline()
|
||||||
|
.addLast(READ_TIMEOUT, new ReadTimeoutHandler(30, TimeUnit.SECONDS))
|
||||||
|
.addLast(LEGACY_PING_DECODER, new LegacyPingDecoder())
|
||||||
|
.addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder())
|
||||||
|
.addLast(LEGACY_PING_ENCODER, LegacyPingEncoder.INSTANCE)
|
||||||
|
.addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE)
|
||||||
|
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolConstants.Direction.TO_SERVER))
|
||||||
|
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolConstants.Direction.TO_CLIENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void strapPipelineForBackend(Channel ch) {
|
static void strapPipelineForBackend(Channel ch) {
|
||||||
ch.pipeline().addLast("read-timeout", new ReadTimeoutHandler(30, TimeUnit.SECONDS));
|
ch.pipeline()
|
||||||
ch.pipeline().addLast("frame-decoder", new MinecraftVarintFrameDecoder());
|
.addLast(READ_TIMEOUT, new ReadTimeoutHandler(30, TimeUnit.SECONDS))
|
||||||
ch.pipeline().addLast("frame-encoder", MinecraftVarintLengthEncoder.INSTANCE);
|
.addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder())
|
||||||
ch.pipeline().addLast("minecraft-decoder", new MinecraftDecoder(ProtocolConstants.Direction.TO_CLIENT));
|
.addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE)
|
||||||
ch.pipeline().addLast("minecraft-encoder", new MinecraftEncoder(ProtocolConstants.Direction.TO_SERVER));
|
.addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolConstants.Direction.TO_CLIENT))
|
||||||
|
.addLast(MINECRAFT_ENCODER, new MinecraftEncoder(ProtocolConstants.Direction.TO_SERVER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,18 @@ package com.velocitypowered.proxy.util;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public enum UuidUtils {
|
public enum UuidUtils {
|
||||||
;
|
;
|
||||||
|
|
||||||
public static UUID fromMojang(String id) {
|
public static UUID fromUndashed(final String string) {
|
||||||
Preconditions.checkNotNull(id, "id");
|
Objects.requireNonNull(string, "string");
|
||||||
Preconditions.checkArgument(id.length() == 32, "Length is incorrect");
|
Preconditions.checkArgument(string.length() == 32, "Length is incorrect");
|
||||||
return UUID.fromString(
|
return new UUID(
|
||||||
id.substring(0, 8) + "-" +
|
Long.parseUnsignedLong(string.substring(0, 16), 16),
|
||||||
id.substring(8, 12) + "-" +
|
Long.parseUnsignedLong(string.substring(16), 16)
|
||||||
id.substring(12, 16) + "-" +
|
|
||||||
id.substring(16, 20) + "-" +
|
|
||||||
id.substring(20, 32)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package com.velocitypowered.proxy.util;
|
package com.velocitypowered.proxy.util;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
public class EncryptionUtilsTest {
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
class EncryptionUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void twoComplementsSha1Digest() throws Exception {
|
void twoComplementsSha1Digest() throws Exception {
|
||||||
String notchHash = hexDigest("Notch");
|
String notchHash = hexDigest("Notch");
|
||||||
Assert.assertEquals("4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48", notchHash);
|
assertEquals("4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48", notchHash);
|
||||||
|
|
||||||
String jebHash = hexDigest("jeb_");
|
String jebHash = hexDigest("jeb_");
|
||||||
Assert.assertEquals("-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1", jebHash);
|
assertEquals("-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1", jebHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String hexDigest(String str) throws Exception {
|
private String hexDigest(String str) throws Exception {
|
||||||
@ -22,4 +23,4 @@ public class EncryptionUtilsTest {
|
|||||||
byte[] digested = digest.digest();
|
byte[] digested = digest.digest();
|
||||||
return EncryptionUtils.twoComplementsSha1Digest(digested);
|
return EncryptionUtils.twoComplementsSha1Digest(digested);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
package com.velocitypowered.proxy.util;
|
package com.velocitypowered.proxy.util;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class UuidUtilsTest {
|
class UuidUtilsTest {
|
||||||
private static final UUID VALID_UUID = UUID.fromString("6b501978-d3be-4f33-bcf6-6e7808f37a0d");
|
private static final UUID EXPECTED_DASHED_UUID = UUID.fromString("6b501978-d3be-4f33-bcf6-6e7808f37a0d");
|
||||||
private static final String VALID_MOJANG_UUID = "6b501978d3be4f33bcf66e7808f37a0d";
|
private static final String ACTUAL_UNDASHED_UUID = EXPECTED_DASHED_UUID.toString().replace("-", "");
|
||||||
|
|
||||||
private static final UUID TEST_OFFLINE_PLAYER_UUID = UUID.fromString("708f6260-183d-3912-bbde-5e279a5e739a");
|
private static final UUID TEST_OFFLINE_PLAYER_UUID = UUID.fromString("708f6260-183d-3912-bbde-5e279a5e739a");
|
||||||
private static final String TEST_OFFLINE_PLAYER = "tuxed";
|
private static final String TEST_OFFLINE_PLAYER = "tuxed";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fromMojang() {
|
void testFromUndashed() {
|
||||||
Assert.assertEquals("UUIDs do not match", VALID_UUID, UuidUtils.fromMojang(VALID_MOJANG_UUID));
|
assertEquals(EXPECTED_DASHED_UUID, UuidUtils.fromUndashed(ACTUAL_UNDASHED_UUID), "UUIDs do not match");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateOfflinePlayerUuid() {
|
void generateOfflinePlayerUuid() {
|
||||||
Assert.assertEquals("UUIDs do not match", TEST_OFFLINE_PLAYER_UUID, UuidUtils.generateOfflinePlayerUuid(TEST_OFFLINE_PLAYER));
|
assertEquals(TEST_OFFLINE_PLAYER_UUID, UuidUtils.generateOfflinePlayerUuid(TEST_OFFLINE_PLAYER), "UUIDs do not match");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren