mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
d070445225
commit
058a6865ff
5 changed files with 50 additions and 36 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -60,7 +60,7 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:09a1322d2fc6f021b23d389c045479cf4fe94fca0f504c61bb0ca2c67e244506"
|
||||
digest = "1:32d8e0c62dc075d198abf73428828689f4e9473cadb8ef270be45fb78ae8648b"
|
||||
name = "github.com/evilsocket/islazy"
|
||||
packages = [
|
||||
"fs",
|
||||
|
@ -70,7 +70,7 @@
|
|||
"zip",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "acbee79ddc39664d9a6ef5b2c4306dd470a58b2b"
|
||||
revision = "fd12757cd7fd9e544ea374582c7015587d9ac534"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
|
|
@ -32,8 +32,8 @@ func NewEvent(tag string, data interface{}) Event {
|
|||
|
||||
func (e Event) Label() string {
|
||||
m := e.Data.(LogMessage)
|
||||
label := log.LevelNames[m.Level]
|
||||
color := log.LevelColors[m.Level]
|
||||
label := log.LevelName(m.Level)
|
||||
color := log.LevelColor(m.Level)
|
||||
return color + label + tui.RESET
|
||||
}
|
||||
|
||||
|
|
|
@ -15,24 +15,7 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
// these are here because if colors are disabled,
|
||||
// we need the updated tui.* variables
|
||||
effects = map[string]string{
|
||||
"{bold}": tui.BOLD,
|
||||
"{dim}": tui.DIM,
|
||||
"{r}": tui.RED,
|
||||
"{g}": tui.GREEN,
|
||||
"{b}": tui.BLUE,
|
||||
"{y}": tui.YELLOW,
|
||||
"{fb}": tui.FOREBLACK,
|
||||
"{fw}": tui.FOREWHITE,
|
||||
"{bdg}": tui.BACKDARKGRAY,
|
||||
"{br}": tui.BACKRED,
|
||||
"{bg}": tui.BACKGREEN,
|
||||
"{by}": tui.BACKYELLOW,
|
||||
"{blb}": tui.BACKLIGHTBLUE, // Ziggy this is for you <3
|
||||
"{reset}": tui.RESET,
|
||||
}
|
||||
effects = map[string]string{}
|
||||
PromptCallbacks = map[string]func(s *Session) string{
|
||||
"{cidr}": func(s *Session) string {
|
||||
return s.Interface.CIDR()
|
||||
|
@ -62,6 +45,24 @@ type Prompt struct {
|
|||
}
|
||||
|
||||
func NewPrompt() Prompt {
|
||||
// these are here because if colors are disabled,
|
||||
// we need the updated tui.* variables
|
||||
effects = map[string]string{
|
||||
"{bold}": tui.BOLD,
|
||||
"{dim}": tui.DIM,
|
||||
"{r}": tui.RED,
|
||||
"{g}": tui.GREEN,
|
||||
"{b}": tui.BLUE,
|
||||
"{y}": tui.YELLOW,
|
||||
"{fb}": tui.FOREBLACK,
|
||||
"{fw}": tui.FOREWHITE,
|
||||
"{bdg}": tui.BACKDARKGRAY,
|
||||
"{br}": tui.BACKRED,
|
||||
"{bg}": tui.BACKGREEN,
|
||||
"{by}": tui.BACKYELLOW,
|
||||
"{blb}": tui.BACKLIGHTBLUE, // Ziggy this is for you <3
|
||||
"{reset}": tui.RESET,
|
||||
}
|
||||
return Prompt{}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,13 +95,22 @@ type Session struct {
|
|||
}
|
||||
|
||||
func New() (*Session, error) {
|
||||
var err error
|
||||
opts, err := core.ParseOptions()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if *opts.NoColors || !tui.Effects() {
|
||||
tui.Disable()
|
||||
log.NoEffects = true
|
||||
}
|
||||
|
||||
s := &Session{
|
||||
Prompt: NewPrompt(),
|
||||
Env: nil,
|
||||
Active: false,
|
||||
Queue: nil,
|
||||
Prompt: NewPrompt(),
|
||||
Options: opts,
|
||||
Env: nil,
|
||||
Active: false,
|
||||
Queue: nil,
|
||||
|
||||
CoreHandlers: make([]CommandHandler, 0),
|
||||
Modules: make([]Module, 0),
|
||||
|
@ -109,15 +118,6 @@ func New() (*Session, error) {
|
|||
UnkCmdCallback: nil,
|
||||
}
|
||||
|
||||
if s.Options, err = core.ParseOptions(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if *s.Options.NoColors || !tui.Effects() {
|
||||
tui.Disable()
|
||||
log.NoEffects = true
|
||||
}
|
||||
|
||||
if *s.Options.CpuProfile != "" {
|
||||
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
|
||||
return nil, err
|
||||
|
|
13
vendor/github.com/evilsocket/islazy/log/level.go
generated
vendored
13
vendor/github.com/evilsocket/islazy/log/level.go
generated
vendored
|
@ -42,3 +42,16 @@ var (
|
|||
FATAL: tui.FOREWHITE + tui.BACKRED + tui.BOLD,
|
||||
}
|
||||
)
|
||||
|
||||
// LevelName returns the name of a verbosity level.
|
||||
func LevelName(v Verbosity) string {
|
||||
return LevelNames[v]
|
||||
}
|
||||
|
||||
// LevelColor returns the color of a verbosity level or "" if effects are disabled.
|
||||
func LevelColor(v Verbosity) string {
|
||||
if NoEffects {
|
||||
return ""
|
||||
}
|
||||
return LevelColors[v]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue