Skip to content

Commit 9ca62bc

Browse files
committed
Add configuration fields for security, pushover, and status management
1 parent 556bf71 commit 9ca62bc

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

config/config_getset.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,97 @@ func (d *Configuration) TranslationPortString() string {
175175
func (d *Configuration) MaxEntries() int {
176176
return d.History.MaxEntries
177177
}
178+
179+
func (d *Configuration) PushoverUserKey() string {
180+
return d.Pushover.UserKey
181+
}
182+
183+
func (d *Configuration) PushoverAPIToken() string {
184+
return d.Pushover.APIToken
185+
}
186+
187+
func (d *Configuration) StatusUNKNOWN() string {
188+
if d.Status.UNKNOWN == "" {
189+
return "UNKN"
190+
}
191+
return d.Status.UNKNOWN
192+
}
193+
194+
func (d *Configuration) StatusONLINE() string {
195+
if d.Status.ONLINE == "" {
196+
return "ONLN"
197+
}
198+
return d.Status.ONLINE
199+
}
200+
201+
func (d *Configuration) StatusOFFLINE() string {
202+
if d.Status.OFFLINE == "" {
203+
return "OFLN"
204+
}
205+
return d.Status.OFFLINE
206+
}
207+
208+
func (d *Configuration) StatusERROR() string {
209+
if d.Status.ERROR == "" {
210+
return "ERRO"
211+
}
212+
return d.Status.ERROR
213+
}
214+
215+
func (d *Configuration) StatusWARNING() string {
216+
if d.Status.WARNING == "" {
217+
return "WARN"
218+
}
219+
return d.Status.WARNING
220+
}
221+
222+
func (d *Configuration) SecurityServiceUserName() string {
223+
return d.Security.ServiceUserName
224+
}
225+
226+
func (d *Configuration) SecurityServiceUserCode() string {
227+
return d.Security.ServiceUserCode
228+
}
229+
230+
func (d *Configuration) SecuritySessionExpiryPeriod() int {
231+
return d.Security.SessionExpiry
232+
}
233+
234+
func (d *Configuration) SecuritySessionUserCodeKey() string {
235+
return d.Security.SessionUserCodeKey
236+
}
237+
238+
func (d *Configuration) SecuritySessionUserIDKey() string {
239+
return d.Security.SessionUserIDKey
240+
}
241+
242+
func (d *Configuration) SecuritySessionExpiryKey() string {
243+
return d.Security.SessionExpiryKey
244+
}
245+
246+
func (d *Configuration) SecuritySessionTokenKey() string {
247+
return d.Security.SessionTokenKey
248+
}
249+
250+
func (d *Configuration) SecuritySessionKey() string {
251+
return d.Security.SessionKeyName
252+
}
253+
254+
func (d *Configuration) GetValidOrigins() []string {
255+
var origins []string
256+
for _, v := range d.AllowedOrigins {
257+
if v.Name != "" {
258+
origins = append(origins, v.Name)
259+
}
260+
}
261+
return origins
262+
}
263+
264+
func (d *Configuration) GetValidHosts() []struct {
265+
Name string "toml:\"name\""
266+
FQDN string "toml:\"fqdn\""
267+
IP string "toml:\"ip\""
268+
Zone string "toml:\"zone\""
269+
} {
270+
return d.Hosts
271+
}

config/config_model.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ type Configuration struct {
4444
History struct {
4545
MaxEntries int `toml:"maxEntries"`
4646
} `toml:"History"`
47+
Hosts []struct {
48+
Name string `toml:"name"`
49+
FQDN string `toml:"fqdn"`
50+
IP string `toml:"ip"`
51+
Zone string `toml:"zone"`
52+
} `toml:"Hosts"`
53+
Security struct {
54+
SessionKeyName string `toml:"sessionKey"`
55+
SessionUserIDKey string `toml:"sessionUserIDKey"`
56+
SessionUserCodeKey string `toml:"sessionUserCodeKey"`
57+
SessionTokenKey string `toml:"sessionTokenKey"`
58+
SessionExpiry int `toml:"sessionExpiry"`
59+
ServiceUserName string `toml:"serviceUserName"`
60+
ServiceUserCode string `toml:"serviceUserCode"`
61+
SessionExpiryKey string `toml:"sessionExpiryKey"`
62+
} `toml:"Security"`
4763
Message struct {
4864
TypeKey string `toml:"typeKey"`
4965
TitleKey string `toml:"titleKey"`
@@ -53,4 +69,18 @@ type Configuration struct {
5369
Display struct {
5470
Delimiter string `toml:"delim"`
5571
} `toml:"Display"`
72+
Pushover struct {
73+
UserKey string `toml:"userKey"`
74+
APIToken string `toml:"apiToken"`
75+
} `toml:"Pushover"`
76+
Status struct {
77+
UNKNOWN string `toml:"unknown"`
78+
ONLINE string `toml:"online"`
79+
OFFLINE string `toml:"offline"`
80+
ERROR string `toml:"error"`
81+
WARNING string `toml:"warning"`
82+
} `toml:"Status"`
83+
AllowedOrigins []struct {
84+
Name string `toml:"name"`
85+
} `toml:"Origins"`
5686
}

0 commit comments

Comments
 (0)