Skip to main content

Crate deepslate

Crate deepslate 

Source
Expand description

A high-performance Minecraft server proxy written in Rust.

This crate can be used as a library to build a custom proxy binary with compile-time plugins, or as a dependency of the default deepslate binary.

§Usage as a library

use deepslate::{Proxy, ServerId};
use deepslate::event::*;
use deepslate::event::events::*;

const LOBBY: ServerId = ServerId::new("lobby", "127.0.0.1:25566");

struct LobbyPlugin;

impl Plugin for LobbyPlugin {
    fn register(&self, events: &mut EventManager) {
        events.subscribe::<ChooseServerEvent>(PostOrder::NORMAL, |event| {
            event.set_result(LOBBY.into());
        });

        events.observe::<LoginEvent>(Phase::Post, |event| {
            println!("Player logged in: {}", event.player.profile.name);
        });
    }
}

#[tokio::main]
async fn main() {
    let proxy = Proxy::builder()
        .forwarding_secret("your-secret")
        .server(&LOBBY)
        .try_servers([&LOBBY])
        .plugin(LobbyPlugin)
        .build()
        .expect("failed to build proxy");
    proxy.run().await.expect("proxy error");
}

Re-exports§

pub use config::Config;
pub use event::EventManager;
pub use event::Phase;
pub use event::PlayerInfo;
pub use event::Plugin;
pub use event::PostOrder;
pub use server::Server;
pub use server::ServerId;
pub use server::ServerRegistry;

Modules§

auth
Authentication and player profiles. Mojang session server authentication.
config
Proxy configuration. Configuration loaded from environment variables or a builder API.
connection
Connection handling and networking. Connection handling: framing, encryption, compression, and the bidirectional packet relay pipeline.
connection_guard
Connection rate limiting and concurrency guards. Connection rate limiting and concurrency guards.
crypto
Cryptographic primitives. RSA key pair management and Minecraft’s “Notchian” server ID hash.
event
Event system and lifecycle events. Type-safe event system for the Deepslate proxy.
metrics
Metrics instrumentation and Prometheus exporter. Metrics instrumentation for the Deepslate proxy.
rpc
gRPC control plane service. gRPC service implementation for the Deepslate control plane.
server
Server registry and backend management. Named server registry with ordered try-list and forced-host routing for initial server selection.
status
Server status (MOTD) handling. Server list ping response builder.

Structs§

Proxy
The Deepslate proxy server.
ProxyBuilder
Builder for constructing a Proxy instance.

Enums§

ProxyError
Error type for public proxy operations.

Functions§

init_tracing
Initialize the tracing subscriber based on configuration.