Skip to content

Commit

Permalink
Merge #521: Fix keepkey enumeration so it does not appear as Trezor
Browse files Browse the repository at this point in the history
f8f4f3f Fix keepkey enumeration so it does not appear as Trezor (Pavol Rusnak)

Pull request description:

  Fixes #517

ACKs for top commit:
  achow101:
    ACK f8f4f3f

Tree-SHA512: 1f0d3538b4f6a87943d1ed2c47fc424ff2cc9cd629dcedf2473030c3bd30449fb90ffda4e6a40eb2396cd574d4dc1e6c0b23a9c23dbe2c5d099956b6585f2995
  • Loading branch information
achow101 committed Aug 27, 2021
2 parents 61cacc8 + f8f4f3f commit ee44b83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions hwilib/devices/keepkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

KEEPKEY_HID_IDS = {(0x2B24, 0x0001)}
KEEPKEY_WEBUSB_IDS = {(0x2B24, 0x0002)}
KEEPKEY_SIMULATOR_PATH = '127.0.0.1:11044'

HID_IDS.update(KEEPKEY_HID_IDS)
WEBUSB_IDS.update(KEEPKEY_WEBUSB_IDS)
Expand Down Expand Up @@ -159,7 +160,7 @@ def enumerate(password: str = "") -> List[Dict[str, Any]]:
results = []
devs = hid.HidTransport.enumerate(usb_ids=KEEPKEY_HID_IDS)
devs.extend(webusb.WebUsbTransport.enumerate(usb_ids=KEEPKEY_WEBUSB_IDS))
devs.extend(udp.UdpTransport.enumerate())
devs.extend(udp.UdpTransport.enumerate(KEEPKEY_SIMULATOR_PATH))
for dev in devs:
d_data: Dict[str, Any] = {}

Expand All @@ -178,7 +179,7 @@ def enumerate(password: str = "") -> List[Dict[str, Any]]:
if 'keepkey' not in client.client.features.vendor:
continue

if d_data['path'] == 'udp:127.0.0.1:11044':
if d_data['path'].startswith('udp:'):
d_data['model'] += '_simulator'

d_data['needs_pin_sent'] = client.client.features.pin_protection and not client.client.features.unlocked
Expand Down
2 changes: 1 addition & 1 deletion hwilib/devices/trezor.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ def enumerate(password: str = "") -> List[Dict[str, Any]]:
continue

d_data['model'] = 'trezor_' + client.client.features.model.lower()
if d_data['path'] == 'udp:127.0.0.1:21324':
if d_data['path'].startswith('udp:'):
d_data['model'] += '_simulator'

d_data['needs_pin_sent'] = client.client.features.pin_protection and not client.client.features.unlocked
Expand Down
7 changes: 4 additions & 3 deletions hwilib/devices/trezorlib/transport/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def _try_path(cls, path: str) -> "UdpTransport":
d.close()

@classmethod
def enumerate(cls) -> Iterable["UdpTransport"]:
default_path = "{}:{}".format(cls.DEFAULT_HOST, cls.DEFAULT_PORT)
def enumerate(cls, path: Optional[str] = None) -> Iterable["UdpTransport"]:
if path is None:
path = "{}:{}".format(cls.DEFAULT_HOST, cls.DEFAULT_PORT)
try:
return [cls._try_path(default_path)]
return [cls._try_path(path)]
except TransportException:
return []

Expand Down

0 comments on commit ee44b83

Please sign in to comment.