forked from pedrinimm/gomilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
samplefilter.go
48 lines (34 loc) · 922 Bytes
/
samplefilter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// +build ignore
/*
Copyright (c) 2015 Leon Baker
This projected is licensed under the terms of the MIT License.
Sample Milter
*/
package main
import (
"."
"fmt"
)
type Mymilter struct {
gomilter.MilterRaw // Embed the basic functionality. No callbacks yet
}
// Define the callback functions we are going to use
func (m *Mymilter) Connect(ctx uintptr, hostname, ip string) (sfsistat int8) {
fmt.Println("mymilter.connect was called")
fmt.Printf("hostname: %s\n", hostname)
fmt.Printf("ip: %s\n", ip)
return gomilter.Reject
}
func (m *Mymilter) Helo(ctx uintptr, helohost string) (sfsistat int8) {
fmt.Println("mymilter.helo was called")
return
}
func main() {
mymilter := new(Mymilter)
mymilter.FilterName = "TestFilter"
mymilter.Debug = true
mymilter.Flags = gomilter.ADDHDRS | gomilter.ADDRCPT
mymilter.Socket = "unix:/var/milterattachcheck/socket"
// Start Milter
gomilter.Run(mymilter)
}