Send proxy header with monitor requests
This commit is contained in:
parent
6916800aeb
commit
493e24ff4d
@ -596,7 +596,7 @@ async fn connect_to_server_no_timeout(
|
|||||||
|
|
||||||
// Add proxy header
|
// Add proxy header
|
||||||
if config.server.send_proxy_v2 {
|
if config.server.send_proxy_v2 {
|
||||||
trace!(target: "lazymc::lobby", "Sending local proxy header for server connection");
|
trace!(target: "lazymc::lobby", "Sending client proxy header for server connection");
|
||||||
outbound
|
outbound
|
||||||
.write_all(&proxy::stream_proxy_header(inbound).map_err(|_| ())?)
|
.write_all(&proxy::stream_proxy_header(inbound).map_err(|_| ())?)
|
||||||
.await
|
.await
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// TODO: remove all unwraps/expects here!
|
|
||||||
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -12,12 +10,14 @@ use minecraft_protocol::version::v1_14_4::status::{
|
|||||||
PingRequest, PingResponse, StatusRequest, StatusResponse,
|
PingRequest, PingResponse, StatusRequest, StatusResponse,
|
||||||
};
|
};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::proto::client::{Client, ClientState};
|
use crate::proto::client::{Client, ClientState};
|
||||||
use crate::proto::{packet, packets};
|
use crate::proto::{packet, packets};
|
||||||
|
use crate::proxy;
|
||||||
use crate::server::{Server, State};
|
use crate::server::{Server, State};
|
||||||
|
|
||||||
/// Monitor ping inverval in seconds.
|
/// Monitor ping inverval in seconds.
|
||||||
@ -97,6 +97,15 @@ pub async fn poll_server(
|
|||||||
async fn fetch_status(config: &Config, addr: SocketAddr) -> Result<ServerStatus, ()> {
|
async fn fetch_status(config: &Config, addr: SocketAddr) -> Result<ServerStatus, ()> {
|
||||||
let mut stream = TcpStream::connect(addr).await.map_err(|_| ())?;
|
let mut stream = TcpStream::connect(addr).await.map_err(|_| ())?;
|
||||||
|
|
||||||
|
// Add proxy header
|
||||||
|
if config.server.send_proxy_v2 {
|
||||||
|
trace!(target: "lazymc::monitor", "Sending local proxy header for server connection");
|
||||||
|
stream
|
||||||
|
.write_all(&proxy::local_proxy_header().map_err(|_| ())?)
|
||||||
|
.await
|
||||||
|
.map_err(|_| ())?;
|
||||||
|
}
|
||||||
|
|
||||||
// Dummy client
|
// Dummy client
|
||||||
let client = Client::dummy();
|
let client = Client::dummy();
|
||||||
|
|
||||||
@ -109,6 +118,15 @@ async fn fetch_status(config: &Config, addr: SocketAddr) -> Result<ServerStatus,
|
|||||||
async fn do_ping(config: &Config, addr: SocketAddr) -> Result<(), ()> {
|
async fn do_ping(config: &Config, addr: SocketAddr) -> Result<(), ()> {
|
||||||
let mut stream = TcpStream::connect(addr).await.map_err(|_| ())?;
|
let mut stream = TcpStream::connect(addr).await.map_err(|_| ())?;
|
||||||
|
|
||||||
|
// Add proxy header
|
||||||
|
if config.server.send_proxy_v2 {
|
||||||
|
trace!(target: "lazymc::monitor", "Sending local proxy header for server connection");
|
||||||
|
stream
|
||||||
|
.write_all(&proxy::local_proxy_header().map_err(|_| ())?)
|
||||||
|
.await
|
||||||
|
.map_err(|_| ())?;
|
||||||
|
}
|
||||||
|
|
||||||
// Dummy client
|
// Dummy client
|
||||||
let client = Client::dummy();
|
let client = Client::dummy();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user