Skip to content

Commit da8ed6b

Browse files
committed
temporarily support pre-0.5 and post 0.5 versions of the protocol
1 parent 9531272 commit da8ed6b

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

filter-senderscore.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var junkBelow *int
3535
var slowFactor *int
3636
var scoreHeader *bool
3737

38+
var version string
39+
3840
type session struct {
3941
id string
4042

@@ -135,12 +137,20 @@ func dataline(phase string, sessionId string, params[] string) {
135137
s := sessions[sessionId]
136138
if s.first_line == true {
137139
if (s.score != -1 && *scoreHeader) {
138-
fmt.Printf("filter-dataline|%s|%s|X-SenderScore: %d\n", token, sessionId, s.score)
140+
if version < "0.5" {
141+
fmt.Printf("filter-dataline|%s|%s|X-SenderScore: %d\n", token, sessionId, s.score)
142+
} else {
143+
fmt.Printf("filter-dataline|%s|%s|X-SenderScore: %d\n", sessionId, token, s.score)
144+
}
139145
}
140146
s.first_line = false
141147
}
142148
sessions[sessionId] = s
143-
fmt.Printf("filter-dataline|%s|%s|%s\n", token, sessionId, line)
149+
if version < "0.5" {
150+
fmt.Printf("filter-dataline|%s|%s|%s\n", token, sessionId, line)
151+
} else {
152+
fmt.Printf("filter-dataline|%s|%s|%s\n", sessionId, token, line)
153+
}
144154
}
145155

146156
func delayedAnswer(phase string, sessionId string, params[] string) {
@@ -175,15 +185,23 @@ func waitThenAction(sessionId string, token string, delay int, action string) {
175185
if (delay != -1) {
176186
time.Sleep(time.Duration(delay) * time.Millisecond)
177187
}
178-
fmt.Printf("filter-result|%s|%s|%s\n", token, sessionId, action)
188+
if version < "0.5" {
189+
fmt.Printf("filter-result|%s|%s|%s\n", token, sessionId, action)
190+
} else {
191+
fmt.Printf("filter-result|%s|%s|%s\n", sessionId, token, action)
192+
}
179193
return
180194
}
181195

182196
func waitThenDisconnect(sessionId string, token string, delay int) {
183197
if (delay != -1) {
184198
time.Sleep(time.Duration(delay) * time.Millisecond)
185199
}
186-
fmt.Printf("filter-result|%s|%s|disconnect|550 your IP reputation is too low for this MX\n", token, sessionId)
200+
if version < "0.5" {
201+
fmt.Printf("filter-result|%s|%s|disconnect|550 your IP reputation is too low for this MX\n", token, sessionId)
202+
} else {
203+
fmt.Printf("filter-result|%s|%s|disconnect|550 your IP reputation is too low for this MX\n", sessionId, token)
204+
}
187205
return
188206
}
189207

@@ -246,6 +264,8 @@ func main() {
246264
os.Exit(1)
247265
}
248266

267+
version = atoms[1]
268+
249269
switch atoms[0] {
250270
case "report":
251271
trigger(reporters, atoms)

0 commit comments

Comments
 (0)