Merge branch 'master' of github.com:bettercap/bettercap

This commit is contained in:
evilsocket 2019-03-17 12:50:25 +01:00
commit b676d68b4c
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 3 additions and 4 deletions

View file

@ -109,7 +109,7 @@ func (mod *DNSSpoofer) Configure() error {
if hostsFile != "" {
mod.Info("loading hosts from file %s ...", hostsFile)
if err, hosts := HostsFromFile(hostsFile); err != nil {
if err, hosts := HostsFromFile(hostsFile, address); err != nil {
return fmt.Errorf("error reading hosts from file %s: %v", hostsFile, err)
} else {
mod.Hosts = append(mod.Hosts, hosts...)

View file

@ -2,7 +2,6 @@ package dns_spoof
import (
"bufio"
"fmt"
"net"
"os"
"regexp"
@ -47,7 +46,7 @@ func NewHostEntry(host string, address net.IP) HostEntry {
return entry
}
func HostsFromFile(filename string) (err error, entries []HostEntry) {
func HostsFromFile(filename string,defaultAddress net.IP) (err error, entries []HostEntry) {
input, err := os.Open(filename)
if err != nil {
return
@ -66,7 +65,7 @@ func HostsFromFile(filename string) (err error, entries []HostEntry) {
domain := parts[1]
entries = append(entries, NewHostEntry(domain, address))
} else {
return fmt.Errorf("'%s' invalid hosts line", line), nil
entries = append(entries, NewHostEntry(line, defaultAddress))
}
}