[Rebase] Impostor Client Web version (#19)

* Impostor Client Web version

Create a web page to download regionInfo.dat and instruct to where to save it.

* Web Client: Add port input field

- Add port input field (default: 22023)
- Fix typo issue: Amoug -> Among
- Fix Layout issues on Mobile
- Support server port in link's hash
This commit is contained in:
Igor Fernandes authored and GitHub committed 2020-09-26 21:19:08 +02:00
1 parent bdd6ff7ba9
commit ca31338c69
5 files changed
+209

No files matched your search

BIN
View File
Binary file not shown.
View File
Whitespace-only changes.
+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Impostor | Among Us Private Server</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body class="row flex-column justify-content-center align-items-center p-0 m-0">
<div class="container text-light d-flex flex-column justify-content-center p-4 p-md-3" style="flex: 1;">
<section class="container mb-4">
<div class="row justify-content-center">
<h1 class="site-title text-center">Impostor</h1>
</div>
<div class="row justify-content-center">
<h2 class="site-subtitle text-center">Among Us Private Server</h2>
</div>
</section>
<section class="container">
<div class="mb-4 mb-md-3">
<h3 class="text-center text-md-left mb-4 mb-md-3 w-100">Connect to a Server</h3>
<p class="text-justify text-sm-center text-md-left support-text desktop-support">To play on a private server, type the server IP and overwrite the <b>regionInfo.dat</b> file in <b>C:\Users\YOUR USER\AppData\LocalLow\Innersloth\Among Us</b>.</p>
<p class="text-justify text-sm-center text-md-left support-text android-support">To play on a private server, type the server IP and overwrite the <b>regionInfo.dat</b> file in <b>Internal Storage/Android/data/com.innersloth.spacemafia/files</b>.</p>
<p class="text-justify text-sm-center text-md-left support-text ios-support">Your iPhone must be jailbroken to overwrite the <b>regionInfo.dat</b> in the game folder.</p>
</div>
<form id="serverFileForm" class="container p-0">
<div class="row justify-content-center mb-5 mb-md-4">
<div class="row justify-content-center flex-nowrap" stlye="max-width: 350px">
<input class="form-control form-control-lg bg-transparent text-light text-center mr-2"
type="text" placeholder="Server IP" id="ip" name="ip" required
pattern="^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
data-mask=099.099.099.099 data-mask-selectonfocus="true">
<input class="form-control form-control-lg bg-transparent text-light" style="max-width: 110px"
type="number" placeholder="Port" id="port" name="port" min="1" max="65535" required>
</div>
</div>
<div class="row justify-content-center">
<button class="btn btn-primary btn-lg">Download server file</button>
</div>
</form>
</section>
</div>
<footer class="container text-light text-center">
<p>To create a server, see the instructions in <a href="https://github.com/AeonLucid/Impostor">Github</a> project page.</p>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js" type="text/javascript"></script>
<script src="script.js"></script>
</body>
</html>
+115
View File
@@ -0,0 +1,115 @@
var REGION_NAME = "Impostor"
var SERVER_PORT = 22023;
$(document).ready(function(){
fillIPAdressUsingLocationHash();
showPlatformText();
$("#serverFileForm").submit(function(e){
e.preventDefault();
let serverIp = $("#ip").val();
let serverPort = $("#port").val();
let serverFileBytes = generateServerFile(REGION_NAME, serverIp, serverPort);
let blob = new Blob([serverFileBytes.buffer]);
saveFile(blob, "regionInfo.dat");
});
});
function fillIPAdressUsingLocationHash() {
let urlServerAddress = document.location.hash.substr(1).split(":");
let serverIp = urlServerAddress[0];
let serverPort = urlServerAddress.length > 1 ? urlServerAddress[1] : SERVER_PORT.toString();
const ipPattern = $("#ip").attr("pattern");
if (new RegExp(ipPattern).test(serverIp)) {
$("#ip").val(serverIp);
}
if (new RegExp("^[0-9]+$", "g").test(serverPort)) {
$("#port").val(serverPort);
}
}
function showPlatformText() {
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {
$('.ios-support').show();
} else if (navigator.userAgent.match(/android/i)) {
$('.android-support').show();
} else {
$('.desktop-support').show();
}
}
function generateServerFile(regionName, ip, port) {
let bytesArray = int32(0);
bytesArray.push(regionName.length);
bytesArray = concatArrays(bytesArray, stringToBytes(regionName));
bytesArray.push(ip.length);
bytesArray = concatArrays(bytesArray, stringToBytes(ip));
bytesArray = concatArrays(bytesArray, int32(1));
let serverName = regionName + "-Master-1";
bytesArray.push(serverName.length);
bytesArray = concatArrays(bytesArray, stringToBytes(serverName));
bytesArray = concatArrays(bytesArray, ipAddressToBytes(ip));
bytesArray = concatArrays(bytesArray, int16(port));
bytesArray = concatArrays(bytesArray, int32(0));
return Uint8Array.from(bytesArray);
}
function saveFile(blob, fileName) {
let url = URL.createObjectURL(blob);
let a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
a.href = url;
a.download = fileName;
a.click();
URL.revokeObjectURL(url);
}
function stringToBytes(str) {
let bytes = [];
for (let i = 0; i < str.length; i++) {
bytes.push(str.charCodeAt(i));
}
return bytes;
}
function int16(int) {
//Convert integer number to little-endian 16-bits int representation
return [(int & 0xFF),
(int & 0xFF00) >> 8];
}
function int32(int) {
//Convert integer number to little-endian 32-bits int representation
return [(int & 0xFF),
(int & 0xFF00) >> 8,
(int & 0xFF0000) >> 16,
(int & 0xFF000000) >> 24];
}
function ipAddressToBytes(ipAddress) {
let octets = ipAddress.split(".");
let bytes = [];
for(let i = 0; i < octets.length; i++) {
bytes.push(parseInt(octets[i]));
}
return bytes;
}
function concatArrays(array1, array2) {
let newArray = [];
for (let i = 0; i < array1.length; i++) {
newArray.push(array1[i]);
}
for (let i = 0; i < array2.length; i++) {
newArray.push(array2[i]);
}
return newArray;
}
+39
View File
@@ -0,0 +1,39 @@
@font-face {
font-family: AloneOnEarth;
font-style: normal;
font-weight: normal;
src: local('AloneOnEarth'), url('AloneOnEarthRegular.ttf') format('truetype');
}
html, body {
min-height: 100vh;
margin: 0;
}
body {
background-color: #252525;
}
.container {
max-width: 800px;
}
.row {
margin-left: 0;
margin-right: 0;
}
.site-title {
font-family: AloneOnEarth;
font-size: 6rem;
margin-bottom: -1.5rem;
}
.site-subtitle {
font-size: 1.6rem;
}
.support-text {
display: none;
word-break: break-all;
}