mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
refact: refactored module parameters api
This commit is contained in:
parent
611e3fe078
commit
e543582257
12 changed files with 111 additions and 198 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue