refact: refactored module parameters api

This commit is contained in:
evilsocket 2018-01-11 00:27:53 +01:00
commit e543582257
12 changed files with 111 additions and 198 deletions

View file

@ -79,6 +79,9 @@ func (p ModuleParam) Validate(value string) (error, interface{}) {
return fmt.Errorf("Unhandled module parameter type %d.", p.Type), nil
}
const ParamIfaceAddress = "<interface address>"
const ParamSubnet = "<entire subnet>"
func (p ModuleParam) Get(s *Session) (error, interface{}) {
var v string
var found bool
@ -89,6 +92,12 @@ func (p ModuleParam) Get(s *Session) (error, interface{}) {
v = ""
}
if v == ParamIfaceAddress {
v = s.Interface.IpAddress
} else if v == ParamSubnet {
v = s.Interface.CIDR()
}
err, obj = p.Validate(v)
return err, obj