bin/ircd: clean up functions parameters

This commit is contained in:
ghassmo
2022-06-17 02:57:47 +03:00
parent 3b0575d0b0
commit ec397fc9ad
2 changed files with 18 additions and 10 deletions

View File

@@ -81,13 +81,17 @@ async fn broadcast_msg(
}
async fn process(
p2p_receiver: Receiver<Privmsg>,
// server
stream: TcpStream,
peer_addr: SocketAddr,
p2p: net::P2pPtr,
// msg ids
seen_msg_ids: SeenMsgIds,
// channels
autojoin_chans: Vec<String>,
configured_chans: FxHashMap<String, ChannelInfo>,
// p2p
p2p: net::P2pPtr,
p2p_receiver: Receiver<Privmsg>,
) -> Result<()> {
let (reader, writer) = stream.split();
@@ -95,9 +99,9 @@ async fn process(
let mut conn = IrcServerConnection::new(
writer,
seen_msg_ids.clone(),
p2p.clone(),
autojoin_chans,
configured_chans,
p2p.clone(),
);
loop {
@@ -211,13 +215,13 @@ async fn realmain(settings: Args, executor: Arc<Executor<'_>>) -> Result<()> {
executor_cloned
.spawn(process(
p2p_recv_channel.clone(),
stream,
peer_addr,
p2p.clone(),
seen_msg_ids.clone(),
settings.autojoin.clone(),
configured_chans.clone(),
p2p.clone(),
p2p_recv_channel.clone(),
))
.detach();
}

View File

@@ -18,35 +18,39 @@ const RPL_NOTOPIC: u32 = 331;
const RPL_TOPIC: u32 = 332;
pub struct IrcServerConnection {
// server stream
write_stream: WriteHalf<TcpStream>,
// msg ids
seen_msg_ids: SeenMsgIds,
// user & channels
is_nick_init: bool,
is_user_init: bool,
is_registered: bool,
nickname: String,
seen_msg_ids: SeenMsgIds,
p2p: P2pPtr,
auto_channels: Vec<String>,
pub configured_chans: FxHashMap<String, ChannelInfo>,
// p2p
p2p: P2pPtr,
}
impl IrcServerConnection {
pub fn new(
write_stream: WriteHalf<TcpStream>,
seen_msg_ids: SeenMsgIds,
p2p: P2pPtr,
auto_channels: Vec<String>,
configured_chans: FxHashMap<String, ChannelInfo>,
p2p: P2pPtr,
) -> Self {
Self {
write_stream,
seen_msg_ids,
is_nick_init: false,
is_user_init: false,
is_registered: false,
nickname: "anon".to_string(),
seen_msg_ids,
p2p,
auto_channels,
configured_chans,
p2p,
}
}