warnings fix

This commit is contained in:
2026-03-20 15:36:56 +07:00
parent 1e5c8e899b
commit 4b3b1ef67b
20 changed files with 46 additions and 89 deletions
-2
View File
@@ -56,7 +56,6 @@ pub struct SessionKeys {
pub ecdh: ECDH,
pub auth_key: [u8; 32],
pub current_aead: Option<([u8; 32], [u8; 12], [u8; 32], [u8; 12])>,
is_initiator: bool,
}
impl SessionKeys {
@@ -66,7 +65,6 @@ impl SessionKeys {
ecdh: ECDH::new(),
auth_key: [0u8; 32],
current_aead: None,
is_initiator,
}
}
+1 -1
View File
@@ -117,7 +117,7 @@ impl TlsInterceptor for ApplicationData {
));
}
Ok(Some(ApplicationData {
len: record.payload.len(),
_len: record.payload.len(),
payload: record.payload,
}))
}
+1 -1
View File
@@ -1,4 +1,4 @@
use bytes::{BufMut, Bytes, BytesMut};
use bytes::{BufMut, BytesMut};
use crate::protocol::parser::parser::Parser;
+7 -7
View File
@@ -71,12 +71,12 @@ impl Parser for ApplicationData {
}
fn parse(bytes: &mut BytesMut) -> Result<Option<Self>, Self::Error> {
let len = bytes.len();
if len == 0 {
let _len = bytes.len();
if _len == 0 {
return Ok(None);
}
let payload = bytes.split_to(len).freeze();
Ok(Some(Self { len, payload }))
let payload = bytes.split_to(_len).freeze();
Ok(Some(Self { _len, payload }))
}
}
@@ -104,7 +104,7 @@ impl Parser for HelloHeader {
Ok(Some(Self {
header_type,
len: U24::from_u32(len),
_len: U24::from_u32(len),
}))
}
}
@@ -157,7 +157,7 @@ impl Parser for ClientHello {
return Ok(None);
}
let version = ProtocolVersion::try_from(bytes.get_u16())
let _version = ProtocolVersion::try_from(bytes.get_u16())
.map_err(|e| TlsError::new(ErrorStage::Tls(e), ErrorAction::Drop, Bytes::new()))?;
let mut random = [0u8; 32];
@@ -184,7 +184,7 @@ impl Parser for ClientHello {
};
Ok(Some(Self {
version,
_version,
random,
session_id,
cipher_suites,
+3 -7
View File
@@ -16,9 +16,8 @@ use crate::{
},
tlseng::profile::BrowserProfile,
};
use bytes::{Bytes, BytesMut};
use netrunner_logger::{debug, error, info, trace, warn};
use std::net::SocketAddr;
use bytes::BytesMut;
use netrunner_logger::info;
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
net::{
@@ -43,7 +42,6 @@ pub trait TunnelHandler {
}
pub struct Connection {
addr: SocketAddr,
pub inbound: OwnedReadHalf,
pub outbound: OwnedWriteHalf,
pub read_buf: BytesMut,
@@ -51,10 +49,9 @@ pub struct Connection {
}
impl Connection {
pub fn new(stream: TcpStream, addr: SocketAddr, init: bool) -> Self {
pub fn new(stream: TcpStream, init: bool) -> Self {
let (inbound, outbound) = stream.into_split();
Self {
addr,
inbound,
outbound,
read_buf: BytesMut::with_capacity(BUF_SIZE),
@@ -64,7 +61,6 @@ impl Connection {
pub fn new_raw(inbound: OwnedReadHalf, outbound: OwnedWriteHalf) -> Self {
Self {
addr: "0.0.0.0:0".parse().unwrap(),
inbound,
outbound,
read_buf: BytesMut::with_capacity(BUF_SIZE),
+3 -3
View File
@@ -62,8 +62,8 @@ impl Network {
tokio::select! {
_ = token.cancelled() => break,
res = listener.accept() => {
if let Ok((stream, client_addr)) = res {
let conn = Connection::new(stream, client_addr, false);
if let Ok((stream, _client_addr)) = res {
let conn = Connection::new(stream, false);
let handler = ClientHandler{ conn, muxer: muxer.clone() };
tokio::spawn(async move {
if let Err(e) = handler.run().await {
@@ -82,7 +82,7 @@ impl Network {
_ = token.cancelled() => break,
res = listener.accept() => {
if let Ok((stream, client_addr)) = res {
let conn = Connection::new(stream, client_addr, true);
let conn = Connection::new(stream, true);
let handler = ServerHandler { conn, token: token.clone() };
tokio::spawn(async move {
if let Err(e) = handler.run().await {
-5
View File
@@ -8,8 +8,3 @@ pub const PSK_DHE_KE_MODE: u8 = 0x01;
pub const CERT_COMPRESSION_BROTLI: u16 = 0x0002;
pub const OCSP_STATUS_TYPE: u8 = 0x01;
pub const GREASE_IDENTIFIERS: [u16; 16] = [
0x0A0A, 0x1A1A, 0x2A2A, 0x3A3A, 0x4A4A, 0x5A5A, 0x6A6A, 0x7A7A, 0x8A8A, 0x9A9A, 0xAAAA, 0xBABA,
0xCACA, 0xDADA, 0xEAEA, 0xFAFA,
];
+2 -13
View File
@@ -1,11 +1,7 @@
use bytes::{BufMut, Bytes, BytesMut};
use rand::RngExt;
use crate::tlseng::{
consts::{
CERT_COMPRESSION_BROTLI, GREASE_IDENTIFIERS, OCSP_STATUS_TYPE, PSK_DHE_KE_MODE,
TYPE_HOST_NAME,
},
consts::{CERT_COMPRESSION_BROTLI, OCSP_STATUS_TYPE, PSK_DHE_KE_MODE, TYPE_HOST_NAME},
profile::BrowserProfile,
types::{TlsExtensions, TlsGroups, TlsSignatures, TlsVersions},
};
@@ -58,18 +54,11 @@ impl ExtensionBuilder {
self.payload.put_slice(data);
}
pub fn grease(&mut self) {
let mut rng = rand::rng();
let rnd = rng.random_range(0..GREASE_IDENTIFIERS.len());
let etype = GREASE_IDENTIFIERS[rnd];
self.add_extension(etype, &[]);
}
pub fn grease_with_id(&mut self, etype: u16) {
self.add_extension(etype, &[]);
}
pub fn apply_generic_extension(&mut self, etype: u16, profile: &BrowserProfile) {
pub fn apply_generic_extension(&mut self, etype: u16, _profile: &BrowserProfile) {
match etype {
_ => {
netrunner_logger::trace!(etype, "Applying generic or unknown extension");
+4 -4
View File
@@ -8,18 +8,18 @@ use crate::{
extension::ExtensionBuilder,
profile::{BrowserProfile, ServerProfile},
tls_record::TlsRecord,
types::{ContentType, HelloType, ProtocolVersion, TlsVersions},
types::{ContentType, HelloType, ProtocolVersion},
},
utils::u24::U24,
};
pub struct HelloHeader {
pub header_type: HelloType,
pub len: U24,
pub _len: U24,
}
pub struct ClientHello {
pub version: ProtocolVersion,
pub _version: ProtocolVersion,
pub random: [u8; 32],
@@ -88,7 +88,7 @@ impl ClientHello {
let extensions_bytes = ext_builder.build();
let client_hello = ClientHello {
version: ProtocolVersion::Tls12,
_version: ProtocolVersion::Tls12,
random: tls_random,
session_id: Bytes::copy_from_slice(&session_id_bytes),
cipher_suites: profile.cipher_suites.to_vec(),
+1 -1
View File
@@ -1,7 +1,7 @@
use bytes::Bytes;
pub struct ApplicationData {
pub len: usize,
pub _len: usize,
pub payload: Bytes,
}
+8 -12
View File
@@ -64,31 +64,27 @@ impl BrowserProfile {
}
pub struct ServerProfile {
pub name: &'static str,
pub versions: TlsVersions,
pub record_layer_version: ProtocolVersion,
pub cipher_suites: &'static [u16],
pub groups: TlsGroups,
pub signatures: TlsSignatures,
pub alpn: &'static [&'static str],
pub session_tickets: bool,
pub _groups: TlsGroups,
pub _signatures: TlsSignatures,
pub _alpn: &'static [&'static str],
pub _session_tickets: bool,
pub honor_cipher_order: bool,
}
impl ServerProfile {
pub const MODERN: Self = Self {
name: "Modern-Secure",
versions: TlsVersions::MODERN,
record_layer_version: ProtocolVersion::Tls12,
cipher_suites: &[0x1301, 0x1302, 0x1303],
groups: TlsGroups::MODERN,
signatures: TlsSignatures::BROWSER_STANDARD,
alpn: &["h2", "http/1.1"],
session_tickets: true,
_groups: TlsGroups::MODERN,
_signatures: TlsSignatures::BROWSER_STANDARD,
_alpn: &["h2", "http/1.1"],
_session_tickets: true,
honor_cipher_order: true,
};
}
+2 -2
View File
@@ -8,7 +8,7 @@ pub struct TlsRecord {
pub version: ProtocolVersion,
pub len: u16,
pub _len: u16,
pub payload: Bytes,
}
@@ -18,7 +18,7 @@ impl TlsRecord {
Self {
content_type,
version,
len: payload.len() as u16,
_len: payload.len() as u16,
payload,
}
}
+2 -2
View File
@@ -9,11 +9,11 @@ impl U24 {
U24([b[1], b[2], b[3]])
}
pub fn to_u32(&self) -> u32 {
pub fn _to_u32(&self) -> u32 {
u32::from_be_bytes([0, self.0[0], self.0[1], self.0[2]])
}
pub fn from_slice(slice: &[u8]) -> u32 {
pub fn _from_slice(slice: &[u8]) -> u32 {
u32::from_be_bytes([0, slice[0], slice[1], slice[2]])
}
}