mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -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
|
@ -107,8 +107,9 @@ func (s *DNSSpoofer) Configure() error {
|
|||
for _, domain := range domains {
|
||||
if expr, err := glob.Compile(domain); err != nil {
|
||||
return fmt.Errorf("'%s' is not a valid domain glob expression: %s", domain, err)
|
||||
} else {
|
||||
s.Domains = append(s.Domains, expr)
|
||||
}
|
||||
s.Domains = append(s.Domains, expr)
|
||||
}
|
||||
|
||||
if err, addr = s.StringParam("dns.spoof.address"); err != nil {
|
||||
|
|
|
@ -210,8 +210,9 @@ func (s *EventsStream) startWaitingFor(tag string, timeout int) error {
|
|||
|
||||
if event == nil {
|
||||
return fmt.Errorf("'events.waitFor %s %d' timed out.", tag, timeout)
|
||||
} else {
|
||||
log.Debug("Got event: %v", event)
|
||||
}
|
||||
log.Debug("Got event: %v", event)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -98,8 +98,9 @@ func (gps *GPS) readLine() (line string, err error) {
|
|||
} else if n == 1 {
|
||||
if b[0] == '\n' {
|
||||
return core.Trim(line), nil
|
||||
} else {
|
||||
line += string(b[0])
|
||||
}
|
||||
line += string(b[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,8 +115,9 @@ func (p *HTTPProxy) Configure(address string, proxyPort int, httpPort int, scrip
|
|||
if scriptPath != "" {
|
||||
if err, p.Script = LoadHttpProxyScript(scriptPath, p.sess); err != nil {
|
||||
return err
|
||||
} else {
|
||||
log.Debug("Proxy script %s loaded.", scriptPath)
|
||||
}
|
||||
log.Debug("Proxy script %s loaded.", scriptPath)
|
||||
}
|
||||
|
||||
p.Server = &http.Server{
|
||||
|
@ -335,9 +336,9 @@ func (p *HTTPProxy) Stop() error {
|
|||
p.isRunning = false
|
||||
p.sniListener.Close()
|
||||
return nil
|
||||
} else {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
return p.Server.Shutdown(ctx)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
return p.Server.Shutdown(ctx)
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ func (t *CookieTracker) domainOf(req *http.Request) string {
|
|||
if parsed, err := tld.Parse(req.Host); err != nil {
|
||||
log.Warning("Could not parse host %s: %s", req.Host, err)
|
||||
return req.Host
|
||||
} else {
|
||||
return fmt.Sprintf("%s.%s", parsed.Domain, parsed.TLD)
|
||||
}
|
||||
return fmt.Sprintf("%s.%s", parsed.Domain, parsed.TLD)
|
||||
}
|
||||
|
||||
func (t *CookieTracker) keyOf(req *http.Request) string {
|
||||
|
|
|
@ -304,9 +304,10 @@ func (s *SSLStripper) isMaxRedirs(hostname string) bool {
|
|||
// reset
|
||||
delete(s.redirs, hostname)
|
||||
return true
|
||||
} else {
|
||||
// increment
|
||||
s.redirs[hostname]++
|
||||
}
|
||||
// increment
|
||||
s.redirs[hostname]++
|
||||
} else {
|
||||
// start tracking redirections
|
||||
s.redirs[hostname] = 1
|
||||
|
|
|
@ -71,8 +71,9 @@ func (p *Prober) Configure() error {
|
|||
var err error
|
||||
if err, p.throttle = p.IntParam("net.probe.throttle"); err != nil {
|
||||
return err
|
||||
} else {
|
||||
log.Debug("Throttling packets of %d ms.", p.throttle)
|
||||
}
|
||||
log.Debug("Throttling packets of %d ms.", p.throttle)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -124,8 +124,9 @@ func (p *TcpProxy) Configure() error {
|
|||
if scriptPath != "" {
|
||||
if err, p.script = LoadTcpProxyScript(scriptPath, p.Session); err != nil {
|
||||
return err
|
||||
} else {
|
||||
log.Debug("TCP proxy script %s loaded.", scriptPath)
|
||||
}
|
||||
log.Debug("TCP proxy script %s loaded.", scriptPath)
|
||||
}
|
||||
|
||||
if !p.Session.Firewall.IsForwardingEnabled() {
|
||||
|
|
|
@ -20,9 +20,9 @@ func findMAC(s *session.Session, ip net.IP, probe bool) (net.HardwareAddr, error
|
|||
mac, err = network.ArpLookup(s.Interface.Name(), ip.String(), false)
|
||||
if err != nil && probe {
|
||||
from := s.Interface.IP
|
||||
fromHw := s.Interface.HW
|
||||
from_hw := s.Interface.HW
|
||||
|
||||
if err, probe := packets.NewUDPProbe(from, fromHw, ip, 139); err != nil {
|
||||
if err, probe := packets.NewUDPProbe(from, from_hw, ip, 139); err != nil {
|
||||
log.Error("Error while creating UDP probe packet for %s: %s", ip.String(), err)
|
||||
} else {
|
||||
s.Queue.Send(probe)
|
||||
|
|
|
@ -101,8 +101,9 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
|||
func(args []string) error {
|
||||
if err := w.parseApConfig(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return w.startAp()
|
||||
}
|
||||
return w.startAp()
|
||||
}))
|
||||
|
||||
w.AddParam(session.NewStringParameter("wifi.ap.ssid",
|
||||
|
@ -148,8 +149,9 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
|||
// No channels setted, retrieve frequencies supported by the card
|
||||
if frequencies, err := network.GetSupportedFrequencies(w.Session.Interface.Name()); err != nil {
|
||||
return err
|
||||
} else {
|
||||
newfrequencies = frequencies
|
||||
}
|
||||
newfrequencies = frequencies
|
||||
}
|
||||
|
||||
w.frequencies = newfrequencies
|
||||
|
|
|
@ -83,30 +83,30 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
|||
recvd,
|
||||
seen,
|
||||
}, include
|
||||
}
|
||||
|
||||
// this is ugly, but necessary in order to have this
|
||||
// method handle both access point and clients
|
||||
// transparently
|
||||
clients := ""
|
||||
if ap, found := w.Session.WiFi.Get(station.HwAddress); found {
|
||||
if ap.NumClients() > 0 {
|
||||
clients = strconv.Itoa(ap.NumClients())
|
||||
} else {
|
||||
// this is ugly, but necessary in order to have this
|
||||
// method handle both access point and clients
|
||||
// transparently
|
||||
clients := ""
|
||||
if ap, found := w.Session.WiFi.Get(station.HwAddress); found {
|
||||
if ap.NumClients() > 0 {
|
||||
clients = strconv.Itoa(ap.NumClients())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return []string{
|
||||
fmt.Sprintf("%d dBm", station.RSSI),
|
||||
bssid,
|
||||
ssid,
|
||||
/* station.Vendor, */
|
||||
encryption,
|
||||
strconv.Itoa(network.Dot11Freq2Chan(station.Frequency)),
|
||||
clients,
|
||||
sent,
|
||||
recvd,
|
||||
seen,
|
||||
}, include
|
||||
return []string{
|
||||
fmt.Sprintf("%d dBm", station.RSSI),
|
||||
bssid,
|
||||
ssid,
|
||||
/* station.Vendor, */
|
||||
encryption,
|
||||
strconv.Itoa(network.Dot11Freq2Chan(station.Frequency)),
|
||||
clients,
|
||||
sent,
|
||||
recvd,
|
||||
seen,
|
||||
}, include
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WiFiModule) Show(by string) error {
|
||||
|
|
|
@ -31,8 +31,9 @@ func NewWOL(s *session.Session) *WOL {
|
|||
func(args []string) error {
|
||||
if mac, err := parseMAC(args); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return w.wolETH(mac)
|
||||
}
|
||||
return w.wolETH(mac)
|
||||
}))
|
||||
|
||||
w.AddHandler(session.NewModuleHandler("wol.udp MAC", "wol.udp(\\s.+)?",
|
||||
|
@ -40,8 +41,9 @@ func NewWOL(s *session.Session) *WOL {
|
|||
func(args []string) error {
|
||||
if mac, err := parseMAC(args); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return w.wolUDP(mac)
|
||||
}
|
||||
return w.wolUDP(mac)
|
||||
}))
|
||||
|
||||
return w
|
||||
|
@ -54,8 +56,9 @@ func parseMAC(args []string) (string, error) {
|
|||
if tmp != "" {
|
||||
if !reMAC.MatchString(tmp) {
|
||||
return "", fmt.Errorf("%s is not a valid MAC address.", tmp)
|
||||
} else {
|
||||
mac = tmp
|
||||
}
|
||||
mac = tmp
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue