Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smtp responses fixed and random wait added #63

Merged
merged 3 commits into from
May 16, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"time"
)

// maximum lines that can be read after the "DATA" command
var maxDataRead int = 500
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not constant?

Copy link
Contributor Author

@HashCode55 HashCode55 Apr 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a commit like 10 seconds before you commented haha


// Client is a connection container
type Client struct {
conn net.Conn
Expand Down Expand Up @@ -75,7 +78,13 @@ func (g *Glutton) HandleSMTP(conn net.Conn) {
client.w("250 OK")
} else if strings.Compare(query, "DATA") == 0 {
client.w("354 End data with <CRLF>.<CRLF>")
for strings.Compare(client.r(g), ".\r\n") != 0 {
for readctr := maxDataRead; readctr >= 0; readctr -= 1 {
data := client.r(g)
g.logger.Infof("[smtp ] Data : %q", data)
// exit condition
if strings.Compare(data, ".\r\n") == 0 {
break
}
}
rwait()
client.w("250 OK")
Expand Down