1. IP to URL conversion
- Posted by Spock Aug 12, 2015
- 2259 views
How would someone convert IP to URL using Euphoria?
Eg:
sequence gotya = IP2URL( "204.71.200.68" ) -- returns "www.yahoo.com"
EDIT: I suppose that should be host_by_addr(), duh.
Spock
2. Re: IP to URL conversion
- Posted by jmduro Aug 13, 2015
- 2217 views
You are right!
include std/net/dns.e include myLibs/myDebug.e -- object gotya = host_by_addr("204.71.200.68") -- returns -11004 object gotya = host_by_addr("46.228.47.115") analyzeObject(gotya, "gotya", 1)
returns
C:\data\Euphoria\v4>eui dns.ex gotya = . [1] "ir1.fp.vip.ir2.yahoo.com" . [2] "" . [3] . . [1] "46.228.47.115" . [4] 2
Jean-Marc
3. Re: IP to URL conversion
- Posted by Spock Aug 13, 2015
- 2275 views
You are right!
...
Not quite. The domain is returned but not the full URL. I see now it's a bit like searching for a street address but the map you have only shows the town name.
I suspect some of the net gurus knew about this as soon as they read the post - but they didn't say anything. That's not very nice.
Spock
4. Re: IP to URL conversion
- Posted by ghaberek (admin) Aug 14, 2015
- 2220 views
Not quite. The domain is returned but not the full URL. I see now it's a bit like searching for a street address but the map you have only shows the town name.
I suspect some of the net gurus knew about this as soon as they read the post - but they didn't say anything. That's not very nice.
I considered it when reading your original post, but it seemed pedantic of me to correct you.
A URL is composed of the following parts:
The most you're going to get from an IP is the domain. The DNS system has no knowledge of actual URLs.
I suggest reading up on the Wikipedia entry for URL to get a better understanding of what each part means.
-Greg
5. Re: IP to URL conversion
- Posted by jimcbrown (admin) Aug 14, 2015
- 2279 views
Not quite. The domain is returned but not the full URL. I see now it's a bit like searching for a street address but the map you have only shows the town name.
I suspect some of the net gurus knew about this as soon as they read the post - but they didn't say anything. That's not very nice.
I considered it when reading your original post, but it seemed pedantic of me to correct you.
I just assumed that the question was to translate an ip address to the root of an HTTP server, e.g. "1.1.1.1" -> "http://www.example.com" since HTTP is probably the most common URL out there. That someone was trying to do a "1.1.1.1" -> "http://www.example.com/more_exapmles.html" conversion didn't occur to me at all.
A URL is composed of the following parts:
The most you're going to get from an IP is the domain. The DNS system has no knowledge of actual URLs.
If even that. But a single IP address is often mapped to multiple domains, so if you get more than one you'll need some other way to figure out which one you want to use.
I suggest reading up on the Wikipedia entry for URL to get a better understanding of what each part means.
-Greg
Also, it's permissible to use the IP address in an URL directly. This is pretty rare on the wider internet, but on a home network I often see "http://192.168.0.1" (or example) to access the web page of a router or something. An IP address doesn't have to be mapped to a domain at all, if you wanted to you could force others to remeber and use the raw ip address to get to your site.
6. Re: IP to URL conversion
- Posted by Spock Aug 14, 2015
- 2154 views
Not quite. The domain is returned but not the full URL. I see now it's a bit like searching for a street address but the map you have only shows the town name...
..
A URL is composed of the following parts:
The most you're going to get from an IP is the domain. The DNS system has no knowledge of actual URLs.
I suggest reading up on the Wikipedia entry for URL to get a better understanding of what each part means.
-Greg
Thanks for the link, I have started reading it and beginning to better understand it all. I freely admit my ignorance about net stuff.
Spock
7. Re: IP to URL conversion
- Posted by Bazzadude Aug 14, 2015
- 2114 views
An IP address doesn't have to be mapped to a domain at all, if you wanted to you could force others to remeber and use the raw ip address to get to your site.
Right.
It's also true that on occasion a hostname like fanciful.dev.shennanigans needs to be used in the request header to obtain a valid response, but this needn't be a "pukka" domain available via public DNS (ie, someone accessing the site via their browser needs to have manually mapped it in their local hosts file, or their app needs to set that header explicitly).
8. Re: IP to URL conversion
- Posted by jimcbrown (admin) Aug 14, 2015
- 2144 views
An IP address doesn't have to be mapped to a domain at all, if you wanted to you could force others to remeber and use the raw ip address to get to your site.
Right.
It's also true that on occasion a hostname like fanciful.dev.shennanigans needs to be used in the request header to obtain a valid response, but this needn't be a "pukka" domain available via public DNS (ie, someone accessing the site via their browser needs to have manually mapped it in their local hosts file, or their app needs to set that header explicitly).
Agreed. This makes more sense for something like a corporate intranet, where names can only be resolved within the corporate network but not outside of it.
As an aside, it's recommended that the .local tld ( https://en.wikipedia.org/wiki/.local ) be used for such networks, as that's reserved and guaranteed not to ever be taken. Whereas, someone setting up an intranet domain at who.wants.to.troll.a.dev might one day find that their fanciful .dev tld has been taken (e.g. http://icannwiki.com/.dev ).
Naturally, not everyone follows the standards. (The .local tld was only reserved for this use in feb 2013 IIUC, so there's probably a lot of legacy cases where an intranet was set up before this and it's considered too expensive to rename everything.)