From b9d3b7ea9df409794eefe48ae1003e8444f519bb Mon Sep 17 00:00:00 2001 From: bt Date: Wed, 8 Apr 2026 13:37:56 +0200 Subject: [daemon] Server to server communication --- server/server.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'server/server.go') diff --git a/server/server.go b/server/server.go index 3876bac..712f654 100644 --- a/server/server.go +++ b/server/server.go @@ -168,7 +168,7 @@ func (s *Server) handleMessage(conn net.Conn, user User, msg core.Message) error return s.handleLocalMessage(channel, msg) } - return core.ErrNotSupported + return s.handleOutboundMessage(channel, host, msg) } func (s *Server) handleLocalMessage(channel string, msg core.Message) error { @@ -179,3 +179,24 @@ func (s *Server) handleLocalMessage(channel string, msg core.Message) error { return user.Send(msg) } + +func (s *Server) handleOutboundMessage(channel, host string, msg core.Message) error { + conn, err := net.Dial("tcp", host+":9999") + if err != nil { + return err + } + defer conn.Close() + + hs := core.Handshake{0, 1} + if err := core.Send(conn, hs); err != nil { + return err + } + + // TODO, servers should not use this type of auth + auth := core.Auth{"server", "valid"} + if err := core.Send(conn, auth); err != nil { + return err + } + + return core.Send(conn, msg) +} -- cgit v1.2.3