|
@@ -11,6 +11,7 @@ import (
|
11
|
11
|
"fmt"
|
12
|
12
|
"io/ioutil"
|
13
|
13
|
"log"
|
|
14
|
+ "strings"
|
14
|
15
|
|
15
|
16
|
"gopkg.in/yaml.v2"
|
16
|
17
|
)
|
|
@@ -68,14 +69,16 @@ type AccountRegistrationConfig struct {
|
68
|
69
|
|
69
|
70
|
type OperClassConfig struct {
|
70
|
71
|
Title string
|
|
72
|
+ WhoisLine string
|
71
|
73
|
Extends string
|
72
|
74
|
Capabilities []string
|
73
|
75
|
}
|
74
|
76
|
|
75
|
77
|
type OperConfig struct {
|
76
|
|
- Class string
|
77
|
|
- Vhost string
|
78
|
|
- Password string
|
|
78
|
+ Class string
|
|
79
|
+ Vhost string
|
|
80
|
+ WhoisLine string `yaml:"whois-line"`
|
|
81
|
+ Password string
|
79
|
82
|
}
|
80
|
83
|
|
81
|
84
|
func (conf *OperConfig) PasswordBytes() []byte {
|
|
@@ -130,6 +133,7 @@ type Config struct {
|
130
|
133
|
|
131
|
134
|
type OperClass struct {
|
132
|
135
|
Title string
|
|
136
|
+ WhoisLine string `yaml:"whois-line"`
|
133
|
137
|
Capabilities map[string]bool // map to make lookups much easier
|
134
|
138
|
}
|
135
|
139
|
|
|
@@ -179,6 +183,16 @@ func (conf *Config) OperatorClasses() (*map[string]OperClass, error) {
|
179
|
183
|
for _, capab := range info.Capabilities {
|
180
|
184
|
oc.Capabilities[capab] = true
|
181
|
185
|
}
|
|
186
|
+ if len(info.WhoisLine) > 0 {
|
|
187
|
+ oc.WhoisLine = info.WhoisLine
|
|
188
|
+ } else {
|
|
189
|
+ oc.WhoisLine = "is a"
|
|
190
|
+ if strings.Contains(strings.ToLower(string(oc.Title[0])), "aeiou") {
|
|
191
|
+ oc.WhoisLine += "n"
|
|
192
|
+ }
|
|
193
|
+ oc.WhoisLine += " "
|
|
194
|
+ oc.WhoisLine += oc.Title
|
|
195
|
+ }
|
182
|
196
|
|
183
|
197
|
ocs[name] = oc
|
184
|
198
|
}
|
|
@@ -193,8 +207,9 @@ func (conf *Config) OperatorClasses() (*map[string]OperClass, error) {
|
193
|
207
|
}
|
194
|
208
|
|
195
|
209
|
type Oper struct {
|
196
|
|
- Class *OperClass
|
197
|
|
- Pass []byte
|
|
210
|
+ Class *OperClass
|
|
211
|
+ WhoisLine string
|
|
212
|
+ Pass []byte
|
198
|
213
|
}
|
199
|
214
|
|
200
|
215
|
func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error) {
|
|
@@ -214,6 +229,11 @@ func (conf *Config) Operators(oc *map[string]OperClass) (map[string]Oper, error)
|
214
|
229
|
return nil, fmt.Errorf("Could not load operator [%s] - they use operclass [%s] which does not exist", name, opConf.Class)
|
215
|
230
|
}
|
216
|
231
|
oper.Class = &class
|
|
232
|
+ if len(opConf.WhoisLine) > 0 {
|
|
233
|
+ oper.WhoisLine = opConf.WhoisLine
|
|
234
|
+ } else {
|
|
235
|
+ oper.WhoisLine = class.WhoisLine
|
|
236
|
+ }
|
217
|
237
|
|
218
|
238
|
// successful, attach to list of opers
|
219
|
239
|
operators[name] = oper
|