ghassmo пре 4 година
родитељ
комит
05a6939950
2 измењених фајлова са 14 додато и 11 уклоњено
  1. 4 2
      bin/ircd/src/main.rs
  2. 10 9
      bin/ircd/src/server.rs

+ 4 - 2
bin/ircd/src/main.rs

@@ -79,7 +79,7 @@ impl Ircd {
             .detach();
     }
 
-    async fn process(
+    async fn process_new_connection(
         &self,
         executor: Arc<Executor<'_>>,
         stream: TcpStream,
@@ -109,6 +109,7 @@ impl Ircd {
             .spawn(async move {
                 loop {
                     let mut line = String::new();
+
                     let result: Result<()> = futures::select! {
                         msg = receiver.receive().fuse() => {
                             match conn.process_msg_from_p2p(&msg).await {
@@ -235,7 +236,8 @@ async fn realmain(settings: Args, executor: Arc<Executor<'_>>) -> Result<()> {
                     }
                 };
 
-                let result = ircd.process(executor_cloned.clone(), stream, peer_addr).await;
+                let result =
+                    ircd.process_new_connection(executor_cloned.clone(), stream, peer_addr).await;
 
                 if let Err(e) = result {
                     error!("Failed processing connection {}: {}", peer_addr, e);

+ 10 - 9
bin/ircd/src/server.rs

@@ -300,13 +300,15 @@ impl IrcServerConnection {
             }
 
             // Send dm messages in buffer
-            if !self.capabilities.get("no-history").unwrap() {
-                for msg in self.privmsgs_buffer.lock().await.to_vec() {
-                    if msg.target == self.nickname ||
-                        (msg.nickname == self.nickname && !msg.target.starts_with("#"))
-                    {
-                        self.senders.notify_by_id(msg, self.subscriber_id).await;
-                    }
+            if *self.capabilities.get("no-history").unwrap() {
+                return Ok(())
+            }
+
+            for msg in self.privmsgs_buffer.lock().await.to_vec() {
+                if msg.target == self.nickname ||
+                    (msg.nickname == self.nickname && !msg.target.starts_with("#"))
+                {
+                    self.senders.notify_by_id(msg, self.subscriber_id).await;
                 }
             }
         }
@@ -363,6 +365,7 @@ impl IrcServerConnection {
             (*self.seen_msg_ids.lock().await).push(random_id);
             (*self.privmsgs_buffer.lock().await).push(protocol_msg.clone())
         }
+
         self.senders.notify_with_exclude(protocol_msg.clone(), &[self.subscriber_id]).await;
 
         debug!(target: "ircd", "PRIVMSG to be sent: {:?}", protocol_msg);
@@ -469,8 +472,6 @@ impl IrcServerConnection {
         info!("Received msg from IRC client: {:?}", line);
         let irc_msg = self.clean_input_line(line)?;
 
-        info!("Send msg to IRC client '{}' from {}", irc_msg, self.peer_address);
-
         if let Err(e) = self.update(irc_msg).await {
             warn!("Connection error: {} for {}", e, self.peer_address);
             return Err(Error::ChannelStopped)