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

Need login for internet #39

Closed
hashier opened this issue May 27, 2013 · 5 comments
Closed

Need login for internet #39

hashier opened this issue May 27, 2013 · 5 comments

Comments

@hashier
Copy link

hashier commented May 27, 2013

In my network I need to authenticate before having 'real' access to the internet. Before that authentication I can resolve DNS hostnames to IP but not more.

Reachability always tells me that I am connected as long as I get an DNS reply. There should be an option to check e.g. with a ping request or maybe even do a HEAD http request to see if we have 'real' internet.

@tonymillion
Copy link
Owner

If you have a look at the connection flags (using the reachabilityFlags method) and check kSCNetworkReachabilityFlagsInterventionRequired is set, that will let you know the app needs to present a login browser.

@hashier
Copy link
Author

hashier commented May 28, 2013

That's not working either:

Code:
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
NSLog(@"%@", [reach currentReachabilityFlags]);
NSLog(@"%@", [reach currentReachabilityString]);
if ([reach isInterventionRequired]) {
NSLog(@"DNS works, but no internet");
} else {
NSLog(@"Connected to the internet");
}
reach.reachableBlock = ^(Reachability*reach)
{
NSLog(@"REACHABLE!");
};

Output:
2013-05-28 20:11:25.009 test[57961:c07] -R -------
2013-05-28 20:11:25.011 test[57961:c07] WiFi
2013-05-28 20:11:25.012 test[57961:c07] Connected to the internet
2013-05-28 20:11:25.051 test[57961:1903] REACHABLE!

From my mac:
$ ping google.com
PING google.com (173.194.69.139): 56 data bytes
Request timeout for icmp_seq 0

And if I open a browser I get to a webpage where I have to authenticate

@xanderdunn
Copy link

I'm also having difficulty with this scenario. It would be really nice to have a simple solution to this situation because working DNS without a working Internet is the same to app users: I need to tell them they have a network problem. A good example is free airport Wifi. Although I have isReachable == True, I also have isInterventionRequired == NO, even though I get a login screen in any browser and I'm unable to access any websites.

@tonymillion
Copy link
Owner

I can't really do anything about captive portals like this.

The best bet would be to do this at the application level i.e.

  1. Create a server endpoint that returns a specific response e.g. OK_APPNAME
  2. When reachability reports its reachable attempt to contact a server you control over HTTP and check the response.
  3. if response != OK_APPNAME then its a safe bet to say you have some kind of MITM

@hashier
Copy link
Author

hashier commented Feb 7, 2015

It would be cool if reachability would help out with this for example set an endpoint www.example.com/json and when this json returns something predefined reachability says "internet available".

Or trying to fetch the header from google.com and see if it says google in it or something else, e.g. airport/hotel name of providing internet service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants