mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
b0a197b377
commit
17ba1be16c
12 changed files with 239 additions and 498 deletions
|
@ -3,38 +3,12 @@ package zerogod
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/bettercap/bettercap/v2/zeroconf"
|
||||
"github.com/evilsocket/islazy/str"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type ServiceData struct {
|
||||
Name string `yaml:"name"` // Instance name (e.g. "My web page")
|
||||
Service string `yaml:"service"` // Service name (e.g. _http._tcp.)
|
||||
Domain string `yaml:"domain"` // If blank, assumes "local"
|
||||
Port int `yaml:"port"` // Service port
|
||||
Records []string `yaml:"records,omitempty"` // Service DNS text records
|
||||
Responder string `yaml:"responder,omitempty"` // Optional IP to use instead of our tcp acceptor
|
||||
}
|
||||
|
||||
func (svc ServiceData) FullName() string {
|
||||
return fmt.Sprintf("%s.%s.%s",
|
||||
strings.Trim(svc.Name, "."),
|
||||
strings.Trim(svc.Service, "."),
|
||||
strings.Trim(svc.Domain, "."))
|
||||
}
|
||||
|
||||
func (svc ServiceData) Unregister() error {
|
||||
if server, err := zeroconf.Register(svc.Name, svc.Service, svc.Domain, svc.Port, svc.Records, nil); err != nil {
|
||||
return err
|
||||
} else {
|
||||
server.Shutdown()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func svcEntriesToData(services map[string]*zeroconf.ServiceEntry) []ServiceData {
|
||||
data := make([]ServiceData, 0)
|
||||
for _, svc := range services {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue