private string getCaptivePortalDetectionURL(InternetReachabilityVerifier.CaptivePortalDetectionMethod cpdm) { if (cpdm == InternetReachabilityVerifier.CaptivePortalDetectionMethod.Custom) { return(this.customMethodURL); } if (cpdm == InternetReachabilityVerifier.CaptivePortalDetectionMethod.Google204) { return("http://clients3.google.com/generate_204"); } if (cpdm == InternetReachabilityVerifier.CaptivePortalDetectionMethod.MicrosoftNCSI) { return("http://www.msftncsi.com/ncsi.txt"); } if (cpdm == InternetReachabilityVerifier.CaptivePortalDetectionMethod.GoogleBlank) { return("http://www.google.com/blank.html"); } if (cpdm == InternetReachabilityVerifier.CaptivePortalDetectionMethod.Apple) { return("http://www.google.com/blank.html"); } if (cpdm == InternetReachabilityVerifier.CaptivePortalDetectionMethod.Ubuntu) { return("http://start.ubuntu.com/connectivity-check"); } return(string.Empty); }
private void Start() { if (this.captivePortalDetectionMethod == InternetReachabilityVerifier.CaptivePortalDetectionMethod.DefaultByPlatform) { this.captivePortalDetectionMethod = InternetReachabilityVerifier.CaptivePortalDetectionMethod.MicrosoftNCSI; if (this.captivePortalDetectionMethod == InternetReachabilityVerifier.CaptivePortalDetectionMethod.DefaultByPlatform) { this.captivePortalDetectionMethod = InternetReachabilityVerifier.CaptivePortalDetectionMethod.MicrosoftNCSI; } } if (this.captivePortalDetectionMethod == InternetReachabilityVerifier.CaptivePortalDetectionMethod.Google204 && Array.IndexOf <RuntimePlatform>(InternetReachabilityVerifier.methodGoogle204Supported, Application.platform) < 0) { this.captivePortalDetectionMethod = InternetReachabilityVerifier.CaptivePortalDetectionMethod.GoogleBlank; } if (this.captivePortalDetectionMethod != InternetReachabilityVerifier.CaptivePortalDetectionMethod.Custom || this.customMethodURL.Length != 0) { base.StartCoroutine(this.netActivity()); return; } UnityEngine.Debug.LogError("IRV - Custom method is selected but URL is empty, cannot start! (disabling component)", this); base.enabled = false; }
private bool checkCaptivePortalDetectionResult(InternetReachabilityVerifier.CaptivePortalDetectionMethod cpdm, WWW www) { if (www == null) { return(false); } if (www.error != null && www.error.Length > 0) { return(false); } switch (cpdm) { case InternetReachabilityVerifier.CaptivePortalDetectionMethod.Google204: { Dictionary <string, string> strs = www.responseHeaders; string empty = string.Empty; if (strs.ContainsKey("STATUS")) { empty = strs["STATUS"]; } else if (strs.ContainsKey("NULL")) { empty = strs["NULL"]; } if (empty.Length > 0) { if (empty.IndexOf("204 No Content") >= 0) { return(true); } } else if (www.size == 0) { return(true); } break; } case InternetReachabilityVerifier.CaptivePortalDetectionMethod.GoogleBlank: { if (www.size == 0) { return(true); } break; } case InternetReachabilityVerifier.CaptivePortalDetectionMethod.MicrosoftNCSI: { if (www.text.StartsWith("Microsoft NCSI")) { return(true); } break; } case InternetReachabilityVerifier.CaptivePortalDetectionMethod.Apple: { if (www.text.IndexOf("<BODY>Success</BODY>") < 50) { return(true); } break; } case InternetReachabilityVerifier.CaptivePortalDetectionMethod.Ubuntu: { if (www.text.IndexOf("Lorem ipsum dolor sit amet") == 109) { return(true); } break; } case InternetReachabilityVerifier.CaptivePortalDetectionMethod.Custom: { if (this.customMethodVerifierDelegate != null) { return(this.customMethodVerifierDelegate(www, this.customMethodExpectedData)); } if (www.text.StartsWith(this.customMethodExpectedData)) { return(true); } break; } } return(false); }