Skip to content

Commit

Permalink
make captive portal work again for iOS11
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed May 3, 2018
1 parent 6c537b2 commit e3f1ffb
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 9 deletions.
41 changes: 41 additions & 0 deletions Assets/HappyFunTimes/HappyFunTimesCore/Server/HFTBrowserVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Text.RegularExpressions;

namespace HappyFunTimes {
public class HFTBrowserVersion {
static public bool IsIOS(string userAgent)
{
return m_iosRE.IsMatch(userAgent);
}

public class Version {
public Version(int major = 0, int minor = 0)
{
Major = major;
Minor = minor;
}
public int Major = 0;
public int Minor = 0;
};

static public Version IOSVersion(string userAgent)
{
var m = m_versionRE.Match(userAgent);
if (m.Success)
{
return new Version(
Int32.Parse(m.Groups[1].ToString()),
Int32.Parse(m.Groups[2].ToString()));
}
return new Version();
}

static public bool IsIOS10(string userAgent)
{
return IsIOS(userAgent) && IOSVersion(userAgent).Major == 10;
}

static private Regex m_iosRE = new Regex("iPad|iPhone");
static private Regex m_versionRE = new Regex("OS (\\d+)_(\\d+)\\D");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ bool Check(string path, HttpListenerRequest req, HttpListenerResponse res)
bool isIndexURL = path.Equals("/index.html", StringComparison.Ordinal) ||
path.Equals("/", StringComparison.Ordinal) ||
path.Equals(m_firstPath, StringComparison.Ordinal);
bool isIOS10 = HFTBrowserVersion.IsIOS10(req.UserAgent);

if (isIndexURL)
{
Expand All @@ -53,7 +54,7 @@ bool Check(string path, HttpListenerRequest req, HttpListenerResponse res)
if (isLoginURL)
{
session.loggedIn = true;
return SendCaptivePortalHTML(req, res, sessionId, "/hft/captive-portal/game-login.html");
return SendCaptivePortalHTML(req, res, sessionId, isIOS10 ? "/hft/captive-portal/game-login-manual.html" : "/hft/captive-portal/game-login.html");
}

// We've seen this device before. Either it's checking that it can connect or it's asking for a normal webpage.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["icon-16.png","3rdparty/audiomanager-min.js","3rdparty/audiomanager.js","3rdparty/chroma.min.js","3rdparty/game-utils-min.js","3rdparty/game-utils.js","3rdparty/gyronorm.complete.min.js","controllers/camera/controller.html","controllers/camera/css/controller.css","controllers/camera/scripts/controller.js","controllers/character-select/controller.html","controllers/character-select/css/controller.css","controllers/character-select/images/cube.svg","controllers/character-select/images/cylinder.svg","controllers/character-select/images/sphere.svg","controllers/character-select/scripts/controller.js","controllers/clean/controller.html","controllers/gamepad/controller.html","controllers/gamepad/css/controller.css","controllers/gamepad/images/bird.png","controllers/gamepad/images/hft-circle-button.svg","controllers/gamepad/images/hft-down-arrow-button.svg","controllers/gamepad/images/hft-left-arrow-button.svg","controllers/gamepad/images/hft-right-arrow-button.svg","controllers/gamepad/images/hft-up-arrow-button.svg","controllers/gamepad/scripts/controller.js","controllers/gamepad/sounds/explosion.mp3","controllers/gamepad/sounds/gameover.mp3","controllers/gamepad/sounds/launch.mp3","controllers/gamepad/sounds/sounds.jsfx.txt","controllers/multi-machine/controller.html","controllers/multi-machine/css/controller.css","controllers/multi-machine/images/bird.png","controllers/multi-machine/images/hft-circle-button.svg","controllers/multi-machine/images/hft-down-arrow-button.svg","controllers/multi-machine/images/hft-left-arrow-button.svg","controllers/multi-machine/images/hft-right-arrow-button.svg","controllers/multi-machine/images/hft-up-arrow-button.svg","controllers/multi-machine/scripts/controller.js","controllers/simple/controller.html","controllers/simple/css/controller.css","controllers/simple/scripts/controller.js","controllers/syncedclock/controller.html","controllers/syncedclock/assets/clocktick.mp3","controllers/syncedclock/assets/clocktick.ogg","controllers/syncedclock/css/controller.css","controllers/syncedclock/scripts/controller.js","hft/hft-min.js","hft/hft.js","hft/missing.html","hft/assets/gear-icon.svg","hft/captive-portal/captive-portal.html","hft/captive-portal/game-login.html","hft/captive-portal/login.css","hft/captive-portal/xtra2.bin","sample-ui/sample-ui-min.js","sample-ui/sample-ui.css","sample-ui/sample-ui.js"]
["icon-16.png","3rdparty/audiomanager-min.js","3rdparty/audiomanager.js","3rdparty/chroma.min.js","3rdparty/game-utils-min.js","3rdparty/game-utils.js","3rdparty/gyronorm.complete.min.js","controllers/camera/controller.html","controllers/camera/css/controller.css","controllers/camera/scripts/controller.js","controllers/character-select/controller.html","controllers/character-select/css/controller.css","controllers/character-select/images/cube.svg","controllers/character-select/images/cylinder.svg","controllers/character-select/images/sphere.svg","controllers/character-select/scripts/controller.js","controllers/clean/controller.html","controllers/gamepad/controller.html","controllers/gamepad/css/controller.css","controllers/gamepad/images/bird.png","controllers/gamepad/images/hft-circle-button.svg","controllers/gamepad/images/hft-down-arrow-button.svg","controllers/gamepad/images/hft-left-arrow-button.svg","controllers/gamepad/images/hft-right-arrow-button.svg","controllers/gamepad/images/hft-up-arrow-button.svg","controllers/gamepad/scripts/controller.js","controllers/gamepad/sounds/explosion.mp3","controllers/gamepad/sounds/gameover.mp3","controllers/gamepad/sounds/launch.mp3","controllers/gamepad/sounds/sounds.jsfx.txt","controllers/multi-machine/controller.html","controllers/multi-machine/css/controller.css","controllers/multi-machine/images/bird.png","controllers/multi-machine/images/hft-circle-button.svg","controllers/multi-machine/images/hft-down-arrow-button.svg","controllers/multi-machine/images/hft-left-arrow-button.svg","controllers/multi-machine/images/hft-right-arrow-button.svg","controllers/multi-machine/images/hft-up-arrow-button.svg","controllers/multi-machine/scripts/controller.js","controllers/simple/controller.html","controllers/simple/css/controller.css","controllers/simple/scripts/controller.js","controllers/syncedclock/controller.html","controllers/syncedclock/assets/clocktick.mp3","controllers/syncedclock/assets/clocktick.ogg","controllers/syncedclock/css/controller.css","controllers/syncedclock/scripts/controller.js","hft/hft-min.js","hft/hft.js","hft/missing.html","hft/assets/gear-icon.svg","hft/captive-portal/captive-portal.html","hft/captive-portal/game-login-manual.html","hft/captive-portal/game-login.html","hft/captive-portal/login.css","hft/captive-portal/xtra2.bin","sample-ui/sample-ui-min.js","sample-ui/sample-ui.css","sample-ui/sample-ui.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
/*
* Copyright 2014, Gregg Tavares.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Gregg Tavares. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui">
<meta name="format-detection" content="telephone=no" />
<title>HappyFunTimes Redirect</title>
<link rel="stylesheet" href="/hft/captive-portal/login.css">
<style>
</style>
</head>
<body>
<div class="hft-center hft-fullsize">
<h1>HappyFunTimes</h1>
<h1>Please open your browser and go to hft.com</h1>
<!-- iOS 10.3 broke this functionality. Rumor is it might be fixed in iOS 11
<a id="start" href="%(startUrl)s" target="_blank">Start</a> -->
</div>
</body>
</html>


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
<body>
<div class="hft-center hft-fullsize">
<h1>HappyFunTimes</h1>
<h1>Please open your browser and go to hft.com</h1>
<!-- iOS 10.3 broke this functionality. Rumor is it might be fixed in iOS 11
<a id="start" href="%(startUrl)s" target="_blank">Start</a> -->
<a id="start" href="%(startUrl)s" target="_blank">Start</a>
</div>
</body>
</html>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
/*
* Copyright 2014, Gregg Tavares.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Gregg Tavares. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui">
<meta name="format-detection" content="telephone=no" />
<title>HappyFunTimes Redirect</title>
<link rel="stylesheet" href="/hft/captive-portal/login.css">
<style>
</style>
</head>
<body>
<div class="hft-center hft-fullsize">
<h1>HappyFunTimes</h1>
<h1>Please open your browser and go to hft.com</h1>
<!-- iOS 10.3 broke this functionality. Rumor is it might be fixed in iOS 11
<a id="start" href="%(startUrl)s" target="_blank">Start</a> -->
</div>
</body>
</html>


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
<body>
<div class="hft-center hft-fullsize">
<h1>HappyFunTimes</h1>
<h1>Please open your browser and go to hft.com</h1>
<!-- iOS 10.3 broke this functionality. Rumor is it might be fixed in iOS 11
<a id="start" href="%(startUrl)s" target="_blank">Start</a> -->
<a id="start" href="%(startUrl)s" target="_blank">Start</a>
</div>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion hft-server/build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cd "$script_dir/hft-server/bin/Release"
export AS="as -arch i386"
export CC="cc -arch i386 -framework CoreFoundation -lobjc -liconv"
export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/4.2.4/lib/pkgconfig
mkbundle -z --static --deps -o hft-server.osx hft-server.exe DeJson.dll websocket-sharp.dll
mkbundle -z --static --deps --sdk /Library/Frameworks/Mono.framework/Versions/Current -o hft-server.osx hft-server.exe DeJson.dll websocket-sharp.dll
cp hft-server.osx ../../../../Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.bytes
shasum -b 256 hft-server.osx > ../../../../Assets/HappyFunTimes/HappyFunTimesCore/Server/Resources/HFTOSXServer.sha256.bytes

Expand Down
3 changes: 3 additions & 0 deletions hft-server/hft-server/hft-server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
<Compile Include="..\..\Assets\HappyFunTimes\HappyFunTimesCore\DNS\Server\MasterFile.cs">
<Link>DNS\Server\MasterFile.cs</Link>
</Compile>
<Compile Include="..\..\Assets\HappyFunTimes\HappyFunTimesCore\Server\HFTBrowserVersion.cs">
<Link>HappyFunTimesCore\Server\HFTBrowserVersion.cs</Link>
</Compile>
<Compile Include="..\..\Assets\HappyFunTimes\HappyFunTimesCore\Server\HFTCaptivePortalHandler.cs">
<Link>HappyFunTimesCore\Server\HFTCaptivePortalHandler.cs</Link>
</Compile>
Expand Down

0 comments on commit e3f1ffb

Please sign in to comment.