2012-03-01 - Re: [GRASE-Hotspot] http://logout - How is it done?

Header Data

From: Tim White <ti***8@gmail.com>
Message Hash: be23e9c79dc7c4c66eaaad964f898b1ab5bf26c941b73f6955140fb6578b8e4e
Message ID: <4F4FF2D7.5040209@gmail.com>
Reply To: <1802e4cfb2df7ae8a7ec61c1a5871392f93e7eb2@thesanctuarythailand.com>
UTC Datetime: 2012-03-01 15:06:15 UTC
Raw Date: Fri, 02 Mar 2012 08:06:15 +1000

Raw message

Hi Raphael.

I've tried steering people away from the http://logout URL and getting 
them to bookmark the "http://10.1.0.1:3990/logoff" link (which will 
change based on your hotspot settings). The http://logout is just a 
"domain name" without any top level domain. For example, if you have a 
local domain for your network called mynetwork.lan and it was setup 
correctly with DHCP and DNS doing the right thing, and your computers 
hostname was bob and another one was jane, from bob you could access the 
computer "jane" via http://jane.mynetwork.lan OR http://jane as long as 
the search domain was setup correctly. So all that is happening with 
http://logout is your computer does a DNS lookup for the hostname logout 
(or logout.hotspot.lan as the domain is set to hotspot.lan), which the 
DNS server on the Grase server resolves to 1.0.0.0 (logout and logoff 
will both resolve to this ip address).
This is where the real magic happens. The special ip address 1.0.0.0 is 
technically invalid, but as it's outside the subnet of the lan, the 
default route means requests to it are sent to the gateway, which is the 
hotspot server. So your browser then requests the page "/" from the 
server "logout" (which is 1.0.0.0), so the request goes to the gateway, 
where Coova see's a request to the special logout ip address 1.0.0.0 and 
logs you out, and redirects you to the login page!

So that's how it works!

The reason I've steered people away from that method of logout, was due 
to some devices triggering a bug, they'd logout, and not be able to 
login again, because when logging in, it would redirect them back to the 
logout link, getting them stuck in a loop of not being able to login. 
This was because Coova Chilli used the 1.0.0.0 request as the webpage 
you wanted to access, instead of ignoring it. I did try to write a fix 
for it, but it was easier to use the Coova logout url which Coova never 
tries to use as the redirect address (as it's not to a normal webserver).

As for making a user navigate to a specific dir. Technically yes, but 
not in the same way the logout link works. You'd need to do 1 of 2 
things. Ether you need to setup Virtualhosts based on hostname, then 
requests to "otherdir" at server 10.1.0.1 would be served by a different 
virtualhost than requests to "thisdir" at server 10.1.0.1 etc etc. 
(Lookup Virtualhosts for some more information, and you'd need to add a 
file to /etc/dnsmasq.d/ directory to make those hostnames resolve to the 
correct ip address.
Or, put a script index.php in the root directory of the webserver 
(usually /var/www, the /usr/share/grase/www directory is an aliased 
directory and only used when you put /grase/ on the url), which will 
catch your requests to "http://otherdir/" and "http://thisdir/" (still 
need the dnsmasq.d stuff), and based on the variables inside PHP, can 
detect which hostname was used, and then send back a redirect to 
redirect the user to where ever you want.

i.e.
<?php
switch ($_SERVER['SERVER_NAME']) {
     case "otherdir":
         header('Location: http://google.com/search?q=otherdir');
         break;
     case "thisdir":
         header('Location: 
http://thisdir/some/webpage/youwant/them/to/land/on');
         break;
     default:
         header('Location: http://grasehotspot.org/');
         break;

}
?>

Probably more detail than you wanted, but hey, now you know!

Tim

On 02/03/12 02:47, it***r@thesanctuarythailand.com wrote:
>
> Hi Tim, im interested in finding out how linux was made to perform a 
> logout action when http://logout is typed into the URL? Is it possible 
> to make a user navigate to a specific dir? such as http://otherdir     
>  would go to /usr/share/grase/www/otherdir
>
> Sorry but i am a linux novice!
>
> If you read this could you please answer my other post!
>
> Many Thanks
>
> ------------------------------------------------------------------------
> Email sent using Atmail - Email, Groupware and Calendaring done right.
>
>
> This body part will be downloaded on demand.
>
>
> This body part will be downloaded on demand.


Thread