mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
new: new -pcap-buf-size option to set a custom pcap buffer size (closes #896)
This commit is contained in:
parent
59dce4ced6
commit
81ae731b9f
3 changed files with 10 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import "flag"
|
import (
|
||||||
|
"flag"
|
||||||
|
)
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
InterfaceName *string
|
InterfaceName *string
|
||||||
|
@ -18,6 +20,7 @@ type Options struct {
|
||||||
MemProfile *string
|
MemProfile *string
|
||||||
CapletsPath *string
|
CapletsPath *string
|
||||||
Script *string
|
Script *string
|
||||||
|
PcapBufSize *int
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseOptions() (Options, error) {
|
func ParseOptions() (Options, error) {
|
||||||
|
@ -37,6 +40,7 @@ func ParseOptions() (Options, error) {
|
||||||
MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."),
|
MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."),
|
||||||
CapletsPath: flag.String("caplets-path", "", "Specify an alternative base path for caplets."),
|
CapletsPath: flag.String("caplets-path", "", "Specify an alternative base path for caplets."),
|
||||||
Script: flag.String("script", "", "Load a session script."),
|
Script: flag.String("script", "", "Load a session script."),
|
||||||
|
PcapBufSize: flag.Int("pcap-buf-size", -1, "PCAP buffer size, leave to 0 for the default value."),
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
|
@ -568,7 +568,7 @@ func (mod *WiFiModule) Configure() error {
|
||||||
if mod.handle, err = network.CaptureWithOptions(ifName, opts); err == nil {
|
if mod.handle, err = network.CaptureWithOptions(ifName, opts); err == nil {
|
||||||
// we're done
|
// we're done
|
||||||
break
|
break
|
||||||
} else if retry == 0 /* && err.Error() == ErrIfaceNotUp */ {
|
} else if retry == 0 && err.Error() == ErrIfaceNotUp {
|
||||||
// try to bring interface up and try again
|
// try to bring interface up and try again
|
||||||
mod.Info("interface %s is down, bringing it up ...", ifName)
|
mod.Info("interface %s is down, bringing it up ...", ifName)
|
||||||
if err := network.ActivateInterface(ifName); err != nil {
|
if err := network.ActivateInterface(ifName); err != nil {
|
||||||
|
|
|
@ -127,6 +127,10 @@ func New() (*Session, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bufSize := *s.Options.PcapBufSize; bufSize != -1 {
|
||||||
|
network.CAPTURE_DEFAULTS.Bufsize = bufSize
|
||||||
|
}
|
||||||
|
|
||||||
if s.Env, err = NewEnvironment(*s.Options.EnvFile); err != nil {
|
if s.Env, err = NewEnvironment(*s.Options.EnvFile); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue