init commit
This commit is contained in:
commit
87952f36ff
8 changed files with 1910 additions and 0 deletions
22
public/auth.php
Normal file
22
public/auth.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
//Scrape current list of registered streamers from the json file that contains them from a non-web accessible folder
|
||||
$validStreamers = json_decode(file_get_contents(realpath('../auth.json')));
|
||||
|
||||
//For each streamer
|
||||
foreach($validStreamers as $curStreamer){
|
||||
//If the given stream key matches the current registered streamer
|
||||
if(password_verify($_POST['name'], $curStreamer->hash)){
|
||||
//Log Stream
|
||||
file_put_contents("status.json", json_encode(array("status"=>array("name"=>$curStreamer->name, "time"=>time()))));
|
||||
|
||||
//Redirect to the public stream
|
||||
header("Location: rtmp://127.0.0.1/public/index");
|
||||
|
||||
//Prevent further execution
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
//If we fell through the loop with no matches, return 403 forbidden
|
||||
http_response_code(403);
|
||||
?>
|
||||
3
public/end.php
Normal file
3
public/end.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
file_put_contents("status.json", json_encode(array("status"=>"offair")));
|
||||
?>
|
||||
1161
public/lib/bcrypt.js
Normal file
1161
public/lib/bcrypt.js
Normal file
File diff suppressed because it is too large
Load diff
90
public/register.html
Normal file
90
public/register.html
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>RSSSSA - Keygen</title>
|
||||
</head>
|
||||
<body style="display: flex; flex-direction: column; align-items: center; text-align: center;">
|
||||
<h1>Rainbownapkins's Super Stupid Simple Stream Authenticator</h1>
|
||||
<h2 style="margin-bottom: 0;">Your stream key hash:</h2>
|
||||
<h4 style="margin-top: 0;">(Send this to your server's administrator so they can add your key to the server.)</h4>
|
||||
<h1 id="hash" style="user-select: all;">NULL</h1>
|
||||
<h2 style="margin-bottom: 0;">Your Stream Key:</h2>
|
||||
<h4 style="margin-top: 0;">(Keep this in your password manager to authenticate with, <span style='color:red;'>DO NOT SHARE THIS!</span>)</h4>
|
||||
<h1 id="key" style="user-select: all;">NULL</h1>
|
||||
<button style="margin-top: 2em; height: 4em; width: 10em;">Generate Key</button>
|
||||
</body>
|
||||
<footer>
|
||||
<script type="module">
|
||||
import bcrypt from '/lib/bcrypt.js';
|
||||
|
||||
function displayKey(){
|
||||
//Gen a new key
|
||||
let key = genKey();
|
||||
//Display that shit
|
||||
document.querySelector('#key').innerText = key;
|
||||
//Display hash
|
||||
document.querySelector('#hash').innerText = hashKey(key);
|
||||
}
|
||||
|
||||
function genKey(){
|
||||
//Number of chars to generate
|
||||
let keyLength = 25;
|
||||
//Generate a set of cryptographically secure random numbers to derive a stream key from
|
||||
let rnum = crypto.getRandomValues(new Uint8Array(keyLength));
|
||||
//Make a string to hold the key
|
||||
let key = '';
|
||||
|
||||
//For each random digit
|
||||
rnum.forEach((num) => {
|
||||
//We cant use the entire ascii table since most of those chars aren't URL safe
|
||||
//Instead we forst adjust the number to fit between the range of 0-77, then map parts of said range to the ascii table
|
||||
//to generate a url-safe and crpytographically secure stream key
|
||||
let adjustedNum = Math.round(((num * 87) / 255));
|
||||
|
||||
//If we pulled a 9
|
||||
if(adjustedNum <= 9){
|
||||
//Adjust number to proper ascii range for 0-9 and convert to char
|
||||
key += String.fromCharCode(adjustedNum + 48);
|
||||
//If we pulled between a 10 and 35
|
||||
}else if(adjustedNum >= 10 && adjustedNum <= 35){
|
||||
//Adjust number to proper ascii range for A-Z and convert to char
|
||||
key += String.fromCharCode((adjustedNum - 10) + 65);
|
||||
//If we pulled between a 36 and 61
|
||||
}else if(adjustedNum >= 36 && adjustedNum <= 61){
|
||||
//Adjust number to proper ascii range for A-Z and convert to char
|
||||
key += String.fromCharCode((adjustedNum - 36) + 97);
|
||||
//If we pulled between a 61 and 66 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 61 && adjustedNum <= 66){
|
||||
//Add a dash
|
||||
key += '-';
|
||||
//If we pulled between a 67 and 72 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 67 && adjustedNum <= 72){
|
||||
//Add a period
|
||||
key += '.';
|
||||
//If we pulled between a 73 and 78 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 73 && adjustedNum <= 78){
|
||||
//Add an underscore
|
||||
key += '_';
|
||||
//If we pulled between a 79 and 84 (weighted to ensure occurance)
|
||||
}else if(adjustedNum >= 79 && adjustedNum <= 84){
|
||||
//Add a tilde
|
||||
key += '~';
|
||||
}
|
||||
});
|
||||
|
||||
//return our key
|
||||
return key;
|
||||
}
|
||||
|
||||
function hashKey(key){
|
||||
return bcrypt.hashSync(key, 10);
|
||||
}
|
||||
|
||||
//Display a new key on refresh
|
||||
displayKey();
|
||||
|
||||
//Make the button do the thing
|
||||
document.querySelector('button').addEventListener('click', displayKey);
|
||||
</script>
|
||||
</footer>
|
||||
</html>
|
||||
1
public/status.json
Normal file
1
public/status.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"status":"offair"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue