8e7de3f59e
* Change stream model to support multiple routes * Simplify attack algorithm * Use dummy route to detect cameras which accept all routes
28 lines
739 B
Go
28 lines
739 B
Go
package cameradar
|
|
|
|
import "fmt"
|
|
|
|
func replace(streams []Stream, new Stream) []Stream {
|
|
var updatedSlice []Stream
|
|
|
|
for _, old := range streams {
|
|
if old.Address == new.Address && old.Port == new.Port {
|
|
updatedSlice = append(updatedSlice, new)
|
|
} else {
|
|
updatedSlice = append(updatedSlice, old)
|
|
}
|
|
}
|
|
|
|
return updatedSlice
|
|
}
|
|
|
|
// GetCameraRTSPURL generates a stream's RTSP URL.
|
|
func GetCameraRTSPURL(stream Stream) string {
|
|
return "rtsp://" + stream.Username + ":" + stream.Password + "@" + stream.Address + ":" + fmt.Sprint(stream.Port) + "/" + stream.Route()
|
|
}
|
|
|
|
// GetCameraAdminPanelURL returns the URL to the camera's admin panel.
|
|
func GetCameraAdminPanelURL(stream Stream) string {
|
|
return "http://" + stream.Address + "/"
|
|
}
|