Skip to content

Commit

Permalink
temporarily support pre-0.5 and post 0.5 versions of the protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
poolpOrg committed Dec 9, 2019
1 parent 9531272 commit da8ed6b
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions filter-senderscore.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var junkBelow *int
var slowFactor *int
var scoreHeader *bool

var version string

type session struct {
id string

Expand Down Expand Up @@ -135,12 +137,20 @@ func dataline(phase string, sessionId string, params[] string) {
s := sessions[sessionId]
if s.first_line == true {
if (s.score != -1 && *scoreHeader) {
fmt.Printf("filter-dataline|%s|%s|X-SenderScore: %d\n", token, sessionId, s.score)
if version < "0.5" {
fmt.Printf("filter-dataline|%s|%s|X-SenderScore: %d\n", token, sessionId, s.score)
} else {
fmt.Printf("filter-dataline|%s|%s|X-SenderScore: %d\n", sessionId, token, s.score)
}
}
s.first_line = false
}
sessions[sessionId] = s
fmt.Printf("filter-dataline|%s|%s|%s\n", token, sessionId, line)
if version < "0.5" {
fmt.Printf("filter-dataline|%s|%s|%s\n", token, sessionId, line)
} else {
fmt.Printf("filter-dataline|%s|%s|%s\n", sessionId, token, line)
}
}

func delayedAnswer(phase string, sessionId string, params[] string) {
Expand Down Expand Up @@ -175,15 +185,23 @@ func waitThenAction(sessionId string, token string, delay int, action string) {
if (delay != -1) {
time.Sleep(time.Duration(delay) * time.Millisecond)
}
fmt.Printf("filter-result|%s|%s|%s\n", token, sessionId, action)
if version < "0.5" {
fmt.Printf("filter-result|%s|%s|%s\n", token, sessionId, action)
} else {
fmt.Printf("filter-result|%s|%s|%s\n", sessionId, token, action)
}
return
}

func waitThenDisconnect(sessionId string, token string, delay int) {
if (delay != -1) {
time.Sleep(time.Duration(delay) * time.Millisecond)
}
fmt.Printf("filter-result|%s|%s|disconnect|550 your IP reputation is too low for this MX\n", token, sessionId)
if version < "0.5" {
fmt.Printf("filter-result|%s|%s|disconnect|550 your IP reputation is too low for this MX\n", token, sessionId)
} else {
fmt.Printf("filter-result|%s|%s|disconnect|550 your IP reputation is too low for this MX\n", sessionId, token)
}
return
}

Expand Down Expand Up @@ -246,6 +264,8 @@ func main() {
os.Exit(1)
}

version = atoms[1]

switch atoms[0] {
case "report":
trigger(reporters, atoms)
Expand Down

0 comments on commit da8ed6b

Please sign in to comment.