1. IP to URL conversion

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

new topic     » topic index » view message » categorize

2. Re: IP to URL conversion

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: IP to URL conversion

jmduro said...

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: IP to URL conversion

Spock said...

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:

scheme://[user:password@]domain:port/path?query_string#fragment_id

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: IP to URL conversion

ghaberek said...
Spock said...

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.

ghaberek said...

A URL is composed of the following parts:

scheme://[user:password@]domain:port/path?query_string#fragment_id

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.

ghaberek said...

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.

new topic     » goto parent     » topic index » view message » categorize

6. Re: IP to URL conversion

ghaberek said...
Spock said...

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:

scheme://[user:password@]domain:port/path?query_string#fragment_id

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

new topic     » goto parent     » topic index » view message » categorize

7. Re: IP to URL conversion

jimcbrown said...

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).

new topic     » goto parent     » topic index » view message » categorize

8. Re: IP to URL conversion

Bazzadude said...
jimcbrown said...

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.)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu