ing
This commit is contained in:
parent
b88509516a
commit
0f9f14aedc
55
mdns/mdns.go
55
mdns/mdns.go
|
@ -17,52 +17,6 @@ import (
|
||||||
"github.com/grandcat/zeroconf"
|
"github.com/grandcat/zeroconf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serviceMeta struct {
|
|
||||||
name string
|
|
||||||
cryptoType string
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
serviceMetaMapping = map[string]*serviceMeta{
|
|
||||||
"http": &serviceMeta{
|
|
||||||
name: "HTTP",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"printer": &serviceMeta{
|
|
||||||
name: "PRINTER",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"pdl-datastream": &serviceMeta{
|
|
||||||
name: "PDL-DATASTREAM",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"ipp": &serviceMeta{
|
|
||||||
name: "IPP",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"webdav": &serviceMeta{
|
|
||||||
name: "WEBDAV",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"webdavs": &serviceMeta{
|
|
||||||
name: "WEBDAV",
|
|
||||||
cryptoType: "TLS",
|
|
||||||
},
|
|
||||||
"afpovertcp": &serviceMeta{
|
|
||||||
name: "AFP",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"smb": &serviceMeta{
|
|
||||||
name: "SMB",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
"rfb": &serviceMeta{
|
|
||||||
name: "RFB",
|
|
||||||
cryptoType: "NONE",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func Scan(discovered model.Discovered) {
|
func Scan(discovered model.Discovered) {
|
||||||
serviceEntries, err := browse("_services._dns-sd._udp", "local")
|
serviceEntries, err := browse("_services._dns-sd._udp", "local")
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
@ -204,14 +158,9 @@ func parseService(service string) (name string, portType string, cryptoType stri
|
||||||
_name := strings.TrimLeft(ss[0], "_")
|
_name := strings.TrimLeft(ss[0], "_")
|
||||||
_portType := strings.TrimLeft(ss[1], "_")
|
_portType := strings.TrimLeft(ss[1], "_")
|
||||||
|
|
||||||
m, ok := serviceMetaMapping[_name]
|
name = _name
|
||||||
if !ok {
|
|
||||||
return "UNKNOWN", "UNKNOWN", "UNKNOWN"
|
|
||||||
}
|
|
||||||
|
|
||||||
name = m.name
|
|
||||||
portType = _portType
|
portType = _portType
|
||||||
cryptoType = m.cryptoType
|
cryptoType = "NONE"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user