Skip to content

Commit

Permalink
fix:discovery mode netscan when using docker-compose
Browse files Browse the repository at this point in the history
Signed-off-by: edgego <tianxingguo@gmail.com>
  • Loading branch information
edgego committed Oct 12, 2022
1 parent 60aed97 commit 0e550ce
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/driver/onvifdiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ func (d *Driver) createDiscoveredDevice(onvifDevice onvif.Device) (sdkModel.Disc
device.Protocols[OnvifProtocol][LastSeen] = time.Now().Format(time.UnixDate)
device.Protocols[OnvifProtocol][FriendlyName] = devInfo.Manufacturer + " " + devInfo.Model

// Spaces are not allowed in the device name
// Spaces and slashes are not allowed in the device name
deviceName := fmt.Sprintf("%s-%s-%s",
strings.ReplaceAll(devInfo.Manufacturer, " ", "-"),
strings.ReplaceAll(devInfo.Model, " ", "-"),
strings.ReplaceAll(strings.ReplaceAll(devInfo.Model, "/", "-"), " ", "-"),
endpointRefAddr)

netInfo, err := d.getNetworkInterfaces(device)
Expand Down Expand Up @@ -189,9 +189,9 @@ func executeRawProbe(conn net.Conn, params netscan.Params) ([]onvif.Device, erro

var responses []string
buf := make([]byte, bufSize)
// keep reading from the PacketConn until the read deadline expires or an error occurs
// keep reading responses from the connection until the read deadline expires or an error occurs
for {
n, _, err := (conn.(net.PacketConn)).ReadFrom(buf)
n, err := conn.Read(buf)
if err != nil {
// ErrDeadlineExceeded is expected once the read timeout is expired
if !stdErrors.Is(err, os.ErrDeadlineExceeded) {
Expand Down

0 comments on commit 0e550ce

Please # to comment.