1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

gofmt on smtpd

This commit is contained in:
James Hillyerd
2012-10-07 17:04:39 -07:00
parent cb388e94b2
commit cbba067673
2 changed files with 295 additions and 298 deletions

View File

@@ -35,7 +35,7 @@ func (s State) String() string {
return "Unknown" return "Unknown"
} }
var commands = map[string] bool { var commands = map[string]bool{
"HELO": true, "HELO": true,
"MAIL": true, "MAIL": true,
"RCPT": true, "RCPT": true,
@@ -273,7 +273,7 @@ func (ss *Session) greet() {
// Calculate the next read or write deadline based on maxIdleSeconds // Calculate the next read or write deadline based on maxIdleSeconds
func (ss *Session) nextDeadline() time.Time { func (ss *Session) nextDeadline() time.Time {
return time.Now().Add(time.Duration(ss.server.maxIdleSeconds)*time.Second) return time.Now().Add(time.Duration(ss.server.maxIdleSeconds) * time.Second)
} }
// Send requested message, store errors in Session.sendError // Send requested message, store errors in Session.sendError
@@ -282,7 +282,7 @@ func (ss *Session) send(msg string) {
ss.sendError = err ss.sendError = err
return return
} }
if _, err := fmt.Fprint(ss.conn, msg + "\r\n"); err != nil { if _, err := fmt.Fprint(ss.conn, msg+"\r\n"); err != nil {
ss.sendError = err ss.sendError = err
ss.error("Failed to send: \"%v\"", msg) ss.error("Failed to send: \"%v\"", msg)
return return
@@ -342,20 +342,18 @@ func (ss *Session) ooSeq(cmd string) {
} }
// Session specific logging methods // Session specific logging methods
func (ss *Session) trace(msg string, args ...interface {}) { func (ss *Session) trace(msg string, args ...interface{}) {
ss.server.trace("<%v> %v", ss.id, fmt.Sprintf(msg, args...)) ss.server.trace("<%v> %v", ss.id, fmt.Sprintf(msg, args...))
} }
func (ss *Session) info(msg string, args ...interface {}) { func (ss *Session) info(msg string, args ...interface{}) {
ss.server.info("<%v> %v", ss.id, fmt.Sprintf(msg, args...)) ss.server.info("<%v> %v", ss.id, fmt.Sprintf(msg, args...))
} }
func (ss *Session) warn(msg string, args ...interface {}) { func (ss *Session) warn(msg string, args ...interface{}) {
ss.server.warn("<%v> %v", ss.id, fmt.Sprintf(msg, args...)) ss.server.warn("<%v> %v", ss.id, fmt.Sprintf(msg, args...))
} }
func (ss *Session) error(msg string, args ...interface {}) { func (ss *Session) error(msg string, args ...interface{}) {
ss.server.error("<%v> %v", ss.id, fmt.Sprintf(msg, args...)) ss.server.error("<%v> %v", ss.id, fmt.Sprintf(msg, args...))
} }

View File

@@ -19,19 +19,19 @@ func New(domain string, port int) *Server {
} }
// Loggers // Loggers
func (s *Server) trace(msg string, args ...interface {}) { func (s *Server) trace(msg string, args ...interface{}) {
fmt.Printf("[trace] %s\n", fmt.Sprintf(msg, args...)) fmt.Printf("[trace] %s\n", fmt.Sprintf(msg, args...))
} }
func (s *Server) info(msg string, args ...interface {}) { func (s *Server) info(msg string, args ...interface{}) {
fmt.Printf("[info ] %s\n", fmt.Sprintf(msg, args...)) fmt.Printf("[info ] %s\n", fmt.Sprintf(msg, args...))
} }
func (s *Server) warn(msg string, args ...interface {}) { func (s *Server) warn(msg string, args ...interface{}) {
fmt.Printf("[warn ] %s\n", fmt.Sprintf(msg, args...)) fmt.Printf("[warn ] %s\n", fmt.Sprintf(msg, args...))
} }
func (s *Server) error(msg string, args ...interface {}) { func (s *Server) error(msg string, args ...interface{}) {
fmt.Printf("[error] %s\n", fmt.Sprintf(msg, args...)) fmt.Printf("[error] %s\n", fmt.Sprintf(msg, args...))
} }
@@ -51,4 +51,3 @@ func (s *Server) Start() {
} }
} }
} }