send transit abilities to far end too, for the future

This will allow a future peer to figure out what transit modes we can
and cannot do, and thus avoid spinning up expensive modes that we won't
be able to use (e.g. WebRTC).
This commit is contained in:
Brian Warner 2016-05-26 16:26:00 -07:00
parent db31ffe075
commit 56fec496e2
3 changed files with 15 additions and 3 deletions

View File

@ -149,8 +149,11 @@ class TwistedReceiver:
tr.set_transit_key(transit_key)
tr.add_connection_hints(sender_transit.get("hints-v1", []))
receiver_abilities = tr.get_connection_abilities()
receiver_hints = yield tr.get_connection_hints()
receiver_transit = {"hints-v1": receiver_hints}
receiver_transit = {"abilities-v1": receiver_abilities,
"hints-v1": receiver_hints,
}
self._send_data({u"transit": receiver_transit}, w)
# TODO: send more hints as the TransitReceiver produces them

View File

@ -106,8 +106,12 @@ class Sender:
self._transit_sender = ts
# for now, send this before the main offer
hints = yield ts.get_connection_hints()
self._send_data({u"transit": {"hints-v1": hints}}, w)
sender_abilities = ts.get_connection_abilities()
sender_hints = yield ts.get_connection_hints()
sender_transit = {"abilities-v1": sender_abilities,
"hints-v1": sender_hints,
}
self._send_data({u"transit": sender_transit}, w)
# TODO: move this down below w.get()
transit_key = w.derive_key(APPID+"/transit-key",

View File

@ -602,6 +602,11 @@ class Common:
ep = endpoints.serverFromString(reactor, "tcp:%d" % portnum)
return direct_hints, ep
def get_connection_abilities(self):
return [{u"type": u"direct-tcp-v1"},
{u"type": u"relay-v1"},
]
@inlineCallbacks
def get_connection_hints(self):
hints = []