From dce03955174abe5ad83c01c930e3bf47fe39d8ce Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 30 Dec 2024 01:23:40 +0000 Subject: Revamp --- servers.go | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 servers.go (limited to 'servers.go') diff --git a/servers.go b/servers.go deleted file mode 100644 index af31093..0000000 --- a/servers.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "net" - - "git.sr.ht/~runxiyu/meseircd/meselog" -) - -type Server struct { - conn *net.Conn - SID uint32 - Name string -} - -func (server *Server) Send(msg SMsg) error { - return server.SendRaw(msg.ServerSerialize()) -} - -func (server *Server) SendRaw(s string) error { - if server == self { - return ErrSendToSelf - } - if server.conn == nil { - // TODO: Propagate across mesh - return ErrNotConnectedServer - } - meselog.Debug("send", "line", s, "conn", server.conn) - _, err := (*server.conn).Write([]byte(s)) - if err != nil { - // TODO: Should shut down the netFd instead but the stdlib - // doesn't expose a way to do this. - (*server.conn).Close() - return err - } - return nil -} - -func (server *Server) ClientSource() string { - return server.Name -} - -func (server *Server) ServerSource() uint64 { - return uint64(server.SID) << 32 -} - -var self *Server -- cgit v1.2.3