mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
progress
This commit is contained in:
parent
756dc3d71a
commit
67cc9680ed
17 changed files with 1833 additions and 274 deletions
35
modules/mdns/mdns_save.go
Normal file
35
modules/mdns/mdns_save.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package mdns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func (mod *MDNSModule) save(address, filename string) error {
|
||||
if address == "" {
|
||||
return fmt.Errorf("address cannot be empty")
|
||||
}
|
||||
if filename == "" {
|
||||
return fmt.Errorf("filename cannot be empty")
|
||||
}
|
||||
|
||||
if ipServices, found := mod.mapping[address]; found {
|
||||
data, err := yaml.Marshal(ipServices)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(filename, data, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mod.Info("mDNS information saved to %s", filename)
|
||||
} else {
|
||||
return fmt.Errorf("no mDNS information found for address %s", address)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue