mirror of
https://github.com/bettercap/bettercap
synced 2025-07-30 03:29:57 -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]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:09a1322d2fc6f021b23d389c045479cf4fe94fca0f504c61bb0ca2c67e244506"
|
digest = "1:32d8e0c62dc075d198abf73428828689f4e9473cadb8ef270be45fb78ae8648b"
|
||||||
name = "github.com/evilsocket/islazy"
|
name = "github.com/evilsocket/islazy"
|
||||||
packages = [
|
packages = [
|
||||||
"fs",
|
"fs",
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "acbee79ddc39664d9a6ef5b2c4306dd470a58b2b"
|
revision = "fd12757cd7fd9e544ea374582c7015587d9ac534"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
|
@ -32,8 +32,8 @@ func NewEvent(tag string, data interface{}) Event {
|
||||||
|
|
||||||
func (e Event) Label() string {
|
func (e Event) Label() string {
|
||||||
m := e.Data.(LogMessage)
|
m := e.Data.(LogMessage)
|
||||||
label := log.LevelNames[m.Level]
|
label := log.LevelName(m.Level)
|
||||||
color := log.LevelColors[m.Level]
|
color := log.LevelColor(m.Level)
|
||||||
return color + label + tui.RESET
|
return color + label + tui.RESET
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,24 +15,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// these are here because if colors are disabled,
|
effects = map[string]string{}
|
||||||
// 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,
|
|
||||||
}
|
|
||||||
PromptCallbacks = map[string]func(s *Session) string{
|
PromptCallbacks = map[string]func(s *Session) string{
|
||||||
"{cidr}": func(s *Session) string {
|
"{cidr}": func(s *Session) string {
|
||||||
return s.Interface.CIDR()
|
return s.Interface.CIDR()
|
||||||
|
@ -62,6 +45,24 @@ type Prompt struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPrompt() Prompt {
|
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{}
|
return Prompt{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,13 +95,22 @@ type Session struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() (*Session, error) {
|
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{
|
s := &Session{
|
||||||
Prompt: NewPrompt(),
|
Prompt: NewPrompt(),
|
||||||
Env: nil,
|
Options: opts,
|
||||||
Active: false,
|
Env: nil,
|
||||||
Queue: nil,
|
Active: false,
|
||||||
|
Queue: nil,
|
||||||
|
|
||||||
CoreHandlers: make([]CommandHandler, 0),
|
CoreHandlers: make([]CommandHandler, 0),
|
||||||
Modules: make([]Module, 0),
|
Modules: make([]Module, 0),
|
||||||
|
@ -109,15 +118,6 @@ func New() (*Session, error) {
|
||||||
UnkCmdCallback: nil,
|
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 *s.Options.CpuProfile != "" {
|
||||||
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
|
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
|
||||||
return nil, err
|
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,
|
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