Class WebLocationChecker
Original code by andyman from Github:
https://gist.github.com/andyman/e58dea85cce23cccecff
Extra modifications by jcx from Github:
https://gist.github.com/jcx/93a3fc93531911add8a8
Add this script to an object in the first scene of your game. For WebGL builds, this script grabs the domain the game is running on, and verifies it against two lists:
- The list of strings in DefaultDomainList.
-
Optionally, if RemoteDomainListUrl isn't an empty string
(or null), this script will attempt to download from the specified url,
and read it as a
. If successful, the globs listed in the will be used to match the domain as well. Remember that if the is encrypted, the OmiyaGames.Web.Security.WebLocationChecker.domainDecrypter needs to be set in the Unity inspector to help decrypt the content of the list.
IEnumerator Start()
{
WebLocationChecker checker = GetComponent<WebLocationChecker>();
yield return StartCoroutine(checker.CheckDomainList());
Debug.Log(checker.CurrentState);
}
If the script is attached to a Namespace: OmiyaGames.Web.Security
Assembly: cs.temp.dll.dll
Syntax
public class WebLocationChecker : ISingletonScript
Remarks
Copyright (c) 2014-2020 Omiya Games Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Revision | Description |
---|---|
Date: 5/15/2016 Author: Taro Omiya | Initial verison. |
Date: 6/5/2018 Author: Taro Omiya | Removed plain-text support. |
Date: 2/12/2019 Author: Taro Omiya |
Adding encryption support of the binary |
Version: 0.1.0-preview.1 Date: 5/20/2020 Author: Taro Omiya | Converting to package. Improving documentation for DocFX support. |
Version: 0.1.1-preview.1 Date: 5/22/2020 Author: Taro Omiya | Fixing documentation to actually be XML-compliant |
Fields
RemoteDomainListHeader
Header string for the Unity Inspector.
Declaration
public const string RemoteDomainListHeader = "Remote Domain List"
Field Value
Type | Description |
---|---|
String |
Properties
AllUniqueDomains
The
Declaration
public Dictionary<string, Regex> AllUniqueDomains { get; }
Property Value
Type | Description |
---|---|
Dictionary<String, Regex> |
CurrentState
Indicates the state this script is in. WebLocationChecker.State
Declaration
public WebLocationChecker.State CurrentState { get; }
Property Value
Type | Description |
---|---|
WebLocationChecker.State |
DefaultDomainList
The default list of domains to match RetrievedHostName against.
This list excludes the globs stored in a
Declaration
public string[] DefaultDomainList { get; }
Property Value
Type | Description |
---|---|
String[] |
DownloadDomainsUrl
The URL used to download a
Declaration
public string DownloadDomainsUrl { get; }
Property Value
Type | Description |
---|---|
String |
DownloadedDomainList
The list of globs in a
Declaration
public string[] DownloadedDomainList { get; }
Property Value
Type | Description |
---|---|
String[] |
DownloadErrorMessage
Indicates the error when attempting to download a
Declaration
public string DownloadErrorMessage { get; }
Property Value
Type | Description |
---|---|
String |
IsDomainListSuccessfullyDownloaded
Indicates if a
Declaration
public bool IsDomainListSuccessfullyDownloaded { get; }
Property Value
Type | Description |
---|---|
Boolean |
RemoteDomainListUrl
The original URL to download a
Declaration
public string RemoteDomainListUrl { get; }
Property Value
Type | Description |
---|---|
String |
RetrievedHostName
The domain this WebGL build is running on.
Declaration
public string RetrievedHostName { get; }
Property Value
Type | Description |
---|---|
String |
Methods
CheckDomainList()
Declaration
public IEnumerator CheckDomainList()
Returns
Type | Description |
---|---|
IEnumerator |
ForceRedirect()
Makes the build redirect the browser to OmiyaGames.Web.Security.WebLocationChecker.redirectURL.
Declaration
public void ForceRedirect()
SceneAwake()
Declaration
public override void SceneAwake()
SingletonAwake()
Declaration
public override void SingletonAwake()