-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmtpd.go
94 lines (79 loc) · 1.86 KB
/
smtpd.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package opensmtpd
import (
"fmt"
"os"
"strings"
)
const (
// FilterVersion is the supported filter API version
FilterVersion = 52
// QueueVersion is the supported queue API version
QueueVersion = 2
// TableVersion is the supported table API version
TableVersion = 2
)
var (
// Debug flag
Debug bool
prog = os.Args[0]
)
// Services
const (
ServiceNone = 0x000
ServiceAlias = 0x001
ServiceDomain = 0x002
ServiceCredentials = 0x004
ServiceNetaddr = 0x008
ServiceUserinfo = 0x010
ServiceSource = 0x020
ServiceMailaddr = 0x040
ServiceAddrname = 0x080
ServiceMailaddrMap = 0x100
ServiceRelayHost = 0x200
ServiceString = 0x400
ServiceAny = 0xfff
)
var serviceTypeName = map[int]string{
ServiceAlias: "alias",
ServiceDomain: "domain",
ServiceCredentials: "credentials",
ServiceNetaddr: "netaddr",
ServiceUserinfo: "userinfo",
ServiceSource: "source",
ServiceMailaddr: "mailaddr",
ServiceAddrname: "addrname",
ServiceMailaddrMap: "maddrmap",
ServiceRelayHost: "relayhost",
ServiceString: "string",
}
func serviceName(service int) string {
var s []string
for i := 1; i <= service; i <<= 1 {
if k := service & i; k != 0 {
s = append(s, serviceTypeName[k])
}
}
return strings.Join(s, ",")
}
func debugf(format string, v ...interface{}) {
if !Debug {
return
}
line := strings.TrimSuffix(fmt.Sprintf(format, v...), "\n")
fmt.Fprintln(os.Stderr, prog+": debug: "+line)
}
func fatal(v ...interface{}) {
line := strings.TrimSuffix(fmt.Sprint(v...), "\n")
fmt.Fprintln(os.Stderr, prog+": "+line)
os.Exit(1)
}
func fatalf(format string, v ...interface{}) {
line := strings.TrimSuffix(fmt.Sprintf(format, v...), "\n")
fmt.Fprintln(os.Stderr, prog+": "+line)
os.Exit(1)
}
const (
maxLineSize = 2048
)
// Dict is a key-value mapping
type Dict map[string]interface{}