cippy issue, fmt, update/upgrade

This commit is contained in:
2026-08-16 10:33:28 +02:00
parent b527019b76
commit a66ea31ab3
14 changed files with 301 additions and 133 deletions
+19 -5
View File
@@ -21,15 +21,29 @@ use std::{
use anyhow::{Context, Result, bail};
use bytes::Bytes;
use lanparty_ctrl::{
CONTROL_LENGTH_PREFIX_LEN, ControlMessage, DisconnectReason, EndpointHello,
MAX_CONTROL_MESSAGE_LEN, RELAY_ALPN, RoomCode, ServerWelcome, decode_control_frame,
CONTROL_LENGTH_PREFIX_LEN,
ControlMessage,
DisconnectReason,
EndpointHello,
MAX_CONTROL_MESSAGE_LEN,
RELAY_ALPN,
RoomCode,
ServerWelcome,
decode_control_frame,
encode_control_message,
};
use lanparty_obs::{DropReason, QuicDiagnostics, TunnelStats};
use lanparty_proto::{
EthernetFrame, FrameType, MacAddr, OVERLAY_FLAGS_NONE, decode_datagram, encode_datagram,
ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason, validate_datagram_budget,
EthernetFrame,
FrameType,
MacAddr,
OVERLAY_FLAGS_NONE,
decode_datagram,
encode_datagram,
ethernet_frame_exceeds_tap_mtu,
gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason,
validate_datagram_budget,
};
use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig};
use rustls::pki_types::CertificateDer;
+9 -3
View File
@@ -286,9 +286,15 @@ mod windows;
pub use windows::{PinnedRelayRoute, best_route_to, interface_identity_from_guid, pin_relay_route};
#[cfg(windows)]
pub use windows::{
ScopedDefaultRoutes, ScopedInterfaceMetric, ScopedInterfaceMtu, interface_metric,
interface_mtu, interface_unicast_addresses, set_scoped_default_routes_disabled,
set_scoped_interface_metric, set_scoped_interface_mtu,
ScopedDefaultRoutes,
ScopedInterfaceMetric,
ScopedInterfaceMtu,
interface_metric,
interface_mtu,
interface_unicast_addresses,
set_scoped_default_routes_disabled,
set_scoped_interface_metric,
set_scoped_interface_mtu,
};
#[cfg(not(windows))]
+46 -18
View File
@@ -1,34 +1,62 @@
use std::{
fmt, io,
fmt,
io,
net::{IpAddr, Ipv4Addr, Ipv6Addr},
ptr::{null, null_mut},
slice,
};
use anyhow::{Context, Result, bail};
use windows_sys::Win32::{
Foundation::{ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS},
NetworkManagement::{
IpHelper::{
ConvertInterfaceGuidToLuid, ConvertInterfaceLuidToIndex, CreateIpForwardEntry2,
DeleteIpForwardEntry2, FreeMibTable, GetBestRoute2, GetIpInterfaceEntry,
GetUnicastIpAddressTable, IP_ADDRESS_PREFIX, InitializeIpForwardEntry,
InitializeIpInterfaceEntry, MIB_IPFORWARD_ROW2, MIB_IPINTERFACE_ROW,
MIB_UNICASTIPADDRESS_ROW, MIB_UNICASTIPADDRESS_TABLE, SetIpInterfaceEntry,
use windows_sys::{
Win32::{
Foundation::{ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS},
NetworkManagement::{
IpHelper::{
ConvertInterfaceGuidToLuid,
ConvertInterfaceLuidToIndex,
CreateIpForwardEntry2,
DeleteIpForwardEntry2,
FreeMibTable,
GetBestRoute2,
GetIpInterfaceEntry,
GetUnicastIpAddressTable,
IP_ADDRESS_PREFIX,
InitializeIpForwardEntry,
InitializeIpInterfaceEntry,
MIB_IPFORWARD_ROW2,
MIB_IPINTERFACE_ROW,
MIB_UNICASTIPADDRESS_ROW,
MIB_UNICASTIPADDRESS_TABLE,
SetIpInterfaceEntry,
},
Ndis::NET_LUID_LH,
},
Networking::WinSock::{
AF_INET,
AF_INET6,
AF_UNSPEC,
IN_ADDR,
IN_ADDR_0,
IN6_ADDR,
IN6_ADDR_0,
RouteProtocolNetMgmt,
SOCKADDR_IN,
SOCKADDR_IN6,
SOCKADDR_IN6_0,
SOCKADDR_INET,
},
Ndis::NET_LUID_LH,
},
Networking::WinSock::{
AF_INET, AF_INET6, AF_UNSPEC, IN_ADDR, IN_ADDR_0, IN6_ADDR, IN6_ADDR_0,
RouteProtocolNetMgmt, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR_IN6_0, SOCKADDR_INET,
},
core::GUID,
};
use windows_sys::core::GUID;
use crate::{
InterfaceMetricSnapshot, InterfaceMtuSnapshot, InterfaceUnicastAddress, IpInterfaceFamily,
InterfaceMetricSnapshot,
InterfaceMtuSnapshot,
InterfaceUnicastAddress,
IpInterfaceFamily,
NetworkInterfaceIdentity,
RouteSnapshot,
};
use crate::{NetworkInterfaceIdentity, RouteSnapshot};
pub fn interface_identity_from_guid(interface_guid: &str) -> Result<NetworkInterfaceIdentity> {
let guid = parse_interface_guid(interface_guid)?;
+34 -8
View File
@@ -8,25 +8,51 @@ use anyhow::{Context, Result, bail};
use lanparty_proto::MacAddr;
use windows_sys::Win32::{
Foundation::{
CloseHandle, ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA, ERROR_NO_MORE_ITEMS, ERROR_SUCCESS,
GENERIC_READ, GENERIC_WRITE, HANDLE, INVALID_HANDLE_VALUE,
CloseHandle,
ERROR_FILE_NOT_FOUND,
ERROR_MORE_DATA,
ERROR_NO_MORE_ITEMS,
ERROR_SUCCESS,
GENERIC_READ,
GENERIC_WRITE,
HANDLE,
INVALID_HANDLE_VALUE,
},
Storage::FileSystem::{
CreateFileW, FILE_ATTRIBUTE_SYSTEM, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING,
ReadFile, WriteFile,
CreateFileW,
FILE_ATTRIBUTE_SYSTEM,
FILE_SHARE_READ,
FILE_SHARE_WRITE,
OPEN_EXISTING,
ReadFile,
WriteFile,
},
System::{
IO::DeviceIoControl,
Registry::{
HKEY, HKEY_LOCAL_MACHINE, KEY_READ, KEY_SET_VALUE, REG_SZ, RegCloseKey, RegEnumKeyExW,
RegOpenKeyExW, RegQueryValueExW, RegSetValueExW,
HKEY,
HKEY_LOCAL_MACHINE,
KEY_READ,
KEY_SET_VALUE,
REG_SZ,
RegCloseKey,
RegEnumKeyExW,
RegOpenKeyExW,
RegQueryValueExW,
RegSetValueExW,
},
},
};
use crate::{
TAP_ADAPTER_KEY, TapAdapterInfo, is_tap_component_id, tap_ioctl_get_mac, tap_ioctl_get_mtu,
tap_ioctl_set_media_status, tap_network_address_value, validate_tap_ethernet_frame,
TAP_ADAPTER_KEY,
TapAdapterInfo,
is_tap_component_id,
tap_ioctl_get_mac,
tap_ioctl_get_mtu,
tap_ioctl_set_media_status,
tap_network_address_value,
validate_tap_ethernet_frame,
};
#[derive(Debug)]
+14 -4
View File
@@ -12,14 +12,23 @@ use std::{sync::mpsc, thread, time::Duration};
use anyhow::{Context, Result, bail};
use clap::Parser;
use lanparty_client_core::{
ClientIdentity, ClientIdentityStore, ClientSession, ClientSessionConfig, connect_client,
ClientIdentity,
ClientIdentityStore,
ClientSession,
ClientSessionConfig,
connect_client,
};
#[cfg(windows)]
use lanparty_client_core::{ClientReceiveOutcome, ClientRelayIo};
#[cfg(windows)]
use lanparty_client_route::{
IpInterfaceFamily, NetworkInterfaceIdentity, PinnedRelayRoute, RouteSnapshot,
ScopedDefaultRoutes, ScopedInterfaceMetric, ScopedInterfaceMtu,
IpInterfaceFamily,
NetworkInterfaceIdentity,
PinnedRelayRoute,
RouteSnapshot,
ScopedDefaultRoutes,
ScopedInterfaceMetric,
ScopedInterfaceMtu,
};
#[cfg(windows)]
use lanparty_client_tap::TapAdapter;
@@ -1263,11 +1272,12 @@ mod tests {
time::{SystemTime, UNIX_EPOCH},
};
use super::*;
use lanparty_ctrl::{DisconnectReason, PeerInfo};
use lanparty_net::DEFAULT_RELAY_PORT;
use lanparty_obs::{QuicDiagnostics, TunnelStats};
use super::*;
#[cfg(not(windows))]
#[test]
fn rejects_runtime_on_non_windows() {
+6 -2
View File
@@ -9,8 +9,12 @@ use std::{fmt, str::FromStr};
mod codec;
pub use codec::{
CONTROL_LENGTH_PREFIX_LEN, ControlCodecError, MAX_CONTROL_MESSAGE_LEN,
complete_control_frame_len, decode_control_frame, encode_control_message,
CONTROL_LENGTH_PREFIX_LEN,
ControlCodecError,
MAX_CONTROL_MESSAGE_LEN,
complete_control_frame_len,
decode_control_frame,
encode_control_message,
};
pub use lanparty_obs::TunnelStats;
use lanparty_proto::{MIN_USEFUL_TAP_MTU, MacAddr, MtuError, recommended_tap_mtu};
+25 -10
View File
@@ -23,27 +23,42 @@ use anyhow::{Context, Result, bail};
use bytes::Bytes;
use clap::Parser;
use lanparty_ctrl::{
CONTROL_LENGTH_PREFIX_LEN, ControlMessage, DisconnectReason, EndpointHello,
MAX_CONTROL_MESSAGE_LEN, PeerInfo, RELAY_ALPN, Role, RoomCode, ServerWelcome,
decode_control_frame, encode_control_message,
CONTROL_LENGTH_PREFIX_LEN,
ControlMessage,
DisconnectReason,
EndpointHello,
MAX_CONTROL_MESSAGE_LEN,
PeerInfo,
RELAY_ALPN,
Role,
RoomCode,
ServerWelcome,
decode_control_frame,
encode_control_message,
};
use lanparty_net::RelayEndpoint;
use lanparty_obs::{DropReason, TunnelStats};
#[cfg(target_os = "linux")]
use lanparty_obs::{FrameAction, FrameDirection, FrameLog};
use lanparty_proto::{
EthernetFrame, FrameType, MacAddr, OVERLAY_FLAGS_NONE, decode_datagram, encode_datagram,
ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason, validate_datagram_budget,
EthernetFrame,
FrameType,
MacAddr,
OVERLAY_FLAGS_NONE,
decode_datagram,
encode_datagram,
ethernet_frame_exceeds_tap_mtu,
gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason,
validate_datagram_budget,
};
#[cfg(target_os = "linux")]
pub use packet::PacketSocket;
use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig};
use rustls::pki_types::CertificateDer;
#[cfg(target_os = "linux")]
use tokio::io::unix::AsyncFd;
#[cfg(target_os = "linux")]
pub use packet::PacketSocket;
const MAX_CONTROL_FRAME_LEN: usize = CONTROL_LENGTH_PREFIX_LEN + MAX_CONTROL_MESSAGE_LEN;
const DISCONNECT_DRAIN_TIMEOUT: Duration = Duration::from_millis(250);
#[cfg(target_os = "linux")]
@@ -1146,7 +1161,7 @@ mod tests {
let help = String::from_utf8(help).unwrap();
assert!(
help.contains("[aliases: --iface]"),
help.contains("[alias: --iface]") || help.contains("[aliases: --iface]"),
"gateway help should advertise --iface alias:\n{help}"
);
}
+2 -1
View File
@@ -1,6 +1,7 @@
use std::{
ffi::CString,
fs, io,
fs,
io,
os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd},
path::Path,
};
+33 -9
View File
@@ -11,22 +11,46 @@ mod overlay;
mod safety;
pub use ethernet::{
ETHERNET_HEADER_LEN, EthernetFrame, MAX_STANDARD_ETHERNET_FRAME_LEN,
MAX_STANDARD_ETHERNET_PAYLOAD_LEN, MIN_ETHERNET_FRAME_LEN,
ETHERNET_HEADER_LEN,
EthernetFrame,
MAX_STANDARD_ETHERNET_FRAME_LEN,
MAX_STANDARD_ETHERNET_PAYLOAD_LEN,
MIN_ETHERNET_FRAME_LEN,
};
pub use mac::{MacAddr, MacParseError};
pub use mtu::{
DEFAULT_DATAGRAM_SAFETY_MARGIN, DEFAULT_TAP_MTU, MIN_USEFUL_TAP_MTU, MtuError,
ethernet_frame_exceeds_tap_mtu, max_ethernet_frame_len_for_tap_mtu, max_tap_mtu_for_datagram,
DEFAULT_DATAGRAM_SAFETY_MARGIN,
DEFAULT_TAP_MTU,
MIN_USEFUL_TAP_MTU,
MtuError,
ethernet_frame_exceeds_tap_mtu,
max_ethernet_frame_len_for_tap_mtu,
max_tap_mtu_for_datagram,
recommended_tap_mtu,
};
pub use overlay::{
FrameType, OVERLAY_FLAGS_NONE, OVERLAY_HEADER_LEN, OVERLAY_MAGIC, OVERLAY_VERSION,
OverlayHeader, OverlayPacket, ProtoError, decode_datagram, encode_datagram,
FrameType,
OVERLAY_FLAGS_NONE,
OVERLAY_HEADER_LEN,
OVERLAY_MAGIC,
OVERLAY_VERSION,
OverlayHeader,
OverlayPacket,
ProtoError,
decode_datagram,
encode_datagram,
validate_datagram_budget,
};
pub use safety::{
ETHERTYPE_8021AD, ETHERTYPE_8021Q, ETHERTYPE_EAPOL, ETHERTYPE_IPV4, ETHERTYPE_IPV6,
ETHERTYPE_LLDP, ETHERTYPE_QINQ, ETHERTYPE_SLOW_PROTOCOLS, EthernetSafetyDrop,
gateway_lan_safety_drop_reason, remote_client_safety_drop_reason,
ETHERTYPE_8021AD,
ETHERTYPE_8021Q,
ETHERTYPE_EAPOL,
ETHERTYPE_IPV4,
ETHERTYPE_IPV6,
ETHERTYPE_LLDP,
ETHERTYPE_QINQ,
ETHERTYPE_SLOW_PROTOCOLS,
EthernetSafetyDrop,
gateway_lan_safety_drop_reason,
remote_client_safety_drop_reason,
};
+18 -7
View File
@@ -9,18 +9,28 @@ mod server;
use std::{collections::HashMap, time::Instant};
pub use config::{ConfigError, DEFAULT_RELAY_PORT, ListenEndpoint, RelayArgs, RelayConfig};
use lanparty_ctrl::{
ControlError, EndpointHello, PeerInfo, Reject, RejectReason, Role, RoomCode, ServerWelcome,
ControlError,
EndpointHello,
PeerInfo,
Reject,
RejectReason,
Role,
RoomCode,
ServerWelcome,
};
use lanparty_obs::{DropReason, FrameAction};
use lanparty_proto::{
EthernetFrame, MacAddr, ethernet_frame_exceeds_tap_mtu, gateway_lan_safety_drop_reason,
recommended_tap_mtu, remote_client_safety_drop_reason,
EthernetFrame,
MacAddr,
ethernet_frame_exceeds_tap_mtu,
gateway_lan_safety_drop_reason,
recommended_tap_mtu,
remote_client_safety_drop_reason,
};
use thiserror::Error;
pub use config::{ConfigError, DEFAULT_RELAY_PORT, ListenEndpoint, RelayArgs, RelayConfig};
pub use server::RelayServer;
use thiserror::Error;
pub const DEFAULT_MAX_CLIENTS_PER_ROOM: usize = 16;
const MEBIBYTE: u64 = 1024 * 1024;
@@ -769,9 +779,10 @@ fn reject_control_error(error: ControlError) -> Reject {
mod tests {
use std::time::{Duration, Instant};
use super::*;
use lanparty_proto::MAX_STANDARD_ETHERNET_FRAME_LEN;
use super::*;
fn room() -> RoomCode {
RoomCode::new("ABCD").unwrap()
}
+37 -11
View File
@@ -1,20 +1,42 @@
use std::{fs, net::SocketAddr, path::Path, sync::Arc};
use std::{collections::HashMap, fs, net::SocketAddr, path::Path, sync::Arc};
use anyhow::{Context, Result, anyhow, bail};
use bytes::Bytes;
use lanparty_ctrl::{
CONTROL_LENGTH_PREFIX_LEN, ControlCodecError, ControlMessage, DisconnectReason, EndpointHello,
MAX_CONTROL_MESSAGE_LEN, PeerInfo, RELAY_ALPN, Reject, RejectReason, Role, RoomCode,
ServerWelcome, decode_control_frame, encode_control_message,
CONTROL_LENGTH_PREFIX_LEN,
ControlCodecError,
ControlMessage,
DisconnectReason,
EndpointHello,
MAX_CONTROL_MESSAGE_LEN,
PeerInfo,
RELAY_ALPN,
Reject,
RejectReason,
Role,
RoomCode,
ServerWelcome,
decode_control_frame,
encode_control_message,
};
use lanparty_obs::{DropReason, FrameDirection, FrameLog, TunnelStats};
use lanparty_proto::{
EthernetFrame, FrameType, OVERLAY_FLAGS_NONE, decode_datagram, encode_datagram,
EthernetFrame,
FrameType,
OVERLAY_FLAGS_NONE,
decode_datagram,
encode_datagram,
};
use quinn::{
Endpoint,
Incoming,
RecvStream,
SendStream,
ServerConfig,
TransportConfig,
crypto::rustls::QuicServerConfig,
};
use quinn::crypto::rustls::QuicServerConfig;
use quinn::{Endpoint, Incoming, RecvStream, SendStream, ServerConfig, TransportConfig};
use rustls::pki_types::{CertificateDer, PrivateKeyDer, PrivatePkcs8KeyDer};
use std::collections::HashMap;
use tokio::sync::Mutex;
use crate::{ForwardingDecision, RelayConfig, RoomRegistry};
@@ -1014,13 +1036,17 @@ mod tests {
use lanparty_ctrl::{RoomCode, decode_control_frame, encode_control_message};
use lanparty_gateway::{GatewayConfig, connect_gateway};
use lanparty_proto::{
ETHERNET_HEADER_LEN, ETHERTYPE_IPV4, FrameType, MacAddr, decode_datagram, encode_datagram,
ETHERNET_HEADER_LEN,
ETHERTYPE_IPV4,
FrameType,
MacAddr,
decode_datagram,
encode_datagram,
};
use quinn::{ClientConfig, crypto::rustls::QuicClientConfig};
use crate::{DEFAULT_MAX_CLIENTS_PER_ROOM, ListenEndpoint};
use super::*;
use crate::{DEFAULT_MAX_CLIENTS_PER_ROOM, ListenEndpoint};
const ETHERTYPE_ARP: u16 = 0x0806;
const ARP_REQUEST: u16 = 1;