aaronjwood / PortAuthority

A handy systems and security-focused tool, Port Authority is a very fast Android port scanner. Port Authority also allows you to quickly discover hosts on your network and will display useful network information about your device and other hosts.
https://play.google.com/store/apps/details?id=com.aaronjwood.portauthority.free
GNU General Public License v3.0
348 stars 66 forks source link

Port mDNS hostname resolution from 'Angry IP Scanner' + Fix NetBIOS hostname resolution + Add API 31 compatibility #135

Closed BayLee4 closed 2 years ago

BayLee4 commented 2 years ago

Hi 👋

In this pull request I ported the mDNS hostname resolution from Angry IP Scanner (also GPL licensed) and fixed the NetBIOS hostname resolution which wasn't working for workstations.

Few modification from upstream MDNSResolver, first uncommenting socket.joinGroup(mdnsIP); which is working on Android and catch more hosts (was disabled because of macOS I guess) :

https://github.com/aaronjwood/PortAuthority/blob/4debcfa25a680e2e0e183bca9b95061ccc9a7a99/app/src/main/java/com/aaronjwood/portauthority/utils/MDNSResolver.java#L19-L20

And modify hostnames parsing accordingly, which change slightly :

https://github.com/aaronjwood/PortAuthority/blob/4debcfa25a680e2e0e183bca9b95061ccc9a7a99/app/src/main/java/com/aaronjwood/portauthority/utils/MDNSResolver.java#L73

Regarding the changes to the NetBIOS hostname resolution, it now catches the NETBIOS_WORKSTATION name. The default behaviour isn't changed at all, as the NETBIOS_FILE_SERVER name is still used in priority if present.

Both the NetBIOS and mDNS hostname resolution now respects the Lan Socket Timeout setting, which is helpful on slow networks.

The changes in .xml strings are for Android Studio, which refuse to compile without these minor modifications. The rest of the code is commented, but feel free to ask any question!

BayLee4 commented 2 years ago

This last commit implement API 31 compatibility, which fix #125, #129 and #134. It also update dependencies, drop the outdated JCIFS library (last update : 2012!) in favor of NetBIOSResolver.java from Angry IP Scanner, and fix the CI to accomodate all of these changes. There is also a few other minor improvements, like not showing .local suffixes if they exist.

aaronjwood commented 2 years ago

Thanks so much for this! Sorry I have not been responsive, I have not had the time to focus on this project.

aaronjwood commented 2 years ago

Thanks for your work on this. I'll merge it in with some clean ups I am currently working on and hopefully get a release out in the next few days :)