mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
new: wifi.min.rssi, wifi.ap.ttl and wifi.sta.ttl changes are now applied in realtime
This commit is contained in:
parent
53b0d81f20
commit
12a11ef19d
5 changed files with 47 additions and 9 deletions
|
@ -62,7 +62,7 @@ func NewDecimalParameter(name string, def_value string, desc string) *ModulePara
|
|||
return NewModuleParameter(name, def_value, FLOAT, "^[\\d]+(\\.\\d+)?$", desc)
|
||||
}
|
||||
|
||||
func (p ModuleParam) Validate(value string) (error, interface{}) {
|
||||
func (p ModuleParam) validate(value string) (error, interface{}) {
|
||||
if p.Validator != nil {
|
||||
if !p.Validator.MatchString(value) {
|
||||
return fmt.Errorf("Parameter %s not valid: '%s' does not match rule '%s'.", tui.Bold(p.Name), value, p.Validator.String()), nil
|
||||
|
@ -125,7 +125,7 @@ func (p ModuleParam) getUnlocked(s *Session) string {
|
|||
func (p ModuleParam) Get(s *Session) (error, interface{}) {
|
||||
_, v := s.Env.Get(p.Name)
|
||||
v = p.parse(s, v)
|
||||
return p.Validate(v)
|
||||
return p.validate(v)
|
||||
}
|
||||
|
||||
func (p ModuleParam) Help(padding int) string {
|
||||
|
@ -138,6 +138,10 @@ func (p ModuleParam) Register(s *Session) {
|
|||
s.Env.Set(p.Name, p.Value)
|
||||
}
|
||||
|
||||
func (p ModuleParam) RegisterObserver(s *Session, cb EnvironmentChangedCallback) {
|
||||
s.Env.WithCallback(p.Name, p.Value, cb)
|
||||
}
|
||||
|
||||
type JSONModuleParam struct {
|
||||
Name string `json:"name"`
|
||||
Type ParamType `json:"type"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue