17.12
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
###############################################################################
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) Crossbar.io Technologies GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from autobahn.wamp.types import \
|
||||
ComponentConfig, \
|
||||
SessionDetails, \
|
||||
CloseDetails, \
|
||||
RegisterOptions, \
|
||||
CallOptions, \
|
||||
CallDetails, \
|
||||
CallResult, \
|
||||
SubscribeOptions, \
|
||||
PublishOptions, \
|
||||
EventDetails
|
||||
|
||||
from autobahn.wamp.exception import \
|
||||
Error, \
|
||||
SessionNotReady, \
|
||||
SerializationError, \
|
||||
ProtocolError, \
|
||||
TransportLost, \
|
||||
ApplicationError, \
|
||||
InvalidUri
|
||||
|
||||
from autobahn.wamp.interfaces import ISession
|
||||
|
||||
from autobahn.wamp.uri import \
|
||||
error, \
|
||||
register, \
|
||||
subscribe
|
||||
|
||||
|
||||
__all__ = (
|
||||
'ComponentConfig',
|
||||
'SessionDetails',
|
||||
'CloseDetails',
|
||||
'RegisterOptions',
|
||||
'CallOptions',
|
||||
'CallDetails',
|
||||
'CallResult',
|
||||
'SubscribeOptions',
|
||||
'PublishOptions',
|
||||
'EventDetails',
|
||||
|
||||
'Error',
|
||||
'SessionNotReady',
|
||||
'SerializationError',
|
||||
'ProtocolError',
|
||||
'TransportLost',
|
||||
'ApplicationError',
|
||||
'InvalidUri',
|
||||
|
||||
'ISession',
|
||||
|
||||
'error',
|
||||
'register',
|
||||
'subscribe',
|
||||
)
|
||||
@@ -0,0 +1,314 @@
|
||||
###############################################################################
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) Crossbar.io Technologies GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
|
||||
from autobahn.util import public
|
||||
from autobahn.wamp.uri import error
|
||||
|
||||
__all__ = (
|
||||
'Error',
|
||||
'SessionNotReady',
|
||||
'SerializationError',
|
||||
'ProtocolError',
|
||||
'TransportLost',
|
||||
'ApplicationError',
|
||||
'NotAuthorized',
|
||||
'InvalidUri',
|
||||
)
|
||||
|
||||
|
||||
@public
|
||||
class Error(RuntimeError):
|
||||
"""
|
||||
Base class for all exceptions related to WAMP.
|
||||
"""
|
||||
|
||||
|
||||
@public
|
||||
class SessionNotReady(Error):
|
||||
"""
|
||||
The application tried to perform a WAMP interaction, but the
|
||||
session is not yet fully established.
|
||||
"""
|
||||
|
||||
|
||||
@public
|
||||
class SerializationError(Error):
|
||||
"""
|
||||
Exception raised when the WAMP serializer could not serialize the
|
||||
application payload (``args`` or ``kwargs`` for ``CALL``, ``PUBLISH``, etc).
|
||||
"""
|
||||
|
||||
|
||||
@public
|
||||
class InvalidUriError(Error):
|
||||
"""
|
||||
Exception raised when an invalid WAMP URI was used.
|
||||
"""
|
||||
|
||||
|
||||
@public
|
||||
class ProtocolError(Error):
|
||||
"""
|
||||
Exception raised when WAMP protocol was violated. Protocol errors
|
||||
are fatal and are handled by the WAMP implementation. They are
|
||||
not supposed to be handled at the application level.
|
||||
"""
|
||||
|
||||
|
||||
@public
|
||||
class TransportLost(Error):
|
||||
"""
|
||||
Exception raised when the transport underlying the WAMP session
|
||||
was lost or is not connected.
|
||||
"""
|
||||
|
||||
|
||||
@public
|
||||
class ApplicationError(Error):
|
||||
"""
|
||||
Base class for all exceptions that can/may be handled
|
||||
at the application level.
|
||||
"""
|
||||
|
||||
INVALID_URI = u"wamp.error.invalid_uri"
|
||||
"""
|
||||
Peer provided an incorrect URI for a URI-based attribute of a WAMP message
|
||||
such as a realm, topic or procedure.
|
||||
"""
|
||||
|
||||
INVALID_PAYLOAD = u"wamp.error.invalid_payload"
|
||||
"""
|
||||
The application payload could not be serialized.
|
||||
"""
|
||||
|
||||
PAYLOAD_SIZE_EXCEEDED = u"wamp.error.payload_size_exceeded"
|
||||
"""
|
||||
The application payload could not be transported becuase the serialized/framed payload
|
||||
exceeds the transport limits.
|
||||
"""
|
||||
|
||||
NO_SUCH_PROCEDURE = u"wamp.error.no_such_procedure"
|
||||
"""
|
||||
A Dealer could not perform a call, since not procedure is currently registered
|
||||
under the given URI.
|
||||
"""
|
||||
|
||||
PROCEDURE_ALREADY_EXISTS = u"wamp.error.procedure_already_exists"
|
||||
"""
|
||||
A procedure could not be registered, since a procedure with the given URI is
|
||||
already registered.
|
||||
"""
|
||||
|
||||
PROCEDURE_EXISTS_INVOCATION_POLICY_CONFLICT = u"wamp.error.procedure_exists_with_different_invocation_policy"
|
||||
"""
|
||||
A procedure could not be registered, since a procedure with the given URI is
|
||||
already registered, and the registration has a conflicting invocation policy.
|
||||
"""
|
||||
|
||||
NO_SUCH_REGISTRATION = u"wamp.error.no_such_registration"
|
||||
"""
|
||||
A Dealer could not perform a unregister, since the given registration is not active.
|
||||
"""
|
||||
|
||||
NO_SUCH_SUBSCRIPTION = u"wamp.error.no_such_subscription"
|
||||
"""
|
||||
A Broker could not perform a unsubscribe, since the given subscription is not active.
|
||||
"""
|
||||
|
||||
NO_SUCH_SESSION = u"wamp.error.no_such_session"
|
||||
"""
|
||||
A router could not perform an operation, since a session ID specified was non-existant.
|
||||
"""
|
||||
|
||||
INVALID_ARGUMENT = u"wamp.error.invalid_argument"
|
||||
"""
|
||||
A call failed, since the given argument types or values are not acceptable to the
|
||||
called procedure - in which case the *Callee* may throw this error. Or a Router
|
||||
performing *payload validation* checked the payload (``args`` / ``kwargs``) of a call,
|
||||
call result, call error or publish, and the payload did not conform.
|
||||
"""
|
||||
|
||||
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
|
||||
SYSTEM_SHUTDOWN = u"wamp.error.system_shutdown"
|
||||
"""
|
||||
The *Peer* is shutting down completely - used as a ``GOODBYE`` (or ``ABORT``) reason.
|
||||
"""
|
||||
|
||||
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
|
||||
CLOSE_REALM = u"wamp.error.close_realm"
|
||||
"""
|
||||
The *Peer* want to leave the realm - used as a ``GOODBYE`` reason.
|
||||
"""
|
||||
|
||||
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
|
||||
GOODBYE_AND_OUT = u"wamp.error.goodbye_and_out"
|
||||
"""
|
||||
A *Peer* acknowledges ending of a session - used as a ``GOOBYE`` reply reason.
|
||||
"""
|
||||
|
||||
NOT_AUTHORIZED = u"wamp.error.not_authorized"
|
||||
"""
|
||||
A call, register, publish or subscribe failed, since the session is not authorized
|
||||
to perform the operation.
|
||||
"""
|
||||
|
||||
AUTHORIZATION_FAILED = u"wamp.error.authorization_failed"
|
||||
"""
|
||||
A Dealer or Broker could not determine if the *Peer* is authorized to perform
|
||||
a join, call, register, publish or subscribe, since the authorization operation
|
||||
*itself* failed. E.g. a custom authorizer did run into an error.
|
||||
"""
|
||||
|
||||
AUTHENTICATION_FAILED = u"wamp.error.authentication_failed"
|
||||
"""
|
||||
Something failed with the authentication itself, that is, authentication could
|
||||
not run to end.
|
||||
"""
|
||||
|
||||
NO_AUTH_METHOD = u"wamp.error.no_auth_method"
|
||||
"""
|
||||
No authentication method the peer offered is available or active.
|
||||
"""
|
||||
|
||||
NO_SUCH_REALM = u"wamp.error.no_such_realm"
|
||||
"""
|
||||
Peer wanted to join a non-existing realm (and the *Router* did not allow to auto-create
|
||||
the realm).
|
||||
"""
|
||||
|
||||
NO_SUCH_ROLE = u"wamp.error.no_such_role"
|
||||
"""
|
||||
A *Peer* was to be authenticated under a Role that does not (or no longer) exists on the Router.
|
||||
For example, the *Peer* was successfully authenticated, but the Role configured does not
|
||||
exists - hence there is some misconfiguration in the Router.
|
||||
"""
|
||||
|
||||
NO_SUCH_PRINCIPAL = u"wamp.error.no_such_principal"
|
||||
"""
|
||||
A *Peer* was authenticated for an authid that does not or longer exists.
|
||||
"""
|
||||
|
||||
CANCELED = u"wamp.error.canceled"
|
||||
"""
|
||||
A Dealer or Callee canceled a call previously issued (WAMP AP).
|
||||
"""
|
||||
|
||||
TIMEOUT = u"wamp.error.timeout"
|
||||
"""
|
||||
A pending (in-flight) call was timed out.
|
||||
"""
|
||||
|
||||
# FIXME: this currently isn't used neither in Autobahn nor Crossbar. Check!
|
||||
NO_ELIGIBLE_CALLEE = u"wamp.error.no_eligible_callee"
|
||||
"""
|
||||
A *Dealer* could not perform a call, since a procedure with the given URI is registered,
|
||||
but *Callee Black- and Whitelisting* and/or *Caller Exclusion* lead to the
|
||||
exclusion of (any) *Callee* providing the procedure (WAMP AP).
|
||||
"""
|
||||
|
||||
ENC_NO_PAYLOAD_CODEC = u"wamp.error.no_payload_codec"
|
||||
"""
|
||||
WAMP message in payload transparency mode received, but no codec set
|
||||
or codec did not decode the payload.
|
||||
"""
|
||||
|
||||
ENC_TRUSTED_URI_MISMATCH = u"wamp.error.encryption.trusted_uri_mismatch"
|
||||
"""
|
||||
WAMP-cryptobox application payload end-to-end encryption error.
|
||||
"""
|
||||
|
||||
ENC_DECRYPT_ERROR = u"wamp.error.encryption.decrypt_error"
|
||||
"""
|
||||
WAMP-cryptobox application payload end-to-end encryption error.
|
||||
"""
|
||||
|
||||
def __init__(self, error, *args, **kwargs):
|
||||
"""
|
||||
|
||||
:param error: The URI of the error that occurred, e.g. ``wamp.error.not_authorized``.
|
||||
:type error: str
|
||||
"""
|
||||
Exception.__init__(self, *args)
|
||||
self.kwargs = kwargs
|
||||
self.error = error
|
||||
self.enc_algo = kwargs.pop('enc_algo', None)
|
||||
self.callee = kwargs.pop('callee', None)
|
||||
self.callee_authid = kwargs.pop('callee_authid', None)
|
||||
self.callee_authrole = kwargs.pop('callee_authrole', None)
|
||||
self.forward_for = kwargs.pop('forward_for', None)
|
||||
|
||||
@public
|
||||
def error_message(self):
|
||||
"""
|
||||
Get the error message of this exception.
|
||||
|
||||
:returns: The error message.
|
||||
:rtype: str
|
||||
"""
|
||||
return u'{0}: {1}'.format(
|
||||
self.error,
|
||||
u' '.join([six.text_type(a) for a in self.args]),
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
if self.kwargs and 'traceback' in self.kwargs:
|
||||
tb = u':\n' + u'\n'.join(self.kwargs.pop('traceback')) + u'\n'
|
||||
self.kwargs['traceback'] = u'...'
|
||||
else:
|
||||
tb = u''
|
||||
return u"ApplicationError(error=<{0}>, args={1}, kwargs={2}, enc_algo={3}, callee={4}, callee_authid={5}, callee_authrole={6}, forward_for={7}){8}".format(
|
||||
self.error, list(self.args), self.kwargs, self.enc_algo, self.callee, self.callee_authid, self.callee_authrole, self.forward_for, tb)
|
||||
|
||||
def __str__(self):
|
||||
if six.PY3:
|
||||
return self.__unicode__()
|
||||
else:
|
||||
return self.__unicode__().encode('utf8')
|
||||
|
||||
|
||||
@error(ApplicationError.NOT_AUTHORIZED)
|
||||
class NotAuthorized(Exception):
|
||||
"""
|
||||
Not authorized to perform the respective action.
|
||||
"""
|
||||
|
||||
|
||||
@error(ApplicationError.INVALID_URI)
|
||||
class InvalidUri(Exception):
|
||||
"""
|
||||
The URI for a topic, procedure or error is not a valid WAMP URI.
|
||||
"""
|
||||
|
||||
|
||||
@error(ApplicationError.INVALID_PAYLOAD)
|
||||
class InvalidPayload(Exception):
|
||||
"""
|
||||
The URI for a topic, procedure or error is not a valid WAMP URI.
|
||||
"""
|
||||
Binary file not shown.
@@ -0,0 +1,38 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: wamp
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Map(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsMap(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Map()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Map
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Map
|
||||
def Key(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Map
|
||||
def Value(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
def MapStart(builder): builder.StartObject(2)
|
||||
def MapAddKey(builder, key): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(key), 0)
|
||||
def MapAddValue(builder, value): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0)
|
||||
def MapEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,22 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: wamp
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Void(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsVoid(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Void()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Void
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
def VoidStart(builder): builder.StartObject(0)
|
||||
def VoidEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,11 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class AuthFactor(object):
|
||||
NONE = 0
|
||||
AuthTicketRequest = 1
|
||||
AuthCraRequest = 2
|
||||
AuthScramRequest = 3
|
||||
AuthCryptosignRequest = 4
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class AuthMode(object):
|
||||
FIRST = 0
|
||||
MULTIFACTOR = 1
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class AuthTicketChallenge(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsAuthTicketChallenge(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = AuthTicketChallenge()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# AuthTicketChallenge
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
def AuthTicketChallengeStart(builder): builder.StartObject(0)
|
||||
def AuthTicketChallengeEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,22 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class AuthTicketRequest(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsAuthTicketRequest(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = AuthTicketRequest()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# AuthTicketRequest
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
def AuthTicketRequestStart(builder): builder.StartObject(0)
|
||||
def AuthTicketRequestEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,102 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class CalleeFeatures(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsCalleeFeatures(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = CalleeFeatures()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# CalleeFeatures
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# CalleeFeatures
|
||||
def CallerIdentification(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def CallTrustlevels(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def CallTimeout(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def CallCanceling(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def ProgressiveCallResults(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def RegistrationRevocation(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def PatternBasedRegistration(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def SharedRegistration(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def PayloadTransparency(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CalleeFeatures
|
||||
def PayloadEncryptionCryptobox(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
def CalleeFeaturesStart(builder): builder.StartObject(10)
|
||||
def CalleeFeaturesAddCallerIdentification(builder, callerIdentification): builder.PrependBoolSlot(0, callerIdentification, 0)
|
||||
def CalleeFeaturesAddCallTrustlevels(builder, callTrustlevels): builder.PrependBoolSlot(1, callTrustlevels, 0)
|
||||
def CalleeFeaturesAddCallTimeout(builder, callTimeout): builder.PrependBoolSlot(2, callTimeout, 0)
|
||||
def CalleeFeaturesAddCallCanceling(builder, callCanceling): builder.PrependBoolSlot(3, callCanceling, 0)
|
||||
def CalleeFeaturesAddProgressiveCallResults(builder, progressiveCallResults): builder.PrependBoolSlot(4, progressiveCallResults, 0)
|
||||
def CalleeFeaturesAddRegistrationRevocation(builder, registrationRevocation): builder.PrependBoolSlot(5, registrationRevocation, 0)
|
||||
def CalleeFeaturesAddPatternBasedRegistration(builder, patternBasedRegistration): builder.PrependBoolSlot(6, patternBasedRegistration, 0)
|
||||
def CalleeFeaturesAddSharedRegistration(builder, sharedRegistration): builder.PrependBoolSlot(7, sharedRegistration, 0)
|
||||
def CalleeFeaturesAddPayloadTransparency(builder, payloadTransparency): builder.PrependBoolSlot(8, payloadTransparency, 0)
|
||||
def CalleeFeaturesAddPayloadEncryptionCryptobox(builder, payloadEncryptionCryptobox): builder.PrependBoolSlot(9, payloadEncryptionCryptobox, 0)
|
||||
def CalleeFeaturesEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,70 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class CallerFeatures(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsCallerFeatures(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = CallerFeatures()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# CallerFeatures
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# CallerFeatures
|
||||
def CallerIdentification(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CallerFeatures
|
||||
def CallTimeout(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CallerFeatures
|
||||
def CallCanceling(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CallerFeatures
|
||||
def ProgressiveCallResults(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CallerFeatures
|
||||
def PayloadTransparency(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# CallerFeatures
|
||||
def PayloadEncryptionCryptobox(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
def CallerFeaturesStart(builder): builder.StartObject(6)
|
||||
def CallerFeaturesAddCallerIdentification(builder, callerIdentification): builder.PrependBoolSlot(0, callerIdentification, 0)
|
||||
def CallerFeaturesAddCallTimeout(builder, callTimeout): builder.PrependBoolSlot(1, callTimeout, 0)
|
||||
def CallerFeaturesAddCallCanceling(builder, callCanceling): builder.PrependBoolSlot(2, callCanceling, 0)
|
||||
def CallerFeaturesAddProgressiveCallResults(builder, progressiveCallResults): builder.PrependBoolSlot(3, progressiveCallResults, 0)
|
||||
def CallerFeaturesAddPayloadTransparency(builder, payloadTransparency): builder.PrependBoolSlot(4, payloadTransparency, 0)
|
||||
def CallerFeaturesAddPayloadEncryptionCryptobox(builder, payloadEncryptionCryptobox): builder.PrependBoolSlot(5, payloadEncryptionCryptobox, 0)
|
||||
def CallerFeaturesEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,9 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class CancelMode(object):
|
||||
SKIP = 0
|
||||
ABORT = 1
|
||||
KILL = 2
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Challenge(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsChallenge(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Challenge()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Challenge
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Challenge
|
||||
def Method(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Challenge
|
||||
def Extra(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from .Map import Map
|
||||
obj = Map()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
return None
|
||||
|
||||
def ChallengeStart(builder): builder.StartObject(2)
|
||||
def ChallengeAddMethod(builder, method): builder.PrependUint8Slot(0, method, 0)
|
||||
def ChallengeAddExtra(builder, extra): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(extra), 0)
|
||||
def ChallengeEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,8 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class ChannelBinding(object):
|
||||
NONE = 0
|
||||
TLS_UNIQUE = 1
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class DealerFeatures(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsDealerFeatures(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = DealerFeatures()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# DealerFeatures
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# DealerFeatures
|
||||
def CallerIdentification(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def CallTrustlevels(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def CallTimeout(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def CallCanceling(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def ProgressiveCallResults(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def RegistrationRevocation(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def PatternBasedRegistration(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def SharedRegistration(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def SessionMetaApi(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def RegistrationMetaApi(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def TestamentMetaApi(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def PayloadTransparency(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# DealerFeatures
|
||||
def PayloadEncryptionCryptobox(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
def DealerFeaturesStart(builder): builder.StartObject(13)
|
||||
def DealerFeaturesAddCallerIdentification(builder, callerIdentification): builder.PrependBoolSlot(0, callerIdentification, 0)
|
||||
def DealerFeaturesAddCallTrustlevels(builder, callTrustlevels): builder.PrependBoolSlot(1, callTrustlevels, 0)
|
||||
def DealerFeaturesAddCallTimeout(builder, callTimeout): builder.PrependBoolSlot(2, callTimeout, 0)
|
||||
def DealerFeaturesAddCallCanceling(builder, callCanceling): builder.PrependBoolSlot(3, callCanceling, 0)
|
||||
def DealerFeaturesAddProgressiveCallResults(builder, progressiveCallResults): builder.PrependBoolSlot(4, progressiveCallResults, 0)
|
||||
def DealerFeaturesAddRegistrationRevocation(builder, registrationRevocation): builder.PrependBoolSlot(5, registrationRevocation, 0)
|
||||
def DealerFeaturesAddPatternBasedRegistration(builder, patternBasedRegistration): builder.PrependBoolSlot(6, patternBasedRegistration, 0)
|
||||
def DealerFeaturesAddSharedRegistration(builder, sharedRegistration): builder.PrependBoolSlot(7, sharedRegistration, 0)
|
||||
def DealerFeaturesAddSessionMetaApi(builder, sessionMetaApi): builder.PrependBoolSlot(8, sessionMetaApi, 0)
|
||||
def DealerFeaturesAddRegistrationMetaApi(builder, registrationMetaApi): builder.PrependBoolSlot(9, registrationMetaApi, 0)
|
||||
def DealerFeaturesAddTestamentMetaApi(builder, testamentMetaApi): builder.PrependBoolSlot(10, testamentMetaApi, 0)
|
||||
def DealerFeaturesAddPayloadTransparency(builder, payloadTransparency): builder.PrependBoolSlot(11, payloadTransparency, 0)
|
||||
def DealerFeaturesAddPayloadEncryptionCryptobox(builder, payloadEncryptionCryptobox): builder.PrependBoolSlot(12, payloadEncryptionCryptobox, 0)
|
||||
def DealerFeaturesEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,110 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Error(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsError(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Error()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Error
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Error
|
||||
def RequestType(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint16Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def Request(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def Error(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Error
|
||||
def Payload(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def PayloadAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def PayloadLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def EncAlgo(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def EncSerializer(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def EncKey(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def EncKeyAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Error
|
||||
def EncKeyLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
def ErrorStart(builder): builder.StartObject(7)
|
||||
def ErrorAddRequestType(builder, requestType): builder.PrependUint16Slot(0, requestType, 0)
|
||||
def ErrorAddRequest(builder, request): builder.PrependUint64Slot(1, request, 0)
|
||||
def ErrorAddError(builder, error): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(error), 0)
|
||||
def ErrorAddPayload(builder, payload): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(payload), 0)
|
||||
def ErrorStartPayloadVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def ErrorAddEncAlgo(builder, encAlgo): builder.PrependUint8Slot(4, encAlgo, 0)
|
||||
def ErrorAddEncSerializer(builder, encSerializer): builder.PrependUint8Slot(5, encSerializer, 0)
|
||||
def ErrorAddEncKey(builder, encKey): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(encKey), 0)
|
||||
def ErrorStartEncKeyVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def ErrorEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,223 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Event(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsEvent(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Event()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Event
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Event
|
||||
def Subscription(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def Publication(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# /// Positional values for application-defined event payload.
|
||||
# Event
|
||||
def Args(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def ArgsAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def ArgsLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# /// Keyword values for application-defined event payload.
|
||||
# Event
|
||||
def Kwargs(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def KwargsAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def KwargsLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# /// Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset.
|
||||
# Event
|
||||
def Payload(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def PayloadAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def PayloadLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def EncAlgo(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def EncSerializer(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def EncKey(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def EncKeyAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def EncKeyLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def Publisher(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Event
|
||||
def PublisherAuthid(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Event
|
||||
def PublisherAuthrole(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(24))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Event
|
||||
def Topic(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(26))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Event
|
||||
def Retained(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(28))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# Event
|
||||
def Acknowledge(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(30))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# Event
|
||||
def ForwardFor(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32))
|
||||
if o != 0:
|
||||
x = self._tab.Vector(o)
|
||||
x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
|
||||
x = self._tab.Indirect(x)
|
||||
from .Principal import Principal
|
||||
obj = Principal()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
return None
|
||||
|
||||
# Event
|
||||
def ForwardForLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(32))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
def EventStart(builder): builder.StartObject(15)
|
||||
def EventAddSubscription(builder, subscription): builder.PrependUint64Slot(0, subscription, 0)
|
||||
def EventAddPublication(builder, publication): builder.PrependUint64Slot(1, publication, 0)
|
||||
def EventAddArgs(builder, args): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(args), 0)
|
||||
def EventStartArgsVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def EventAddKwargs(builder, kwargs): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(kwargs), 0)
|
||||
def EventStartKwargsVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def EventAddPayload(builder, payload): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(payload), 0)
|
||||
def EventStartPayloadVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def EventAddEncAlgo(builder, encAlgo): builder.PrependUint8Slot(5, encAlgo, 0)
|
||||
def EventAddEncSerializer(builder, encSerializer): builder.PrependUint8Slot(6, encSerializer, 0)
|
||||
def EventAddEncKey(builder, encKey): builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(encKey), 0)
|
||||
def EventStartEncKeyVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def EventAddPublisher(builder, publisher): builder.PrependUint64Slot(8, publisher, 0)
|
||||
def EventAddPublisherAuthid(builder, publisherAuthid): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(publisherAuthid), 0)
|
||||
def EventAddPublisherAuthrole(builder, publisherAuthrole): builder.PrependUOffsetTRelativeSlot(10, flatbuffers.number_types.UOffsetTFlags.py_type(publisherAuthrole), 0)
|
||||
def EventAddTopic(builder, topic): builder.PrependUOffsetTRelativeSlot(11, flatbuffers.number_types.UOffsetTFlags.py_type(topic), 0)
|
||||
def EventAddRetained(builder, retained): builder.PrependBoolSlot(12, retained, 0)
|
||||
def EventAddAcknowledge(builder, acknowledge): builder.PrependBoolSlot(13, acknowledge, 0)
|
||||
def EventAddForwardFor(builder, forwardFor): builder.PrependUOffsetTRelativeSlot(14, flatbuffers.number_types.UOffsetTFlags.py_type(forwardFor), 0)
|
||||
def EventStartForwardForVector(builder, numElems): return builder.StartVector(4, numElems, 4)
|
||||
def EventEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,94 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class EventReceived(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsEventReceived(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = EventReceived()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# EventReceived
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# EventReceived
|
||||
def Publication(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def Payload(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def PayloadAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def PayloadLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def EncAlgo(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def EncSerializer(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def EncKey(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def EncKeyAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# EventReceived
|
||||
def EncKeyLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
def EventReceivedStart(builder): builder.StartObject(5)
|
||||
def EventReceivedAddPublication(builder, publication): builder.PrependUint64Slot(0, publication, 0)
|
||||
def EventReceivedAddPayload(builder, payload): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(payload), 0)
|
||||
def EventReceivedStartPayloadVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def EventReceivedAddEncAlgo(builder, encAlgo): builder.PrependUint8Slot(2, encAlgo, 0)
|
||||
def EventReceivedAddEncSerializer(builder, encSerializer): builder.PrependUint8Slot(3, encSerializer, 0)
|
||||
def EventReceivedAddEncKey(builder, encKey): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(encKey), 0)
|
||||
def EventReceivedStartEncKeyVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def EventReceivedEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,118 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Hello(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsHello(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Hello()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Hello
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Hello
|
||||
def Roles(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from .ClientRoles import ClientRoles
|
||||
obj = ClientRoles()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
return None
|
||||
|
||||
# Hello
|
||||
def Realm(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Hello
|
||||
def Authmethods(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Hello
|
||||
def AuthmethodsAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Hello
|
||||
def AuthmethodsLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# Hello
|
||||
def Authid(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Hello
|
||||
def Authrole(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
# Hello
|
||||
def Authextra(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from .Map import Map
|
||||
obj = Map()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
return None
|
||||
|
||||
# Hello
|
||||
def Resumable(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# Hello
|
||||
def ResumeSession(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Hello
|
||||
def ResumeToken(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
|
||||
if o != 0:
|
||||
return self._tab.String(o + self._tab.Pos)
|
||||
return None
|
||||
|
||||
def HelloStart(builder): builder.StartObject(9)
|
||||
def HelloAddRoles(builder, roles): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(roles), 0)
|
||||
def HelloAddRealm(builder, realm): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(realm), 0)
|
||||
def HelloAddAuthmethods(builder, authmethods): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(authmethods), 0)
|
||||
def HelloStartAuthmethodsVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def HelloAddAuthid(builder, authid): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(authid), 0)
|
||||
def HelloAddAuthrole(builder, authrole): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(authrole), 0)
|
||||
def HelloAddAuthextra(builder, authextra): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(authextra), 0)
|
||||
def HelloAddResumable(builder, resumable): builder.PrependBoolSlot(6, resumable, 0)
|
||||
def HelloAddResumeSession(builder, resumeSession): builder.PrependUint64Slot(7, resumeSession, 0)
|
||||
def HelloAddResumeToken(builder, resumeToken): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(resumeToken), 0)
|
||||
def HelloEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,38 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Interrupt(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsInterrupt(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Interrupt()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Interrupt
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Interrupt
|
||||
def Request(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Interrupt
|
||||
def Mode(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 1
|
||||
|
||||
def InterruptStart(builder): builder.StartObject(2)
|
||||
def InterruptAddRequest(builder, request): builder.PrependUint64Slot(0, request, 0)
|
||||
def InterruptAddMode(builder, mode): builder.PrependUint8Slot(1, mode, 1)
|
||||
def InterruptEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,9 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class Kdf(object):
|
||||
NONE = 0
|
||||
PBKDF2 = 1
|
||||
ARGON2 = 2
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class Match(object):
|
||||
EXACT = 0
|
||||
PREFIX = 1
|
||||
WILDCARD = 2
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class PublisherFeatures(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsPublisherFeatures(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = PublisherFeatures()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# PublisherFeatures
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# PublisherFeatures
|
||||
def PublisherIdentification(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# PublisherFeatures
|
||||
def PublisherExclusion(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# PublisherFeatures
|
||||
def SubscriberBlackwhiteListing(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# PublisherFeatures
|
||||
def AcknowledgeEventReceived(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# PublisherFeatures
|
||||
def PayloadTransparency(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
# PublisherFeatures
|
||||
def PayloadEncryptionCryptobox(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
|
||||
if o != 0:
|
||||
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
|
||||
return False
|
||||
|
||||
def PublisherFeaturesStart(builder): builder.StartObject(6)
|
||||
def PublisherFeaturesAddPublisherIdentification(builder, publisherIdentification): builder.PrependBoolSlot(0, publisherIdentification, 0)
|
||||
def PublisherFeaturesAddPublisherExclusion(builder, publisherExclusion): builder.PrependBoolSlot(1, publisherExclusion, 0)
|
||||
def PublisherFeaturesAddSubscriberBlackwhiteListing(builder, subscriberBlackwhiteListing): builder.PrependBoolSlot(2, subscriberBlackwhiteListing, 0)
|
||||
def PublisherFeaturesAddAcknowledgeEventReceived(builder, acknowledgeEventReceived): builder.PrependBoolSlot(3, acknowledgeEventReceived, 0)
|
||||
def PublisherFeaturesAddPayloadTransparency(builder, payloadTransparency): builder.PrependBoolSlot(4, payloadTransparency, 0)
|
||||
def PublisherFeaturesAddPayloadEncryptionCryptobox(builder, payloadEncryptionCryptobox): builder.PrependBoolSlot(5, payloadEncryptionCryptobox, 0)
|
||||
def PublisherFeaturesEnd(builder): return builder.EndObject()
|
||||
@@ -0,0 +1,13 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
class Serializer(object):
|
||||
TRANSPORT = 0
|
||||
JSON = 1
|
||||
MSGPACK = 2
|
||||
CBOR = 3
|
||||
UBJSON = 4
|
||||
OPAQUE = 5
|
||||
FLATBUFFERS = 6
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: proto
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Yield(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
@classmethod
|
||||
def GetRootAsYield(cls, buf, offset):
|
||||
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
|
||||
x = Yield()
|
||||
x.Init(buf, n + offset)
|
||||
return x
|
||||
|
||||
# Yield
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# Yield
|
||||
def Request(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def Payload(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def PayloadAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def PayloadLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def EncAlgo(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def EncSerializer(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def EncKey(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def EncKeyAsNumpy(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
|
||||
return 0
|
||||
|
||||
# Yield
|
||||
def EncKeyLength(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
def YieldStart(builder): builder.StartObject(5)
|
||||
def YieldAddRequest(builder, request): builder.PrependUint64Slot(0, request, 0)
|
||||
def YieldAddPayload(builder, payload): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(payload), 0)
|
||||
def YieldStartPayloadVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def YieldAddEncAlgo(builder, encAlgo): builder.PrependUint8Slot(2, encAlgo, 0)
|
||||
def YieldAddEncSerializer(builder, encSerializer): builder.PrependUint8Slot(3, encSerializer, 0)
|
||||
def YieldAddEncKey(builder, encKey): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(encKey), 0)
|
||||
def YieldStartEncKeyVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def YieldEnd(builder): return builder.EndObject()
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
###############################################################################
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) Crossbar.io Technologies GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from autobahn.wamp import cryptobox
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
@unittest.skipIf(not cryptobox.HAS_CRYPTOBOX, 'no cryptobox support present')
|
||||
class TestCryptoBox(unittest.TestCase):
|
||||
|
||||
def test_create_keyring(self):
|
||||
kr = cryptobox.KeyRing()
|
||||
assert kr
|
||||
@@ -0,0 +1,127 @@
|
||||
###############################################################################
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) Crossbar.io Technologies GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from mock import Mock
|
||||
|
||||
import txaio
|
||||
|
||||
if os.environ.get('USE_TWISTED', False):
|
||||
txaio.use_twisted()
|
||||
elif os.environ.get('USE_ASYNCIO', False):
|
||||
txaio.use_asyncio()
|
||||
else:
|
||||
raise Exception('no networking framework selected')
|
||||
|
||||
from autobahn.wamp.cryptosign import _makepad, HAS_CRYPTOSIGN
|
||||
from autobahn.wamp import types
|
||||
from autobahn.wamp.auth import create_authenticator
|
||||
|
||||
if HAS_CRYPTOSIGN:
|
||||
from autobahn.wamp.cryptosign import SigningKey
|
||||
from nacl.encoding import HexEncoder
|
||||
|
||||
import tempfile
|
||||
|
||||
import unittest
|
||||
|
||||
keybody = '''-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
QyNTUxOQAAACAa38i/4dNWFuZN/72QAJbyOwZvkUyML/u2b2B1uW4RbQAAAJj4FLyB+BS8
|
||||
gQAAAAtzc2gtZWQyNTUxOQAAACAa38i/4dNWFuZN/72QAJbyOwZvkUyML/u2b2B1uW4RbQ
|
||||
AAAEBNV9l6aPVVaWYgpthJwM5YJWhRjXKet1PcfHMt4oBFEBrfyL/h01YW5k3/vZAAlvI7
|
||||
Bm+RTIwv+7ZvYHW5bhFtAAAAFXNvbWV1c2VyQGZ1bmt0aGF0LmNvbQ==
|
||||
-----END OPENSSH PRIVATE KEY-----'''
|
||||
|
||||
pubkey = '''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJVp3hjHwIQyEladzd8mFcf0YSXcmyKS3qMLB7VqTQKm someuser@example.com
|
||||
'''
|
||||
|
||||
|
||||
@unittest.skipIf(not HAS_CRYPTOSIGN, 'nacl library not present')
|
||||
class TestAuth(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.key = SigningKey.from_ssh_data(keybody)
|
||||
self.privkey_hex = self.key._key.encode(encoder=HexEncoder)
|
||||
m = hashlib.sha256()
|
||||
m.update("some TLS message".encode())
|
||||
self.channel_id = m.digest()
|
||||
|
||||
def test_valid(self):
|
||||
session = Mock()
|
||||
session._transport.get_channel_id = Mock(return_value=self.channel_id)
|
||||
challenge = types.Challenge(u"ticket", dict(challenge="ff" * 32))
|
||||
signed = yield self.key.sign_challenge(session, challenge)
|
||||
self.assertEqual(
|
||||
u'9b6f41540c9b95b4b7b281c3042fa9c54cef43c842d62ea3fd6030fcb66e70b3e80d49d44c29d1635da9348d02ec93f3ed1ef227dfb59a07b580095c2b82f80f9d16ca518aa0c2b707f2b2a609edeca73bca8dd59817a633f35574ac6fd80d00',
|
||||
signed.result,
|
||||
)
|
||||
|
||||
def test_authenticator(self):
|
||||
authenticator = create_authenticator(
|
||||
u"cryptosign",
|
||||
authid="someone",
|
||||
privkey=self.privkey_hex,
|
||||
)
|
||||
session = Mock()
|
||||
session._transport.get_channel_id = Mock(return_value=self.channel_id)
|
||||
challenge = types.Challenge(u"cryptosign", dict(challenge="ff" * 32))
|
||||
reply = yield authenticator.on_challenge(session, challenge)
|
||||
self.assertEqual(
|
||||
reply.result,
|
||||
u'9b6f41540c9b95b4b7b281c3042fa9c54cef43c842d62ea3fd6030fcb66e70b3e80d49d44c29d1635da9348d02ec93f3ed1ef227dfb59a07b580095c2b82f80f9d16ca518aa0c2b707f2b2a609edeca73bca8dd59817a633f35574ac6fd80d00',
|
||||
)
|
||||
|
||||
|
||||
class TestKey(unittest.TestCase):
|
||||
|
||||
def test_pad(self):
|
||||
self.assertEqual(_makepad(0), '')
|
||||
self.assertEqual(_makepad(2), '\x01\x02')
|
||||
self.assertEqual(_makepad(3), '\x01\x02\x03')
|
||||
|
||||
@unittest.skipIf(not HAS_CRYPTOSIGN, 'nacl library not present')
|
||||
def test_key(self):
|
||||
with tempfile.NamedTemporaryFile('w+t') as fp:
|
||||
fp.write(keybody)
|
||||
fp.seek(0)
|
||||
|
||||
key = SigningKey.from_ssh_key(fp.name)
|
||||
self.assertEqual(key.public_key(), '1adfc8bfe1d35616e64dffbd900096f23b066f914c8c2ffbb66f6075b96e116d')
|
||||
|
||||
@unittest.skipIf(not HAS_CRYPTOSIGN, 'nacl library not present')
|
||||
def test_pubkey(self):
|
||||
with tempfile.NamedTemporaryFile('w+t') as fp:
|
||||
fp.write(pubkey)
|
||||
fp.seek(0)
|
||||
|
||||
key = SigningKey.from_ssh_key(fp.name)
|
||||
self.assertEqual(key.public_key(), '9569de18c7c0843212569dcddf2615c7f46125dc9b2292dea30b07b56a4d02a6')
|
||||
self.assertEqual(key.comment(), 'someuser@example.com')
|
||||
@@ -0,0 +1,580 @@
|
||||
###############################################################################
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) Crossbar.io Technologies GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from autobahn import wamp
|
||||
from autobahn.wamp.uri import Pattern, RegisterOptions, SubscribeOptions
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class TestUris(unittest.TestCase):
|
||||
|
||||
def test_invalid_uris(self):
|
||||
for u in [u"",
|
||||
u"com.myapp.<product:foo>.update",
|
||||
u"com.myapp.<123:int>.update",
|
||||
u"com.myapp.<:product>.update",
|
||||
u"com.myapp.<product:>.update",
|
||||
u"com.myapp.<int:>.update",
|
||||
]:
|
||||
self.assertRaises(Exception, Pattern, u, Pattern.URI_TARGET_ENDPOINT)
|
||||
|
||||
def test_valid_uris(self):
|
||||
for u in [u"com.myapp.proc1",
|
||||
u"123",
|
||||
u"com.myapp.<product:int>.update",
|
||||
u"com.myapp.<category:string>.<subcategory>.list"
|
||||
u"com.myapp.something..update"
|
||||
]:
|
||||
p = Pattern(u, Pattern.URI_TARGET_ENDPOINT)
|
||||
self.assertIsInstance(p, Pattern)
|
||||
|
||||
def test_parse_uris(self):
|
||||
tests = [
|
||||
(u"com.myapp.<product:int>.update", [
|
||||
(u"com.myapp.0.update", {u'product': 0}),
|
||||
(u"com.myapp.123456.update", {u'product': 123456}),
|
||||
(u"com.myapp.aaa.update", None),
|
||||
(u"com.myapp..update", None),
|
||||
(u"com.myapp.0.delete", None),
|
||||
]
|
||||
),
|
||||
(u"com.myapp.<product:string>.update", [
|
||||
(u"com.myapp.box.update", {u'product': u'box'}),
|
||||
(u"com.myapp.123456.update", {u'product': u'123456'}),
|
||||
(u"com.myapp..update", None),
|
||||
]
|
||||
),
|
||||
(u"com.myapp.<product>.update", [
|
||||
(u"com.myapp.0.update", {u'product': u'0'}),
|
||||
(u"com.myapp.abc.update", {u'product': u'abc'}),
|
||||
(u"com.myapp..update", None),
|
||||
]
|
||||
),
|
||||
(u"com.myapp.<category:string>.<subcategory:string>.list", [
|
||||
(u"com.myapp.cosmetic.shampoo.list", {u'category': u'cosmetic', u'subcategory': u'shampoo'}),
|
||||
(u"com.myapp...list", None),
|
||||
(u"com.myapp.cosmetic..list", None),
|
||||
(u"com.myapp..shampoo.list", None),
|
||||
]
|
||||
)
|
||||
]
|
||||
for test in tests:
|
||||
pat = Pattern(test[0], Pattern.URI_TARGET_ENDPOINT)
|
||||
for ptest in test[1]:
|
||||
uri = ptest[0]
|
||||
kwargs_should = ptest[1]
|
||||
if kwargs_should is not None:
|
||||
args_is, kwargs_is = pat.match(uri)
|
||||
self.assertEqual(kwargs_is, kwargs_should)
|
||||
else:
|
||||
self.assertRaises(Exception, pat.match, uri)
|
||||
|
||||
|
||||
class TestDecorators(unittest.TestCase):
|
||||
|
||||
def test_decorate_endpoint(self):
|
||||
|
||||
@wamp.register(u"com.calculator.square")
|
||||
def square(_):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(square, '_wampuris'))
|
||||
self.assertTrue(type(square._wampuris) == list)
|
||||
self.assertEqual(len(square._wampuris), 1)
|
||||
self.assertIsInstance(square._wampuris[0], Pattern)
|
||||
self.assertTrue(square._wampuris[0].is_endpoint())
|
||||
self.assertFalse(square._wampuris[0].is_handler())
|
||||
self.assertFalse(square._wampuris[0].is_exception())
|
||||
self.assertEqual(square._wampuris[0].uri(), u"com.calculator.square")
|
||||
self.assertEqual(square._wampuris[0]._type, Pattern.URI_TYPE_EXACT)
|
||||
|
||||
@wamp.register(u"com.myapp.product.<product:int>.update")
|
||||
def update_product(product=None, label=None):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(update_product, '_wampuris'))
|
||||
self.assertTrue(type(update_product._wampuris) == list)
|
||||
self.assertEqual(len(update_product._wampuris), 1)
|
||||
self.assertIsInstance(update_product._wampuris[0], Pattern)
|
||||
self.assertTrue(update_product._wampuris[0].is_endpoint())
|
||||
self.assertFalse(update_product._wampuris[0].is_handler())
|
||||
self.assertFalse(update_product._wampuris[0].is_exception())
|
||||
self.assertEqual(update_product._wampuris[0].uri(), u"com.myapp.product.<product:int>.update")
|
||||
self.assertEqual(update_product._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
@wamp.register(u"com.myapp.<category:string>.<cid:int>.update")
|
||||
def update(category=None, cid=None):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(update, '_wampuris'))
|
||||
self.assertTrue(type(update._wampuris) == list)
|
||||
self.assertEqual(len(update._wampuris), 1)
|
||||
self.assertIsInstance(update._wampuris[0], Pattern)
|
||||
self.assertTrue(update._wampuris[0].is_endpoint())
|
||||
self.assertFalse(update._wampuris[0].is_handler())
|
||||
self.assertFalse(update._wampuris[0].is_exception())
|
||||
self.assertEqual(update._wampuris[0].uri(), u"com.myapp.<category:string>.<cid:int>.update")
|
||||
self.assertEqual(update._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
@wamp.register(u"com.myapp.circle.<name:string>",
|
||||
RegisterOptions(match=u"wildcard", details_arg="details"))
|
||||
def circle(name=None, details=None):
|
||||
""" Do nothing. """
|
||||
|
||||
self.assertTrue(hasattr(circle, '_wampuris'))
|
||||
self.assertTrue(type(circle._wampuris) == list)
|
||||
self.assertEqual(len(circle._wampuris), 1)
|
||||
self.assertIsInstance(circle._wampuris[0], Pattern)
|
||||
self.assertIsInstance(circle._wampuris[0].options, RegisterOptions)
|
||||
self.assertEqual(circle._wampuris[0].options.match, u"wildcard")
|
||||
self.assertEqual(circle._wampuris[0].options.details_arg, "details")
|
||||
self.assertTrue(circle._wampuris[0].is_endpoint())
|
||||
self.assertFalse(circle._wampuris[0].is_handler())
|
||||
self.assertFalse(circle._wampuris[0].is_exception())
|
||||
self.assertEqual(circle._wampuris[0].uri(), u"com.myapp.circle.<name:string>")
|
||||
self.assertEqual(circle._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
@wamp.register(u"com.myapp.something..update",
|
||||
RegisterOptions(match=u"wildcard", details_arg="details"))
|
||||
def something(dynamic=None, details=None):
|
||||
""" Do nothing. """
|
||||
self.assertTrue(hasattr(something, '_wampuris'))
|
||||
self.assertTrue(type(something._wampuris) == list)
|
||||
self.assertEqual(len(something._wampuris), 1)
|
||||
self.assertIsInstance(something._wampuris[0], Pattern)
|
||||
self.assertIsInstance(something._wampuris[0].options, RegisterOptions)
|
||||
self.assertEqual(something._wampuris[0].options.match, u"wildcard")
|
||||
self.assertEqual(something._wampuris[0].options.details_arg, "details")
|
||||
self.assertTrue(something._wampuris[0].is_endpoint())
|
||||
self.assertFalse(something._wampuris[0].is_handler())
|
||||
self.assertFalse(something._wampuris[0].is_exception())
|
||||
self.assertEqual(something._wampuris[0].uri(), u"com.myapp.something..update")
|
||||
self.assertEqual(something._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
def test_decorate_handler(self):
|
||||
|
||||
@wamp.subscribe(u"com.myapp.on_shutdown")
|
||||
def on_shutdown():
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(on_shutdown, '_wampuris'))
|
||||
self.assertTrue(type(on_shutdown._wampuris) == list)
|
||||
self.assertEqual(len(on_shutdown._wampuris), 1)
|
||||
self.assertIsInstance(on_shutdown._wampuris[0], Pattern)
|
||||
self.assertFalse(on_shutdown._wampuris[0].is_endpoint())
|
||||
self.assertTrue(on_shutdown._wampuris[0].is_handler())
|
||||
self.assertFalse(on_shutdown._wampuris[0].is_exception())
|
||||
self.assertEqual(on_shutdown._wampuris[0].uri(), u"com.myapp.on_shutdown")
|
||||
self.assertEqual(on_shutdown._wampuris[0]._type, Pattern.URI_TYPE_EXACT)
|
||||
|
||||
@wamp.subscribe(u"com.myapp.product.<product:int>.on_update")
|
||||
def on_product_update(product=None, label=None):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(on_product_update, '_wampuris'))
|
||||
self.assertTrue(type(on_product_update._wampuris) == list)
|
||||
self.assertEqual(len(on_product_update._wampuris), 1)
|
||||
self.assertIsInstance(on_product_update._wampuris[0], Pattern)
|
||||
self.assertFalse(on_product_update._wampuris[0].is_endpoint())
|
||||
self.assertTrue(on_product_update._wampuris[0].is_handler())
|
||||
self.assertFalse(on_product_update._wampuris[0].is_exception())
|
||||
self.assertEqual(on_product_update._wampuris[0].uri(), u"com.myapp.product.<product:int>.on_update")
|
||||
self.assertEqual(on_product_update._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
@wamp.subscribe(u"com.myapp.<category:string>.<cid:int>.on_update")
|
||||
def on_update(category=None, cid=None, label=None):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(on_update, '_wampuris'))
|
||||
self.assertTrue(type(on_update._wampuris) == list)
|
||||
self.assertEqual(len(on_update._wampuris), 1)
|
||||
self.assertIsInstance(on_update._wampuris[0], Pattern)
|
||||
self.assertFalse(on_update._wampuris[0].is_endpoint())
|
||||
self.assertTrue(on_update._wampuris[0].is_handler())
|
||||
self.assertFalse(on_update._wampuris[0].is_exception())
|
||||
self.assertEqual(on_update._wampuris[0].uri(), u"com.myapp.<category:string>.<cid:int>.on_update")
|
||||
self.assertEqual(on_update._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
@wamp.subscribe(u"com.myapp.on.<event:string>",
|
||||
SubscribeOptions(match=u"wildcard", details_arg="details"))
|
||||
def on_event(event=None, details=None):
|
||||
""" Do nothing. """
|
||||
|
||||
self.assertTrue(hasattr(on_event, '_wampuris'))
|
||||
self.assertTrue(type(on_event._wampuris) == list)
|
||||
self.assertEqual(len(on_event._wampuris), 1)
|
||||
self.assertIsInstance(on_event._wampuris[0], Pattern)
|
||||
self.assertIsInstance(on_event._wampuris[0].options, SubscribeOptions)
|
||||
self.assertEqual(on_event._wampuris[0].options.match, u"wildcard")
|
||||
self.assertEqual(on_event._wampuris[0].options.details_arg, "details")
|
||||
self.assertFalse(on_event._wampuris[0].is_endpoint())
|
||||
self.assertTrue(on_event._wampuris[0].is_handler())
|
||||
self.assertFalse(on_event._wampuris[0].is_exception())
|
||||
self.assertEqual(on_event._wampuris[0].uri(), u"com.myapp.on.<event:string>")
|
||||
self.assertEqual(on_event._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
def test_decorate_exception(self):
|
||||
|
||||
@wamp.error(u"com.myapp.error")
|
||||
class AppError(Exception):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(AppError, '_wampuris'))
|
||||
self.assertTrue(type(AppError._wampuris) == list)
|
||||
self.assertEqual(len(AppError._wampuris), 1)
|
||||
self.assertIsInstance(AppError._wampuris[0], Pattern)
|
||||
self.assertFalse(AppError._wampuris[0].is_endpoint())
|
||||
self.assertFalse(AppError._wampuris[0].is_handler())
|
||||
self.assertTrue(AppError._wampuris[0].is_exception())
|
||||
self.assertEqual(AppError._wampuris[0].uri(), u"com.myapp.error")
|
||||
self.assertEqual(AppError._wampuris[0]._type, Pattern.URI_TYPE_EXACT)
|
||||
|
||||
@wamp.error(u"com.myapp.product.<product:int>.product_inactive")
|
||||
class ProductInactiveError(Exception):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(ProductInactiveError, '_wampuris'))
|
||||
self.assertTrue(type(ProductInactiveError._wampuris) == list)
|
||||
self.assertEqual(len(ProductInactiveError._wampuris), 1)
|
||||
self.assertIsInstance(ProductInactiveError._wampuris[0], Pattern)
|
||||
self.assertFalse(ProductInactiveError._wampuris[0].is_endpoint())
|
||||
self.assertFalse(ProductInactiveError._wampuris[0].is_handler())
|
||||
self.assertTrue(ProductInactiveError._wampuris[0].is_exception())
|
||||
self.assertEqual(ProductInactiveError._wampuris[0].uri(), u"com.myapp.product.<product:int>.product_inactive")
|
||||
self.assertEqual(ProductInactiveError._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
@wamp.error(u"com.myapp.<category:string>.<product:int>.inactive")
|
||||
class ObjectInactiveError(Exception):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(ObjectInactiveError, '_wampuris'))
|
||||
self.assertTrue(type(ObjectInactiveError._wampuris) == list)
|
||||
self.assertEqual(len(ObjectInactiveError._wampuris), 1)
|
||||
self.assertIsInstance(ObjectInactiveError._wampuris[0], Pattern)
|
||||
self.assertFalse(ObjectInactiveError._wampuris[0].is_endpoint())
|
||||
self.assertFalse(ObjectInactiveError._wampuris[0].is_handler())
|
||||
self.assertTrue(ObjectInactiveError._wampuris[0].is_exception())
|
||||
self.assertEqual(ObjectInactiveError._wampuris[0].uri(), u"com.myapp.<category:string>.<product:int>.inactive")
|
||||
self.assertEqual(ObjectInactiveError._wampuris[0]._type, Pattern.URI_TYPE_WILDCARD)
|
||||
|
||||
def test_match_decorated_endpoint(self):
|
||||
|
||||
@wamp.register(u"com.calculator.square")
|
||||
def square(x):
|
||||
return x
|
||||
|
||||
args, kwargs = square._wampuris[0].match(u"com.calculator.square")
|
||||
self.assertEqual(square(666, **kwargs), 666)
|
||||
|
||||
@wamp.register(u"com.myapp.product.<product:int>.update")
|
||||
def update_product(product=None, label=None):
|
||||
return product, label
|
||||
|
||||
args, kwargs = update_product._wampuris[0].match(u"com.myapp.product.123456.update")
|
||||
kwargs['label'] = "foobar"
|
||||
self.assertEqual(update_product(**kwargs), (123456, "foobar"))
|
||||
|
||||
@wamp.register(u"com.myapp.<category:string>.<cid:int>.update")
|
||||
def update(category=None, cid=None, label=None):
|
||||
return category, cid, label
|
||||
|
||||
args, kwargs = update._wampuris[0].match(u"com.myapp.product.123456.update")
|
||||
kwargs['label'] = "foobar"
|
||||
self.assertEqual(update(**kwargs), ("product", 123456, "foobar"))
|
||||
|
||||
def test_match_decorated_handler(self):
|
||||
|
||||
@wamp.subscribe(u"com.myapp.on_shutdown")
|
||||
def on_shutdown():
|
||||
pass
|
||||
|
||||
args, kwargs = on_shutdown._wampuris[0].match(u"com.myapp.on_shutdown")
|
||||
self.assertEqual(on_shutdown(**kwargs), None)
|
||||
|
||||
@wamp.subscribe(u"com.myapp.product.<product:int>.on_update")
|
||||
def on_product_update(product=None, label=None):
|
||||
return product, label
|
||||
|
||||
args, kwargs = on_product_update._wampuris[0].match(u"com.myapp.product.123456.on_update")
|
||||
kwargs['label'] = "foobar"
|
||||
self.assertEqual(on_product_update(**kwargs), (123456, "foobar"))
|
||||
|
||||
@wamp.subscribe(u"com.myapp.<category:string>.<cid:int>.on_update")
|
||||
def on_update(category=None, cid=None, label=None):
|
||||
return category, cid, label
|
||||
|
||||
args, kwargs = on_update._wampuris[0].match(u"com.myapp.product.123456.on_update")
|
||||
kwargs['label'] = "foobar"
|
||||
self.assertEqual(on_update(**kwargs), ("product", 123456, "foobar"))
|
||||
|
||||
def test_match_decorated_exception(self):
|
||||
|
||||
@wamp.error(u"com.myapp.error")
|
||||
class AppError(Exception):
|
||||
|
||||
def __init__(self, msg):
|
||||
Exception.__init__(self, msg)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.__class__ == other.__class__ and \
|
||||
self.args == other.args
|
||||
|
||||
args, kwargs = AppError._wampuris[0].match(u"com.myapp.error")
|
||||
# noinspection PyArgumentList
|
||||
self.assertEqual(AppError(u"fuck", **kwargs), AppError(u"fuck"))
|
||||
|
||||
@wamp.error(u"com.myapp.product.<product:int>.product_inactive")
|
||||
class ProductInactiveError(Exception):
|
||||
|
||||
def __init__(self, msg, product=None):
|
||||
Exception.__init__(self, msg)
|
||||
self.product = product
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.__class__ == other.__class__ and \
|
||||
self.args == other.args and \
|
||||
self.product == other.product
|
||||
|
||||
args, kwargs = ProductInactiveError._wampuris[0].match(u"com.myapp.product.123456.product_inactive")
|
||||
self.assertEqual(ProductInactiveError("fuck", **kwargs), ProductInactiveError("fuck", 123456))
|
||||
|
||||
@wamp.error(u"com.myapp.<category:string>.<product:int>.inactive")
|
||||
class ObjectInactiveError(Exception):
|
||||
|
||||
def __init__(self, msg, category=None, product=None):
|
||||
Exception.__init__(self, msg)
|
||||
self.category = category
|
||||
self.product = product
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.__class__ == other.__class__ and \
|
||||
self.args == other.args and \
|
||||
self.category == other.category and \
|
||||
self.product == other.product
|
||||
|
||||
args, kwargs = ObjectInactiveError._wampuris[0].match(u"com.myapp.product.123456.inactive")
|
||||
self.assertEqual(ObjectInactiveError("fuck", **kwargs), ObjectInactiveError("fuck", "product", 123456))
|
||||
|
||||
|
||||
class KwException(Exception):
|
||||
def __init__(self, *args, **kwargs):
|
||||
Exception.__init__(self, *args)
|
||||
self.kwargs = kwargs
|
||||
|
||||
# what if the WAMP error message received
|
||||
# contains args/kwargs that cannot be
|
||||
# consumed by the constructor of the exception
|
||||
# class defined for the WAMP error URI?
|
||||
|
||||
# 1. we can bail out (but we are already signaling an error)
|
||||
# 2. we can require a generic constructor
|
||||
# 3. we can map only unconsumed args/kwargs to generic attributes
|
||||
# 4. we can silently drop unconsumed args/kwargs
|
||||
|
||||
|
||||
class MockSession(object):
|
||||
|
||||
def __init__(self):
|
||||
self._ecls_to_uri_pat = {}
|
||||
self._uri_to_ecls = {}
|
||||
|
||||
def define(self, exception, error=None):
|
||||
if error is None:
|
||||
assert(hasattr(exception, '_wampuris'))
|
||||
self._ecls_to_uri_pat[exception] = exception._wampuris
|
||||
self._uri_to_ecls[exception._wampuris[0].uri()] = exception
|
||||
else:
|
||||
assert(not hasattr(exception, '_wampuris'))
|
||||
self._ecls_to_uri_pat[exception] = [Pattern(error, Pattern.URI_TARGET_HANDLER)]
|
||||
self._uri_to_ecls[error] = exception
|
||||
|
||||
def map_error(self, error, args=None, kwargs=None):
|
||||
|
||||
# FIXME:
|
||||
# 1. map to ecls based on error URI wildcard/prefix
|
||||
# 2. extract additional args/kwargs from error URI
|
||||
|
||||
if error in self._uri_to_ecls:
|
||||
ecls = self._uri_to_ecls[error]
|
||||
try:
|
||||
# the following might fail, eg. TypeError when
|
||||
# signature of exception constructor is incompatible
|
||||
# with args/kwargs or when the exception constructor raises
|
||||
if kwargs:
|
||||
if args:
|
||||
exc = ecls(*args, **kwargs)
|
||||
else:
|
||||
exc = ecls(**kwargs)
|
||||
else:
|
||||
if args:
|
||||
exc = ecls(*args)
|
||||
else:
|
||||
exc = ecls()
|
||||
except Exception:
|
||||
# FIXME: log e
|
||||
exc = KwException(error, *args, **kwargs)
|
||||
else:
|
||||
# this never fails
|
||||
args = args or []
|
||||
kwargs = kwargs or {}
|
||||
exc = KwException(error, *args, **kwargs)
|
||||
return exc
|
||||
|
||||
|
||||
class TestDecoratorsAdvanced(unittest.TestCase):
|
||||
|
||||
def test_decorate_exception_non_exception(self):
|
||||
|
||||
def test():
|
||||
# noinspection PyUnusedLocal
|
||||
@wamp.error(u"com.test.error")
|
||||
class Foo(object):
|
||||
pass
|
||||
|
||||
self.assertRaises(Exception, test)
|
||||
|
||||
def test_decorate_endpoint_multiple(self):
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
@wamp.register(u"com.oldapp.oldproc")
|
||||
@wamp.register(u"com.calculator.square")
|
||||
def square(x):
|
||||
"""Do nothing."""
|
||||
|
||||
self.assertTrue(hasattr(square, '_wampuris'))
|
||||
self.assertTrue(type(square._wampuris) == list)
|
||||
self.assertEqual(len(square._wampuris), 2)
|
||||
|
||||
for i in range(2):
|
||||
self.assertIsInstance(square._wampuris[i], Pattern)
|
||||
self.assertTrue(square._wampuris[i].is_endpoint())
|
||||
self.assertFalse(square._wampuris[i].is_handler())
|
||||
self.assertFalse(square._wampuris[i].is_exception())
|
||||
self.assertEqual(square._wampuris[i]._type, Pattern.URI_TYPE_EXACT)
|
||||
|
||||
self.assertEqual(square._wampuris[0].uri(), u"com.calculator.square")
|
||||
self.assertEqual(square._wampuris[1].uri(), u"com.oldapp.oldproc")
|
||||
|
||||
def test_marshal_decorated_exception(self):
|
||||
|
||||
@wamp.error(u"com.myapp.error")
|
||||
class AppError(Exception):
|
||||
pass
|
||||
|
||||
try:
|
||||
raise AppError("fuck")
|
||||
except Exception as e:
|
||||
self.assertEqual(e._wampuris[0].uri(), u"com.myapp.error")
|
||||
|
||||
@wamp.error(u"com.myapp.product.<product:int>.product_inactive")
|
||||
class ProductInactiveError(Exception):
|
||||
|
||||
def __init__(self, msg, product=None):
|
||||
Exception.__init__(self, msg)
|
||||
self.product = product
|
||||
|
||||
try:
|
||||
raise ProductInactiveError("fuck", 123456)
|
||||
except Exception as e:
|
||||
self.assertEqual(e._wampuris[0].uri(), u"com.myapp.product.<product:int>.product_inactive")
|
||||
|
||||
session = MockSession()
|
||||
session.define(AppError)
|
||||
|
||||
def test_define_exception_undecorated(self):
|
||||
|
||||
session = MockSession()
|
||||
|
||||
class AppError(Exception):
|
||||
pass
|
||||
|
||||
# defining an undecorated exception requires
|
||||
# an URI to be provided
|
||||
self.assertRaises(Exception, session.define, AppError)
|
||||
|
||||
session.define(AppError, u"com.myapp.error")
|
||||
|
||||
exc = session.map_error(u"com.myapp.error")
|
||||
self.assertIsInstance(exc, AppError)
|
||||
|
||||
def test_define_exception_decorated(self):
|
||||
|
||||
session = MockSession()
|
||||
|
||||
@wamp.error(u"com.myapp.error")
|
||||
class AppError(Exception):
|
||||
pass
|
||||
|
||||
# when defining a decorated exception
|
||||
# an URI must not be provided
|
||||
self.assertRaises(Exception, session.define, AppError, u"com.myapp.error")
|
||||
|
||||
session.define(AppError)
|
||||
|
||||
exc = session.map_error(u"com.myapp.error")
|
||||
self.assertIsInstance(exc, AppError)
|
||||
|
||||
def test_map_exception_undefined(self):
|
||||
|
||||
session = MockSession()
|
||||
|
||||
exc = session.map_error(u"com.myapp.error")
|
||||
self.assertIsInstance(exc, Exception)
|
||||
|
||||
def test_map_exception_args(self):
|
||||
|
||||
session = MockSession()
|
||||
|
||||
@wamp.error(u"com.myapp.error")
|
||||
class AppError(Exception):
|
||||
pass
|
||||
|
||||
@wamp.error(u"com.myapp.error.product_inactive")
|
||||
class ProductInactiveError(Exception):
|
||||
def __init__(self, product=None):
|
||||
self.product = product
|
||||
|
||||
# define exceptions in mock session
|
||||
session.define(AppError)
|
||||
session.define(ProductInactiveError)
|
||||
|
||||
for test in [
|
||||
# (u"com.myapp.foo.error", [], {}, KwException),
|
||||
(u"com.myapp.error", [], {}, AppError),
|
||||
(u"com.myapp.error", ["you are doing it wrong"], {}, AppError),
|
||||
(u"com.myapp.error", ["you are doing it wrong", 1, 2, 3], {}, AppError),
|
||||
|
||||
(u"com.myapp.error.product_inactive", [], {}, ProductInactiveError),
|
||||
(u"com.myapp.error.product_inactive", [], {"product": 123456}, ProductInactiveError),
|
||||
]:
|
||||
error, args, kwargs, ecls = test
|
||||
exc = session.map_error(error, args, kwargs)
|
||||
|
||||
self.assertIsInstance(exc, ecls)
|
||||
self.assertEqual(list(exc.args), args)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,296 @@
|
||||
###############################################################################
|
||||
#
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) Crossbar.io Technologies GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import traceback
|
||||
|
||||
from autobahn.websocket import protocol
|
||||
from autobahn.websocket.types import ConnectionDeny
|
||||
from autobahn.wamp.interfaces import ITransport
|
||||
from autobahn.wamp.exception import ProtocolError, SerializationError, TransportLost
|
||||
|
||||
__all__ = ('WampWebSocketServerProtocol',
|
||||
'WampWebSocketClientProtocol',
|
||||
'WampWebSocketServerFactory',
|
||||
'WampWebSocketClientFactory')
|
||||
|
||||
|
||||
class WampWebSocketProtocol(object):
|
||||
"""
|
||||
Base class for WAMP-over-WebSocket transport mixins.
|
||||
"""
|
||||
|
||||
_session = None # default; self.session is set in onOpen
|
||||
|
||||
def _bailout(self, code, reason=None):
|
||||
self.log.debug('Failing WAMP-over-WebSocket transport: code={code}, reason="{reason}"', code=code, reason=reason)
|
||||
self._fail_connection(code, reason)
|
||||
|
||||
def onOpen(self):
|
||||
"""
|
||||
Callback from :func:`autobahn.websocket.interfaces.IWebSocketChannel.onOpen`
|
||||
"""
|
||||
# WebSocket connection established. Now let the user WAMP session factory
|
||||
# create a new WAMP session and fire off session open callback.
|
||||
try:
|
||||
self._session = self.factory._factory()
|
||||
self._session.onOpen(self)
|
||||
except Exception as e:
|
||||
self.log.critical("{tb}", tb=traceback.format_exc())
|
||||
reason = u'WAMP Internal Error ({0})'.format(e)
|
||||
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_INTERNAL_ERROR, reason=reason)
|
||||
|
||||
def onClose(self, wasClean, code, reason):
|
||||
"""
|
||||
Callback from :func:`autobahn.websocket.interfaces.IWebSocketChannel.onClose`
|
||||
"""
|
||||
# WAMP session might never have been established in the first place .. guard this!
|
||||
self._onclose_reason = reason
|
||||
if self._session is not None:
|
||||
# WebSocket connection lost - fire off the WAMP
|
||||
# session close callback
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
self.log.debug('WAMP-over-WebSocket transport lost: wasClean={wasClean}, code={code}, reason="{reason}"', wasClean=wasClean, code=code, reason=reason)
|
||||
self._session.onClose(wasClean)
|
||||
except Exception:
|
||||
self.log.critical("{tb}", tb=traceback.format_exc())
|
||||
self._session = None
|
||||
|
||||
def onMessage(self, payload, isBinary):
|
||||
"""
|
||||
Callback from :func:`autobahn.websocket.interfaces.IWebSocketChannel.onMessage`
|
||||
"""
|
||||
try:
|
||||
for msg in self._serializer.unserialize(payload, isBinary):
|
||||
self.log.trace(
|
||||
"WAMP RECV: message={message}, session={session}, authid={authid}",
|
||||
authid=self._session._authid,
|
||||
session=self._session._session_id,
|
||||
message=msg,
|
||||
)
|
||||
self._session.onMessage(msg)
|
||||
|
||||
except ProtocolError as e:
|
||||
self.log.critical("{tb}", tb=traceback.format_exc())
|
||||
reason = u'WAMP Protocol Error ({0})'.format(e)
|
||||
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_PROTOCOL_ERROR, reason=reason)
|
||||
|
||||
except Exception as e:
|
||||
self.log.critical("{tb}", tb=traceback.format_exc())
|
||||
reason = u'WAMP Internal Error ({0})'.format(e)
|
||||
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_INTERNAL_ERROR, reason=reason)
|
||||
|
||||
def send(self, msg):
|
||||
"""
|
||||
Implements :func:`autobahn.wamp.interfaces.ITransport.send`
|
||||
"""
|
||||
if self.isOpen():
|
||||
try:
|
||||
self.log.trace(
|
||||
"WAMP SEND: message={message}, session={session}, authid={authid}",
|
||||
authid=self._session._authid,
|
||||
session=self._session._session_id,
|
||||
message=msg,
|
||||
)
|
||||
payload, isBinary = self._serializer.serialize(msg)
|
||||
except Exception as e:
|
||||
self.log.error("WAMP message serialization error: {}".format(e))
|
||||
# all exceptions raised from above should be serialization errors ..
|
||||
raise SerializationError(u"WAMP message serialization error: {0}".format(e))
|
||||
else:
|
||||
self.sendMessage(payload, isBinary)
|
||||
else:
|
||||
raise TransportLost()
|
||||
|
||||
def isOpen(self):
|
||||
"""
|
||||
Implements :func:`autobahn.wamp.interfaces.ITransport.isOpen`
|
||||
"""
|
||||
return self._session is not None
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Implements :func:`autobahn.wamp.interfaces.ITransport.close`
|
||||
"""
|
||||
if self.isOpen():
|
||||
self.sendClose(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_NORMAL)
|
||||
else:
|
||||
raise TransportLost()
|
||||
|
||||
def abort(self):
|
||||
"""
|
||||
Implements :func:`autobahn.wamp.interfaces.ITransport.abort`
|
||||
"""
|
||||
if self.isOpen():
|
||||
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_GOING_AWAY)
|
||||
else:
|
||||
raise TransportLost()
|
||||
|
||||
|
||||
ITransport.register(WampWebSocketProtocol)
|
||||
|
||||
|
||||
def parseSubprotocolIdentifier(subprotocol):
|
||||
try:
|
||||
s = subprotocol.split(u'.')
|
||||
if s[0] != u'wamp':
|
||||
raise Exception(u'WAMP WebSocket subprotocol identifier must start with "wamp", not "{}"'.format(s[0]))
|
||||
version = int(s[1])
|
||||
serializerId = u'.'.join(s[2:])
|
||||
return version, serializerId
|
||||
except:
|
||||
return None, None
|
||||
|
||||
|
||||
class WampWebSocketServerProtocol(WampWebSocketProtocol):
|
||||
"""
|
||||
Mixin for WAMP-over-WebSocket server transports.
|
||||
"""
|
||||
|
||||
STRICT_PROTOCOL_NEGOTIATION = True
|
||||
|
||||
def onConnect(self, request):
|
||||
"""
|
||||
Callback from :func:`autobahn.websocket.interfaces.IWebSocketChannel.onConnect`
|
||||
"""
|
||||
headers = {}
|
||||
for subprotocol in request.protocols:
|
||||
version, serializerId = parseSubprotocolIdentifier(subprotocol)
|
||||
if version == 2 and serializerId in self.factory._serializers.keys():
|
||||
self._serializer = self.factory._serializers[serializerId]
|
||||
return subprotocol, headers
|
||||
|
||||
if self.STRICT_PROTOCOL_NEGOTIATION:
|
||||
raise ConnectionDeny(ConnectionDeny.BAD_REQUEST, u'This server only speaks WebSocket subprotocols {}'.format(u', '.join(self.factory.protocols)))
|
||||
else:
|
||||
# assume wamp.2.json
|
||||
self._serializer = self.factory._serializers[u'json']
|
||||
return None, headers
|
||||
|
||||
|
||||
class WampWebSocketClientProtocol(WampWebSocketProtocol):
|
||||
"""
|
||||
Mixin for WAMP-over-WebSocket client transports.
|
||||
"""
|
||||
|
||||
STRICT_PROTOCOL_NEGOTIATION = True
|
||||
|
||||
def onConnect(self, response):
|
||||
"""
|
||||
Callback from :func:`autobahn.websocket.interfaces.IWebSocketChannel.onConnect`
|
||||
"""
|
||||
if response.protocol not in self.factory.protocols:
|
||||
if self.STRICT_PROTOCOL_NEGOTIATION:
|
||||
raise Exception(u'The server does not speak any of the WebSocket subprotocols {} we requested.'.format(u', '.join(self.factory.protocols)))
|
||||
else:
|
||||
# assume wamp.2.json
|
||||
serializerId = u'json'
|
||||
else:
|
||||
version, serializerId = parseSubprotocolIdentifier(response.protocol)
|
||||
|
||||
self._serializer = self.factory._serializers[serializerId]
|
||||
|
||||
|
||||
class WampWebSocketFactory(object):
|
||||
"""
|
||||
Base class for WAMP-over-WebSocket transport factory mixins.
|
||||
"""
|
||||
|
||||
def __init__(self, factory, serializers=None):
|
||||
"""
|
||||
Ctor.
|
||||
|
||||
:param factory: A callable that produces instances that implement
|
||||
:class:`autobahn.wamp.interfaces.ITransportHandler`
|
||||
:type factory: callable
|
||||
|
||||
:param serializers: A list of WAMP serializers to use (or None for default
|
||||
serializers). Serializers must implement
|
||||
:class:`autobahn.wamp.interfaces.ISerializer`.
|
||||
:type serializers: list
|
||||
"""
|
||||
if callable(factory):
|
||||
self._factory = factory
|
||||
else:
|
||||
self._factory = lambda: factory
|
||||
|
||||
if serializers is None:
|
||||
serializers = []
|
||||
|
||||
# try CBOR WAMP serializer
|
||||
try:
|
||||
from autobahn.wamp.serializer import CBORSerializer
|
||||
serializers.append(CBORSerializer(batched=True))
|
||||
serializers.append(CBORSerializer())
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# try MsgPack WAMP serializer
|
||||
try:
|
||||
from autobahn.wamp.serializer import MsgPackSerializer
|
||||
serializers.append(MsgPackSerializer(batched=True))
|
||||
serializers.append(MsgPackSerializer())
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# try UBJSON WAMP serializer
|
||||
try:
|
||||
from autobahn.wamp.serializer import UBJSONSerializer
|
||||
serializers.append(UBJSONSerializer(batched=True))
|
||||
serializers.append(UBJSONSerializer())
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# try JSON WAMP serializer
|
||||
try:
|
||||
from autobahn.wamp.serializer import JsonSerializer
|
||||
serializers.append(JsonSerializer(batched=True))
|
||||
serializers.append(JsonSerializer())
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if not serializers:
|
||||
raise Exception(u'Could not import any WAMP serializer')
|
||||
|
||||
self._serializers = {}
|
||||
for ser in serializers:
|
||||
self._serializers[ser.SERIALIZER_ID] = ser
|
||||
|
||||
self._protocols = [u'wamp.2.{}'.format(ser.SERIALIZER_ID) for ser in serializers]
|
||||
|
||||
|
||||
class WampWebSocketServerFactory(WampWebSocketFactory):
|
||||
"""
|
||||
Mixin for WAMP-over-WebSocket server transport factories.
|
||||
"""
|
||||
|
||||
|
||||
class WampWebSocketClientFactory(WampWebSocketFactory):
|
||||
"""
|
||||
Mixin for WAMP-over-WebSocket client transport factories.
|
||||
"""
|
||||
Reference in New Issue
Block a user