iri icon indicating copy to clipboard operation
iri copied to clipboard

getNeighbors returning IPs in different formats

Open bahamapascal opened this issue 9 years ago • 5 comments

When making the getNeighbors call, it returned me a IP in this format: "address": "92.ip-51-XXX-195.eu:14265", After restarting the IRI, I made the getNeighbors call again, just that it this time returned: "address": "51.XXX.195.92:14265",

This first result seems to me like a bug. Strange thing, after a while (10min maybe) the getNeighbors call again returned the IPs in a strange format, just that when restarting this time, nothing changed. Maybe this has something to do with the DNS updater, which was implemented some versions ago?

bahamapascal avatar Jan 31 '17 11:01 bahamapascal

I think you mean the DNS Resolver. Its not a bug, its a feature.

pinpong avatar Feb 04 '17 13:02 pinpong

Is this related to the "Checking neighbor ip..." message I see occasionally in the IRI output?

todofixthis avatar Feb 04 '17 19:02 todofixthis

@pinpong Yes you are probably right.

Though personally I would like it if getNeighbors would return the plain IP/DNS as it was entered in the neighbor configuration. If looking for a neighbor, and its displayed in such a abstract way that the numbers of the IP aren't even displayed in the correct order, then its just very hard to spot the neighbor I am looking for.

@todofixthis Yes quite sure it is.

bahamapascal avatar Feb 06 '17 06:02 bahamapascal

Including this info 'cause I know you're a Python dev (:

Note: in Python, you can use socket.gethostbyname to resolve a hostname into an IP address. Even if the IRI doesn't provide IP addresses, it shouldn't be too difficult to resolve them in the calling script:

In [1]: import socket

In [2]: socket.gethostbyname('example.com')
Out[2]: '93.184.216.34'

See https://docs.python.org/2/library/socket.html#socket.gethostbyname for more information.

todofixthis avatar Feb 06 '17 17:02 todofixthis

Thanks! This looks like a good solution. And sorry for the late reply, some how forgot.

bahamapascal avatar Feb 20 '17 18:02 bahamapascal