|
|
@ -17,6 +17,7 @@
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
|
import binascii
|
|
|
|
import binascii
|
|
|
|
from io import BytesIO
|
|
|
|
from io import BytesIO
|
|
|
@ -27,6 +28,8 @@ from .. import messages
|
|
|
|
from .. import protobuf
|
|
|
|
from .. import protobuf
|
|
|
|
from . import Transport, TransportException
|
|
|
|
from . import Transport, TransportException
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
TREZORD_HOST = 'http://127.0.0.1:21325'
|
|
|
|
TREZORD_HOST = 'http://127.0.0.1:21325'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,6 +81,8 @@ class BridgeTransport(Transport):
|
|
|
|
self.session = None
|
|
|
|
self.session = None
|
|
|
|
|
|
|
|
|
|
|
|
def write(self, msg):
|
|
|
|
def write(self, msg):
|
|
|
|
|
|
|
|
LOG.debug("sending message: {}".format(msg.__class__.__name__),
|
|
|
|
|
|
|
|
extra={'protobuf': msg})
|
|
|
|
data = BytesIO()
|
|
|
|
data = BytesIO()
|
|
|
|
protobuf.dump_message(data, msg)
|
|
|
|
protobuf.dump_message(data, msg)
|
|
|
|
ser = data.getvalue()
|
|
|
|
ser = data.getvalue()
|
|
|
@ -97,5 +102,7 @@ class BridgeTransport(Transport):
|
|
|
|
(msg_type, datalen) = struct.unpack('>HL', data[:headerlen])
|
|
|
|
(msg_type, datalen) = struct.unpack('>HL', data[:headerlen])
|
|
|
|
data = BytesIO(data[headerlen:headerlen + datalen])
|
|
|
|
data = BytesIO(data[headerlen:headerlen + datalen])
|
|
|
|
msg = protobuf.load_message(data, mapping.get_class(msg_type))
|
|
|
|
msg = protobuf.load_message(data, mapping.get_class(msg_type))
|
|
|
|
|
|
|
|
LOG.debug("received message: {}".format(msg.__class__.__name__),
|
|
|
|
|
|
|
|
extra={'protobuf': msg})
|
|
|
|
self.response = None
|
|
|
|
self.response = None
|
|
|
|
return msg
|
|
|
|
return msg
|
|
|
|