From cd7556264e29acf6885afd5481fb20d3a71f085b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 6 Feb 2020 22:19:31 +0100 Subject: [PATCH] Forward channel information --- downstream.go | 8 ++++++++ upstream.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/downstream.go b/downstream.go index a01b382..a4cc6fc 100644 --- a/downstream.go +++ b/downstream.go @@ -73,6 +73,14 @@ func newDownstreamConn(srv *Server, netConn net.Conn) *downstreamConn { return conn } +func (c *downstreamConn) prefix() *irc.Prefix { + return &irc.Prefix{ + Name: c.nick, + User: c.username, + // TODO: fill the host? + } +} + func (c *downstreamConn) readMessages() error { c.logger.Printf("new connection") defer c.Close() diff --git a/upstream.go b/upstream.go index a65c0ab..6d7087b 100644 --- a/upstream.go +++ b/upstream.go @@ -168,6 +168,12 @@ func (c *upstreamConn) handleMessage(msg *irc.Message) error { } ch.complete = true + + c.srv.lock.Lock() + for _, dc := range c.srv.downstreamConns { + forwardChannel(dc, ch) + } + c.srv.lock.Unlock() case irc.RPL_YOURHOST, irc.RPL_CREATED: // Ignore case irc.RPL_LUSERCLIENT, irc.RPL_LUSEROP, irc.RPL_LUSERUNKNOWN, irc.RPL_LUSERCHANNELS, irc.RPL_LUSERME: