mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
Revert "Minor refactors using golint"
This commit is contained in:
parent
9196be7a8b
commit
5328ced392
21 changed files with 101 additions and 70 deletions
|
@ -27,6 +27,7 @@ func (h *CommandHandler) Parse(line string) (bool, []string) {
|
|||
result := h.Parser.FindStringSubmatch(line)
|
||||
if len(result) == h.Parser.NumSubexp()+1 {
|
||||
return true, result[1:]
|
||||
} else {
|
||||
return false, nil
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -114,8 +114,9 @@ func (env *Environment) GetInt(name string) (error, int) {
|
|||
if found, value := env.Get(name); found {
|
||||
if i, err := strconv.Atoi(value); err == nil {
|
||||
return nil, i
|
||||
} else {
|
||||
return err, 0
|
||||
}
|
||||
return err, 0
|
||||
}
|
||||
|
||||
return fmt.Errorf("Not found."), 0
|
||||
|
|
|
@ -62,12 +62,13 @@ func (m SessionModule) ListParam(name string) (err error, values []string) {
|
|||
list := ""
|
||||
if err, list = m.StringParam(name); err != nil {
|
||||
return
|
||||
}
|
||||
parts := strings.Split(list, ",")
|
||||
for _, part := range parts {
|
||||
part = core.Trim(part)
|
||||
if part != "" {
|
||||
values = append(values, part)
|
||||
} else {
|
||||
parts := strings.Split(list, ",")
|
||||
for _, part := range parts {
|
||||
part = core.Trim(part)
|
||||
if part != "" {
|
||||
values = append(values, part)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -77,27 +78,33 @@ func (m SessionModule) StringParam(name string) (error, string) {
|
|||
if p, found := m.params[name]; found {
|
||||
if err, v := p.Get(m.Session); err != nil {
|
||||
return err, ""
|
||||
} else {
|
||||
return nil, v.(string)
|
||||
}
|
||||
return nil, v.(string)
|
||||
} else {
|
||||
return fmt.Errorf("Parameter %s does not exist.", name), ""
|
||||
}
|
||||
return fmt.Errorf("Parameter %s does not exist.", name), ""
|
||||
}
|
||||
|
||||
func (m SessionModule) IntParam(name string) (error, int) {
|
||||
if p, found := m.params[name]; found {
|
||||
if err, v := p.Get(m.Session); err != nil {
|
||||
return err, 0
|
||||
} else {
|
||||
return nil, v.(int)
|
||||
}
|
||||
return nil, v.(int)
|
||||
|
||||
} else {
|
||||
return fmt.Errorf("Parameter %s does not exist.", name), 0
|
||||
}
|
||||
return fmt.Errorf("Parameter %s does not exist.", name), 0
|
||||
}
|
||||
|
||||
func (m SessionModule) BoolParam(name string) (error, bool) {
|
||||
if err, v := m.params[name].Get(m.Session); err != nil {
|
||||
return err, false
|
||||
} else {
|
||||
return nil, v.(bool)
|
||||
}
|
||||
return nil, v.(bool)
|
||||
}
|
||||
|
||||
func (m *SessionModule) AddHandler(h ModuleHandler) {
|
||||
|
@ -120,8 +127,9 @@ func (m *SessionModule) SetRunning(running bool, cb func()) error {
|
|||
if running == m.Running() {
|
||||
if m.Started {
|
||||
return ErrAlreadyStarted
|
||||
} else {
|
||||
return ErrAlreadyStopped
|
||||
}
|
||||
return ErrAlreadyStopped
|
||||
}
|
||||
|
||||
m.StatusLock.Lock()
|
||||
|
|
|
@ -148,8 +148,9 @@ func (s *Session) sleepHandler(args []string, sess *Session) error {
|
|||
if secs, err := strconv.Atoi(args[0]); err == nil {
|
||||
time.Sleep(time.Duration(secs) * time.Second)
|
||||
return nil
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Session) getHandler(args []string, sess *Session) error {
|
||||
|
@ -256,8 +257,9 @@ func (s *Session) aliasHandler(args []string, sess *Session) error {
|
|||
|
||||
if s.Lan.SetAliasFor(mac, alias) {
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("Could not find endpoint %s", mac)
|
||||
}
|
||||
return fmt.Errorf("Could not find endpoint %s", mac)
|
||||
}
|
||||
|
||||
func (s *Session) addHandler(h CommandHandler, c *readline.PrefixCompleter) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue