seemoo-lab / opendrop

An open Apple AirDrop implementation written in Python
https://owlink.org
GNU General Public License v3.0
8.48k stars 265 forks source link

AttributeError: 'AirDropBrowser' object has no attribute 'update_service' #77

Closed lucadenhez closed 2 years ago

lucadenhez commented 2 years ago

Hello!

Whenever I try and use the browser to search for devices, it throws this exception when a device is found:

Traceback (most recent call last): Exception in thread zeroconf-ServiceBrowser-_airdrop._tcp-1519690: File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner Traceback (most recent call last): File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/site-packages/zeroconf/_services/browser.py", line 541, in run self.run() File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/threading.py", line 870, in run self._target(*self._args, self._kwargs) File "/Users/lucadenhez/Documents/AirDrop/testing.py", line 128, in on_receiver_found self._fire_service_state_changed_event(event) File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/site-packages/zeroconf/_services/browser.py", line 423, in _fire_service_state_changed_event address = ipaddress.ip_address(info.address).compressed AttributeError: 'ServiceInfo' object has no attribute 'address' self._service_state_changed.fire( File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/site-packages/zeroconf/_services/init.py", line 55, in fire h(kwargs) File "/Users/lucadenhez/opt/anaconda3/lib/python3.8/site-packages/zeroconf/_services/browser.py", line 180, in on_change getattr(listener, _ON_CHANGE_DISPATCH[state_change])(zeroconf, service_type, name) AttributeError: 'AirDropBrowser' object has no attribute 'update_service'

Here's the code I was trying it out with, used someone else's code too and was presented with the same issue:

browser = AirDropBrowser(AirDropConfig()) browser.start(callback_add = deviceFound)

Thanks for the support, such cool software!

lucadenhez commented 2 years ago

Fixed by adding this block of code to client.py :)

def update_service(self, zeroconf, service_type, name): info = zeroconf.get_service_info(service_type, name) logger.debug(f"Add service {name}") if self.callback_add is not None: self.callback_add(info)