Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for getting host name #3

Closed
guyluz11 opened this issue Jan 15, 2022 · 13 comments · Fixed by #41
Closed

Support for getting host name #3

guyluz11 opened this issue Jan 15, 2022 · 13 comments · Fixed by #41
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@guyluz11
Copy link
Collaborator

guyluz11 commented Jan 15, 2022

Is there a way to get a hostname/dns name from specific IP?.
Or even better, have a way to get the hostname of all the IPs during the scan?.

If not what are the steps that missing in order to add this feature.

@git-elliot
Copy link
Collaborator

git-elliot commented Jan 15, 2022

DNS lookup is already there to get the hostname. As far as scan is concerned, it is made on the local wifi network and hence IP addresses would be local also, most probably won't have any name associated with it.

P.S. - I'm not still clear why you want hostname when scanning for hosts on a network.

@guyluz11
Copy link
Collaborator Author

So I am missing something, where is the hostname stored?, I am expecting it to be stored in the class ActiveHost but it does not contain any hostname.

I am creating a smart hub.
I want to recognize smart devices on the network by vendor name which exists in hostname.
Examples: LIFX-White-5ECF0C, ESP_F5B515

I am thinking of clessefying IP to company by open ports but as nmap is showing me this is not always possible
All 1000 scanned ports on LIFX-White-5ECF0C (55.13.21.149) are closed

@git-elliot
Copy link
Collaborator

git-elliot commented Jan 15, 2022

Sorry my bad for confusing the hostname with domain name. It's been pretty while working on this project. Let me check for the hostname. I'll update if I'm able to retrieve it.

@guyluz11
Copy link
Collaborator Author

guyluz11 commented Jan 15, 2022

Cool thanks.

On an unrelated note.
I am looking at the code and noticed that it cheks one IP at a time, waits for the result and then checks the next IP.
I will try to change it to do it asynchronously, is it something that you will accept as a pull request?.

@git-elliot
Copy link
Collaborator

I don't know why I kept it synchronised, yeah please try. I'll check the PR and test it. If it does the same thing then I'll merge into the code.

@git-elliot
Copy link
Collaborator

@guyluz11 Please also tell me about which scanner are you talking about. host_scanner or port_scanner?

@guyluz11
Copy link
Collaborator Author

Host scanner.

Also is there a way to remove the PingSummary lines?
PingSummary(transmitted:1, received:0), time: 0 ms, Errors: [NoReply]

@git-elliot
Copy link
Collaborator

In host scanner, you can't yield twice that's why for inner stream I used await for.

PingSummary lines can be removed by removing this line. i'll not suggest removing it, but adding a flag to the method named debug.

https://github.com/git-elliot/network_tools/blob/dd606bf36f70ff7ba7e4ccff893dd0f493252dd8/lib/src/host_scanner.dart#L51

@git-elliot
Copy link
Collaborator

I'm unable to find any way to get hostname of local IPs. People are claiming it to be done using InternetAddress.reverse() but that only works if the result came from the DNS server.

@git-elliot git-elliot added the platform limitation This feature or fix is limited to underlying platform features. label Jan 17, 2022
@guyluz11
Copy link
Collaborator Author

guyluz11 commented Jan 17, 2022

Not sure if this helps but Nmap and host tools for Linux are doing that fine and is very popular.
Maybe there is more documentation about the implementation in Nmap GitHub repo.

I think "Hostname" is also called "local domain name" and "DNS host name" and "mDNS host name".

It can be resolved using avahi-resolve-address command so I guess we can do it by using avahi packages, maybe avahi or multicast_dns.
More research is required.

@guyluz11
Copy link
Collaborator Author

I have found a way to do reverse DNS lookup and get the hostname from IP :D.

After getting an InternetAddress object we need to run .reverse on it and the .host field will get populated.

Example code

final InternetAddress internetAddressWithoutHost = InternetAddress('IP');
final InternetAddress internetAddressWithHost = await internetAddressWithoutHost.reverse();
print(internetAddressWithHost.host);

I will implement it after my pull requests will get accepted.

@guyluz11 guyluz11 added enhancement New feature or request good first issue Good for newcomers and removed platform limitation This feature or fix is limited to underlying platform features. labels Jul 25, 2022
@guyluz11 guyluz11 self-assigned this Jul 26, 2022
@git-elliot
Copy link
Collaborator

Seems like internetAddressWithoutHost.reverse() is added lately.

guyluz11 added a commit to guyluz11/network_tools that referenced this issue Jul 27, 2022
guyluz11 added a commit to guyluz11/network_tools that referenced this issue Jul 27, 2022
@guyluz11 guyluz11 linked a pull request Jul 27, 2022 that will close this issue
git-elliot pushed a commit that referenced this issue Jul 28, 2022
* Updated dependencies

* Added comments to each dependency

* Decided to update min dart version to 2.17.0 (even though pub get didn't show any errors) because it is the min version in dart_ping 7.0.0

* Reverted min dart version back to 2.12.0 as it is not mandatory

* Updated min dart version to 2.17.0.

* Added a function to find some of the mdns devices on the network

* Added todo part for searchMdnsDevices and more srv record.

* Inserting the name from the mdns into _make var in ActiveHost

* More srv records.

* More srv records.

* Added mdns scanner to example and Changelog. Changed network_tool version to 2.1.0

* Remove Future<void> from main function in example folder

* Made searching for mdns process better for Linux if avahi-browse or mdns-scan is installed on it.

* Removing print

* Added small comment for future mac implementation.

* Small fix to srv results as avahi command does not return all of them.

* Added a lot entry's to the tcpSrvRecords list, added udpSrvRecordList.

* Added the udp list to the search. Small fix for multiple devices with the same mDNS name different address.

* Made mdns_scanner accessible to users of the package.

* Fix for #3. Improved pub.dev score. Change method names to be more precise.

* Each ActiveHost object will automatically get host name when waitingForActiveHostSetupToComplete is done, fix for #3.

* Fix for #44

* Updated package version to 2.2.0, updated changelog for the new version .Updated lint to 1.10.0.

* Changed ip to address

* Changed app version and changelog to version 3.0.0 as we did braking changed by changed methods name.

* Solved some analysis warnings
@guyluz11
Copy link
Collaborator Author

Host name functionality got merged into dev branch.

I will close this issue now, thanks.

git-elliot pushed a commit that referenced this issue Aug 6, 2022
* Updated dependencies

* Added comments to each dependency

* Decided to update min dart version to 2.17.0 (even though pub get didn't show any errors) because it is the min version in dart_ping 7.0.0

* Reverted min dart version back to 2.12.0 as it is not mandatory

* Updated min dart version to 2.17.0.

* Added a function to find some of the mdns devices on the network

* Added todo part for searchMdnsDevices and more srv record.

* Inserting the name from the mdns into _make var in ActiveHost

* More srv records.

* More srv records.

* Added mdns scanner to example and Changelog. Changed network_tool version to 2.1.0

* Remove Future<void> from main function in example folder

* Made searching for mdns process better for Linux if avahi-browse or mdns-scan is installed on it.

* Removing print

* Added small comment for future mac implementation.

* Small fix to srv results as avahi command does not return all of them.

* Added a lot entry's to the tcpSrvRecords list, added udpSrvRecordList.

* Added the udp list to the search. Small fix for multiple devices with the same mDNS name different address.

* Made mdns_scanner accessible to users of the package.

* Fix for #3. Improved pub.dev score. Change method names to be more precise.

* Each ActiveHost object will automatically get host name when waitingForActiveHostSetupToComplete is done, fix for #3.

* Fix for #44

* Updated package version to 2.2.0, updated changelog for the new version .Updated lint to 1.10.0.

* Changed ip to address

* Changed app version and changelog to version 3.0.0 as we did braking changed by changed methods name.

* Solved some analysis warnings

* Small fix for rear cases where DNS lookup crashes.

* Added _ewelink to srv list. Added a way for users to forceUseOfSavedSrvRecordList. Searching srv list on linux will now also use avahi-browse as just using mdns-scan does not retrieve the full results.

* MdnsInfo now also saves SrvResourceRecord and PtrResourceRecord objects from multicast_dns package as it contains more info about the mdns device.

* Made the code easier to work with as developer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants