Add verified camera settings, family version recovery and account self service
This commit is contained in:
@@ -13,6 +13,12 @@ MEDIA = 'http://www.onvif.org/ver10/media/wsdl'
|
||||
SCHEMA = 'http://www.onvif.org/ver10/schema'
|
||||
|
||||
|
||||
class NoRedirect(urllib.request.HTTPRedirectHandler):
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
# Camera services must stay on the validated device endpoint.
|
||||
return None
|
||||
|
||||
|
||||
def request(host, port, endpoint, namespace, operation, content, username, password):
|
||||
created = dt.datetime.now(dt.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
nonce = secrets.token_bytes(16)
|
||||
@@ -30,7 +36,7 @@ def request(host, port, endpoint, namespace, operation, content, username, passw
|
||||
target = 'http://' + host + ':' + str(port) + endpoint
|
||||
passwords = urllib.request.HTTPPasswordMgrWithDefaultRealm()
|
||||
passwords.add_password(None, target, username, password)
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), urllib.request.HTTPDigestAuthHandler(passwords))
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect(), urllib.request.HTTPDigestAuthHandler(passwords))
|
||||
req = urllib.request.Request(target, data=envelope.encode(), headers={
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8; action="' + namespace + '/' + operation + '"'})
|
||||
with opener.open(req, timeout=5) as response:
|
||||
|
||||
Reference in New Issue
Block a user