This commit is contained in:
Elizabeth Cray 2023-10-07 00:28:02 +00:00
parent b8e60396b8
commit 238f694e9a
6 changed files with 213 additions and 4 deletions

View File

@ -19,6 +19,7 @@ Warrant canary available at /etc/ttyserver/canary
* [ ] Canary description popup? * [ ] Canary description popup?
* [ ] Shift-Click for Keygen Options * [ ] Shift-Click for Keygen Options
* [ ] Download SSH Public Key on fingerprint click? * [ ] Download SSH Public Key on fingerprint click?
* [ ] Better font scaling for long text
## Completed TODO: ## Completed TODO:
* Change Sign Up to Log In * Change Sign Up to Log In

View File

@ -61,6 +61,71 @@ if (isset($_REQUEST["act"])) {
returnError("Incorrect Verify Query"); returnError("Incorrect Verify Query");
} }
break; break;
case "gemproxy":
if (isset($_REQUEST["token"])){
// Verify Encrypted Token
$EncTokenData = $_REQUEST["token"];
$TokenData = verifyEncToken($EncTokenData);
if (gettype($TokenData) == "string") {
// Invalid Token
returnError($TokenData);
}else{
// Valid Token
if (isset($_REQUEST["enable"])){
if (!userExists($TokenData["MastodonData"]->username)){
returnError("User Home Directory Not Found, try making a new SSH key.");
} else {
switch ($_REQUEST["enable"]){
case "yes":
shell_exec("/usr/bin/sudo /etc/ttyserver/bin/toggleProxy enable \"".$TokenData["MastodonData"]->username."\"");
returnSuccess("Gemini Proxy Enabled", buildEncToken($TokenData["AuthToken"],
$TokenData["UserID"],
$_SERVER["REMOTE_ADDR"],
$_SERVER["HTTP_USER_AGENT"]));
break;
case "no":
$result = trim(shell_exec("/usr/bin/sudo /etc/ttyserver/bin/toggleProxy disable \"".$TokenData["MastodonData"]->username."\""));
switch($result){
case "done":
returnSuccess("Gemini Proxy Disabled", buildEncToken($TokenData["AuthToken"],
$TokenData["UserID"],
$_SERVER["REMOTE_ADDR"],
$_SERVER["HTTP_USER_AGENT"]
));
break;
case "no_perm":
returnError("Gemini Proxy Disable Failed, error_p");
break;
case "no_dir":
returnError("Gemini Directory Not Found");
break;
default:
returnError("Gemini Proxy Disable Failed, error_u");
break;
}
break;
case "get":
$result = trim(shell_exec("/usr/bin/sudo /etc/ttyserver/bin/toggleProxy get \"".$TokenData["MastodonData"]->username."\""));
returnSuccess(($result == "enabled"), buildEncToken($TokenData["AuthToken"],
$TokenData["UserID"],
$_SERVER["REMOTE_ADDR"],
$_SERVER["HTTP_USER_AGENT"]
));
break;
default:
returnError("Incorrect Gemini Proxy Query");
break;
}
}
}else {
returnError("Incorrect Gemini Proxy Query");
}
}
}
break;
default: default:
returnError("Incorrect Action Query"); returnError("Incorrect Action Query");
break; break;

View File

@ -6,6 +6,14 @@ const SwalConfig = {
color: "#79F257", color: "#79F257",
background: "#022601", background: "#022601",
buttonsStyling: false, buttonsStyling: false,
showClass: {
backdrop: 'swal2-noanimation',
popup: '',
icon: ''
},
hideClass: {
popup: '',
}
}; };
const invalidChars = ["/", "\\", ">", "<", ":", "*", "|", '"', "'", "?", "\0"]; const invalidChars = ["/", "\\", ">", "<", ":", "*", "|", '"', "'", "?", "\0"];
@ -35,7 +43,12 @@ const post = (url, data, callback) => {
}, },
data: data data: data
}; };
$.ajax(settings).done(callback); $.ajax(settings).done((data) => {
if (typeof data.token !== "undefined") {
localStorage.setItem("tty_token", data.token);
}
callback(data);
});
}; };
const saveFile = (name, type, data) => { const saveFile = (name, type, data) => {
@ -240,6 +253,54 @@ const logout = () => {
window.location.href = "/?msg=End%20Of%20Line."; window.location.href = "/?msg=End%20Of%20Line.";
}; };
const gemini = () => {
var payload = {
token: localStorage.getItem("tty_token"),
act: "gemproxy",
enable: "get"
};
post(USE_ORIGIN + "/auth/api/index.php", payload, (response) => {
console.dir(response.data);
$.get(USE_ORIGIN + "/auth/gem.html", (ui) => {
ui = ui.replace("checked", response.data?"checked":"");
console.log(ui);
Swal.fire({
...SwalConfig,
title: "Gemini Settings",
html: ui,
willClose: (doc) => {
switch(doc.getElementsByTagName("input")[0].checked){
case true:
payload.enable = "yes";
break;
case false:
payload.enable = "no";
break;
default:
break;
}
payload.token = localStorage.getItem("tty_token");
post(USE_ORIGIN + "/auth/api/index.php", payload, (set_response) => {
if(set_response.error){
Swal.fire({
...SwalConfig,
title: "Config Failed",
text: set_response.error,
});
}else {
Swal.fire({
...SwalConfig,
title: "Success",
text: set_response.data,
});
}
});
}
});
})
});
};
$(() => { $(() => {
// On Page Load // On Page Load
// Override domain // Override domain

View File

@ -9,6 +9,7 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/jszip@3.9.1/dist/jszip.min.js" integrity="sha256-aSPPIlJfSHQ5T7wunbPcp7tM0rlq5dHoUGeN8O5odMg=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/jszip@3.9.1/dist/jszip.min.js" integrity="sha256-aSPPIlJfSHQ5T7wunbPcp7tM0rlq5dHoUGeN8O5odMg=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js" crossorigin="anonymous"></script>
<script src="https://livejs.com/live.js" crossorigin="anonymous"></script>
<script src="/fittext.js"></script> <script src="/fittext.js"></script>
<!-- Stylesheets --> <!-- Stylesheets -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

View File

@ -50,6 +50,8 @@ const failMsg = (msg) => {
...SwalConfig, ...SwalConfig,
title: "Error!", title: "Error!",
text: msg, text: msg,
}).then(() => {
window.location.replace("/");
}); });
} }

View File

@ -8,6 +8,11 @@
src: url("/Assets/Fonts/C64-Rounded.ttf") format("truetype"); src: url("/Assets/Fonts/C64-Rounded.ttf") format("truetype");
} }
@font-face {
font-family: Space;
src: url("/Assets/Fonts/SpaceGrotesk.ttf") format("truetype");
}
body { body {
background-color: black; background-color: black;
background-image: url("/Assets/wallpaper4k.png"); background-image: url("/Assets/wallpaper4k.png");
@ -53,6 +58,7 @@ span {
.button { .button {
margin: 8px; margin: 8px;
} }
.button>button { .button>button {
background-color: #377326; background-color: #377326;
color: #79F257; color: #79F257;
@ -85,7 +91,9 @@ span {
display: none; display: none;
} }
.swal2-confirm, .swal2-deny, .swal2-cancel { .swal2-confirm,
.swal2-deny,
.swal2-cancel {
border: 1px solid #79F257; border: 1px solid #79F257;
background-color: #377326; background-color: #377326;
color: #79F257; color: #79F257;
@ -98,6 +106,10 @@ span {
background-color: #022601; background-color: #022601;
} }
.swal2-html-container {
overflow: hidden !important;
}
.footerbutton { .footerbutton {
background: none; background: none;
border: none; border: none;
@ -107,9 +119,11 @@ span {
td { td {
border: 1px solid #3a4c35; border: 1px solid #3a4c35;
} }
td:first-child { td:first-child {
border-left: 2px solid #3a4c35; border-left: 2px solid #3a4c35;
} }
.fingerprintTable { .fingerprintTable {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
@ -132,3 +146,68 @@ td:first-child {
.emoji { .emoji {
height: 2em; height: 2em;
} }
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #3a4c35;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: #79F257;
-webkit-transition: .4s;
transition: .4s;
}
input:checked+.slider {
background-color: #377326;
}
input:focus+.slider {
box-shadow: 0 0 1px #377326;
}
input:checked+.slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
.name {
font-family: Space, Courier, monospace;
white-space: nowrap;
font-size: 2vw;
}