Documentation
¶
Index ¶
- Variables
- func SetClient(addr string, username string, password string, client *Client)
- type BasicInfo
- type Client
- func (cli *Client) AddEndpoint(Key, Value string)
- func (cli *Client) BasicAuth(endpoint string, method interface{}) (*http.Response, error)
- func (cli *Client) BuildMethodSOAP(msg string) (soap.SoapMessage, error)
- func (cli *Client) CalculateMD5(data string) string
- func (cli *Client) CallMethod(method any) (*http.Response, error)
- func (cli *Client) DigestAuth(endpoint string, method interface{}, Config map[string]string) (*http.Response, error)
- func (cli *Client) GenDigestAuthHeader(username, password, realm, nonce, qop, uri, method string) (string, error)
- func (cli *Client) GenRandomCNonce() (string, error)
- func (cli *Client) GetAction(method any) soap.Action
- func (cli *Client) GetBasicInfo() *BasicInfo
- func (cli *Client) GetConfig() *Config
- func (cli *Client) GetEndpoint(service string) (string, error)
- func (cli *Client) GetHttpClient() *http.Client
- func (cli *Client) GetIncrementNonceCount(nonce string) uint64
- func (cli *Client) GetServiceName(method any) string
- func (cli *Client) GetServices() map[string]string
- func (cli *Client) GetSupportedServices(resp *http.Response) error
- func (cli *Client) ParseAuthHeader(header string) (scheme string, Config map[string]string, err error)
- func (cli *Client) SetHttpClient(client *http.Client)
- func (cli *Client) UnAuthorized(endpoint string, method any, response *http.Response) (*http.Response, error)
- type Config
- func (c *Config) GetDebug() bool
- func (c *Config) GetPassword() string
- func (c *Config) GetTimeout() time.Duration
- func (c *Config) GetUsername() string
- func (c *Config) GetXAddr() string
- func (c *Config) SetDebug(debug bool)
- func (c *Config) SetPassword(password string)
- func (c *Config) SetTimeout(timeout time.Duration)
- func (c *Config) SetUsername(username string)
- func (c *Config) SetXAddr(xaddr string)
- type DigestNonceContext
- type Location
Constants ¶
This section is empty.
Variables ¶
View Source
var XMLNamespaces = map[string]string{
"onvif": "http://www.onvif.org/ver10/schema",
"tds": "http://www.onvif.org/ver10/device/wsdl",
"trt": "http://www.onvif.org/ver10/media/wsdl",
"tev": "http://www.onvif.org/ver10/events/wsdl",
"tptz": "http://www.onvif.org/ver20/ptz/wsdl",
"timg": "http://www.onvif.org/ver20/imaging/wsdl",
"tan": "http://www.onvif.org/ver20/analytics/wsdl",
"xmime": "http://www.w3.org/2005/05/xmlmime",
"wsnt": "http://docs.oasis-open.org/wsn/b-2",
"xop": "http://www.w3.org/2004/08/xop/include",
"wsa": "http://www.w3.org/2005/08/addressing",
"wstop": "http://docs.oasis-open.org/wsn/t-1",
"wsntw": "http://docs.oasis-open.org/wsn/bw-2",
"wsrf-rw": "http://docs.oasis-open.org/wsrf/rw-2",
"wsaw": "http://www.w3.org/2006/05/addressing/wsdl",
}
XMLNamespaces XML Scheam
Functions ¶
Types ¶
type BasicInfo ¶
type BasicInfo struct {
XAddrs []string `xorm:"blob 'xaddrs'"` // xaddr 地址列表
Addrs []string `json:"addrs"` // 地址列表
IPs []string `json:"ips"` // ip列表
Types []string `json:"types"` // 类型列表
Scopes []string `json:"scopes"` // 域列表
Locations []string `json:"locations"` // 位置信息列表
Profiles []string `json:"profiles"` // 规范列表
Names []string `json:"names"` // 名称/型号列表
Macs []string `json:"macs"` // Mac 地址列表
Hardwares []string `json:"hardwares"` // 硬件信息列表
MetadataVersion *int `json:"metadata_version"` // 元数据版本
Location *Location `json:"location"` // 地理位置信息
Name string `json:"name"` // 名称
Brand string `json:"brand"` // 品牌
Model string `json:"model"` // 型号
Type string `json:"type"` // 设备类型
Mac string `json:"mac"` // Mac 地址
SerialNumber string `json:"serial_number"` // 序列号
Manufacturer string `json:"manufacturer"` // 制造商/厂商
FirmwareVersion string `json:"firmware_version"` // 固件版本
HardwareVersion string `json:"hardware_version"` // 硬件版本
SoftwareVersion string `json:"software_version"` // 软件版本
}
设备基本信息
type Client ¶
type Client struct {
Config *Config `json:"config"` // 配置信息(设备连接参数)
HttpClient *http.Client `json:"-"` // HTTP 客户端
BasicInfo *BasicInfo `json:"basic_info"` // 设备基础信息(WS-Discovery结果)
Endpoints map[string]string `json:"endpoints"` // 服务能力节点/地址列表
Nonces map[string]DigestNonceContext `json:"-"` // nonce 摘要认证的上下文信息
RWMutex sync.RWMutex `json:"-"` // 保护 Nonces
Capabilities *tt.Capabilities `json:"capabilities"` // 能力列表
}
Client ONVIF 设备客户端
func (*Client) AddEndpoint ¶
AddEndpoint 添加服务能力节点/地址列表信息
func (*Client) BuildMethodSOAP ¶
func (cli *Client) BuildMethodSOAP(msg string) (soap.SoapMessage, error)
BuildMethodSOAP 构建 SOAP 消息
func (*Client) CalculateMD5 ¶
CalculateMD5 计算MD5哈希
func (*Client) CallMethod ¶
CallMethod 调用 ONVIF 方法,自动处理认证
func (*Client) DigestAuth ¶
func (cli *Client) DigestAuth(endpoint string, method interface{}, Config map[string]string) (*http.Response, error)
DigestAuth 处理摘要认证
func (*Client) GenDigestAuthHeader ¶
func (cli *Client) GenDigestAuthHeader(username, password, realm, nonce, qop, uri, method string) (string, error)
GenDigestAuthHeader 生成摘要认证头部
func (*Client) GenRandomCNonce ¶
GenRandomCNonce 生成随机cnonce
func (*Client) GetBasicInfo ¶
GetBasicInfo 获取设备基础信息(WS-Discovery结果)
func (*Client) GetEndpoint ¶
GetEndpoint 获取服务能力节点/地址URL
func (*Client) GetHttpClient ¶
GetHttpClient 获取 HTTP 客户端
func (*Client) GetIncrementNonceCount ¶
GetIncrementNonceCount 获取并增加 nonce 计数器
func (*Client) GetServiceName ¶
GetServiceName 从方法类型获取服务名称
func (*Client) GetServices ¶
GetServices 获取服务能力节点/地址列表
func (*Client) GetSupportedServices ¶
GetSupportedServices 从 GetCapabilities(设备能力信息)请求方法响应中获取支持的服务列表[节点信息]
func (*Client) ParseAuthHeader ¶
func (cli *Client) ParseAuthHeader(header string) (scheme string, Config map[string]string, err error)
ParseAuthHeader 解析 WWW-Authenticate 头部
func (*Client) SetHttpClient ¶
SetHttpClient 设置 HTTP 客户端
type Config ¶
type Config struct {
XAddr string `json:"xaddr"` // 基础地址
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
Debug bool `json:"debug"` // 调试模式
Timeout time.Duration `json:"timeout"` // 超时时间
}
Config 设备连接配置
type DigestNonceContext ¶
DigestNonceContext 存储摘要认证的上下文信息
Click to show internal directories.
Click to hide internal directories.