mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
new: realtime network stats can now be used in the prompt
This commit is contained in:
parent
e7da2d4287
commit
75b423ab2d
7 changed files with 31 additions and 4 deletions
|
@ -1,10 +1,13 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -33,6 +36,24 @@ var PromptCallbacks = map[string]func(s *Session) string{
|
|||
"{cidr}": func(s *Session) string {
|
||||
return s.Interface.CIDR()
|
||||
},
|
||||
"{net.sent}": func(s *Session) string {
|
||||
return fmt.Sprintf("%d", s.Queue.Sent)
|
||||
},
|
||||
"{net.sent.human}": func(s *Session) string {
|
||||
return humanize.Bytes(s.Queue.Sent)
|
||||
},
|
||||
"{net.received}": func(s *Session) string {
|
||||
return fmt.Sprintf("%d", s.Queue.Received)
|
||||
},
|
||||
"{net.received.human}": func(s *Session) string {
|
||||
return humanize.Bytes(s.Queue.Received)
|
||||
},
|
||||
"{net.packets}": func(s *Session) string {
|
||||
return fmt.Sprintf("%d", s.Queue.PktReceived)
|
||||
},
|
||||
"{net.errors}": func(s *Session) string {
|
||||
return fmt.Sprintf("%d", s.Queue.Errors)
|
||||
},
|
||||
}
|
||||
|
||||
var envRe = regexp.MustCompile("{env\\.(.+)}")
|
||||
|
|
|
@ -253,9 +253,13 @@ func (s *Session) Start() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Session) ReadLine() (string, error) {
|
||||
func (s *Session) Refresh() {
|
||||
s.Input.SetPrompt(s.Prompt.Render(s))
|
||||
s.Input.Refresh()
|
||||
}
|
||||
|
||||
func (s *Session) ReadLine() (string, error) {
|
||||
s.Refresh()
|
||||
return s.Input.Readline()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue