diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/socket.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/socket.go b/lib/socket.go index ae1ce339..902a7be2 100644 --- a/lib/socket.go +++ b/lib/socket.go @@ -21,6 +21,7 @@ type AercServer struct { logger *log.Logger listener net.Listener OnMailto func(addr *url.URL) error + OnMbox func(source string) error } func StartServer(logger *log.Logger) (*AercServer, error) { @@ -92,6 +93,16 @@ func (as *AercServer) handleClient(conn net.Conn) { } else { conn.Write([]byte("result: success\n")) } + case "mbox": + var err error + if as.OnMbox != nil { + err = as.OnMbox(msg) + } + if err != nil { + conn.Write([]byte(fmt.Sprintf("result: %v\n", err))) + } else { + conn.Write([]byte("result: success\n")) + } } } as.logger.Printf("Closed Unix connection %d", clientId) |