<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RTunnel</title>
<link rel="stylesheet" href="css.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
body {
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #0f0f0f6c;
border-radius: 15px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 8px;
width: 370px;
margin: 10px;
}
.container-logo {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 8px;
width: 370px;
margin-top: -90px;
}
.flag {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 8px;
width: 35px;
height: 35px;
}
.form {
display: flex;
flex-direction: column;
align-items: center;
margin: 10px;
}
.input {
margin: 1px;
width: 100%;
}
input,
select {
width: 100%;
padding: 15px;
margin-bottom: 1px;
border-radius: 10px;
border: 2px solid #1319ce1a;
background-color: #0f0f0f6c;
color: #cbbfdf;
outline: none;
}
input::placeholder {
color: #cbbfdf;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0 30px #0f0f0f inset !important;
-webkit-text-fill-color: #cbbfdf !important;
}
#startOrStopButton {
padding: 15px;
width: 100%;
border: 1px solid;
margin-right: 5px;
margin-top: 2px;
border-radius: 10px;
background-color: #0f0f0f96;
color: #cbbfdf;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
#updateButton {
width: auto;
padding: 15px;
border: 1px solid;
margin-top: 2px;
border-radius: 10px;
background-color: #0f0f0f96;
color: #cbbfdf;
cursor: pointer;
transition: background-color 0.3s ease;
}
#startOrStopButton:hover,
#updateButton:hover {
background-color: #0f0f0f96;
}
#loggerButton {
width: auto;
padding: 15px;
border: 1px solid;
margin-top: 2px;
border-radius: 10px;
background-color: #0f0f0f96;
color: #cbbfdf;
cursor: pointer;
transition: background-color 0.3s ease;
}
#configModalButton {
padding: 15px;
border: 1px solid;
margin-top: 2px;
border-radius: 10px;
background-color: #0f0f0f96;
color: #cbbfdf;
}
#logsClose {
padding: 15px;
border: 2px solid;
margin-top: 2px;
border-radius: 10px;
background-color: #0f0f0f96;
color: #cbbfdf;
}
#logsClean {
padding: 15px;
border: 2px solid;
margin-top: 2px;
border-radius: 10px;
background-color: #0f0f0f96;
color: #cbbfdf;
}
.state {
margin-top: 10px;
text-align: center;
border: 2px solid;
padding: 8px 16px;
border-radius: 15px;
color: #962430;
font-weight: bold;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.modal-header {
border: none;
}
.modal-content {
background-color: #0f0f0fab;
color: hsl(263, 33%, 81%);
}
.close-btn {
color: #cbbfdf;
background-color: #ffffff00;
border: none;
}
.set-configs {
background-color: #1d1d1db7;
padding: 10px;
margin-bottom: 5px;
width: 100%;
border-radius: 10px;
}
.set-configs span {
color: #cbbfdf;
font-size: large;
}
.set-configs img {
margin-right: 5px;
width: 40px;
height: 40px;
}
#Operadora {
color: white;
}
#Version {
color: white;
}
</style>
</head>
<body>
<div class="container-logo">
<img id="logoImg" alt="logo" width="200" height="200">
</div>
<div id="Operadora"> Aqui</div>
<div id="Version"> Aqui</div>
<div class="form">
<div class="container">
<div class="input" id="config"></div>
<input type="button" value="Selecione uma configuração" id="configModalButton" data-bs-toggle="modal" data-bs-target="#configModal">
<div style="display: flex;">
<input type="text" style="margin-right: 1px;" placeholder="Usuário" id="user" />
<input type="text" style="margin-left: 1px;" placeholder="Senha" id="password" />
</div>
<div style="display: flex;">
<button id="startOrStopButton" onclick="startOrStop()">INICIAR VPN</button>
<button id="updateButton" onclick="app.searchUpdate()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-arrow-repeat" viewBox="0 0 16 16">
<path
d="M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 0 1-.384 0l-1.966-2.36a.25.25 0 0 1 .192-.41zm-11 2h3.932a.25.25 0 0 0 .192-.41L2.692 6.23a.25.25 0 0 0-.384 0L.342 8.59A.25.25 0 0 0 .534 9z" />
<path fill-rule="evenodd"
d="M8 3c-1.552 0-2.94.707-3.857 1.818a.5.5 0 1 1-.771-.636A6.002 6.002 0 0 1 13.917 7H12.9A5.002 5.002 0 0 0 8 3zM3.1 9a5.002 5.002 0 0 0 8.757 2.182.5.5 0 1 1 .771.636A6.002 6.002 0 0 1 2.083 9H3.1z" />
</svg>
</button>
<button data-bs-toggle="modal"
data-bs-target="#logs" id="loggerButton"
style="margin-left: 3px;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-file-earmark-text" viewBox="0 0 16 16">
<path
d="M5.5 7a.5.5 0 0 0 0 1h5a.5.5 0 0 0 0-1h-5zM5 9.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5z" />
<path
d="M9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.5L9.5 0zm0 1v2A1.5 1.5 0 0 0 11 4.5h2V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h5.5z" />
</svg>
</button>
</div>
</div>
</div>
</div>
<div class="container state" id="state">Você está desconectado !</div>
<div class="modal fade" aria-hidden="true" id="configModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" style="align-items: center;">Servidores: </h5>
<button type="button" class="close-btn" data-bs-dismiss="modal" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
class="bi bi-x-lg" viewBox="0 0 16 16">
<path
d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z" />
</svg>
</button>
</div>
<div class="modal-body">
<div id="serverOptions"></div>
</div>
</div>
</div>
</div>
<div class="modal fade" aria-hidden="true" id="checkuserModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Informações do usuario</h5>
<button type="button" class="close-btn" data-bs-dismiss="modal" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
class="bi bi-x-lg" viewBox="0 0 16 16">
<path
d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z" />
</svg>
</button>
</div>
<div class="modal-body">
<div id="checkuser">Checkuser</div>
</div>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" role="dialog" id="logs">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content rounded-3 shadow">
<div class="modal-header border-bottom-0 pb-0">
<h1 class="modal-title fs-5 text-white">LOGS</h1>
</div>
<div class="modal-body">
<ul id="logList"></ul>
</div>
<div class="modal-footer flex-nowrap p-0">
<button type="button" id="logsClean" onclick="app.clearLogs()" >LIMPAR</button>
<button type="button" id="logsClose" data-bs-dismiss="modal">FECHAR</button>
</div>
</div>
</div>
</div>
<div class="modal fade" aria-hidden="true" id="checkuserModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Informações do usuario</h5>
<button type="button" class="close-btn" data-bs-dismiss="modal" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
class="bi bi-x-lg" viewBox="0 0 16 16">
<path
d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z" />
</svg>
</button>
</div>
<div class="modal-body">
<div id="checkuser">Checkuser</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="bootstrap.js"></script>
<script>
const logoImg = document.getElementById("logoImg");
const configModalButton = document.getElementById("configModalButton");
const user = document.getElementById("user");
const pass = document.getElementById("password");
const startOrStopButton = document.getElementById("startOrStopButton");
const updateButton = document.getElementById("updateButton");
const loggerButton = document.getElementById("loggerButton");
const state = document.getElementById("state");
const operadora = document.getElementById("Operadora");
operadora.innerHTML = "Operadora: " + app.getOperadoraEmUso();
// setTema();
const version = document.getElementById("Version");
version.innerHTML = "Versão da config: " + app.getVersion();
function loadLogs() {
var logList = document.getElementById("logList");
var logs = JSON.parse(app.getlogs())
var formattedLogs = '';
logs.forEach(item => {
formattedLogs += '<li class="list-group-item bg-transparent p-0 border-0 text-start ms-2 text-wrap" style="font-size: 12px; color: var(--text-color);">';
formattedLogs += item.TIME;
formattedLogs += '</li>';
});
logList.innerHTML = '<ul class="list-group">' + formattedLogs + '</ul>';
}
var modal = new bootstrap.Modal(document.getElementById('configModal'));
const serverOptions = document.getElementById('serverOptions');
var servers = JSON.parse(app.getJsonServers());
function createServerCard(server) {
const card = document.createElement('div');
card.classList.add('set-configs');
card.style.backgroundColor = server.ConfigColor;
var configImage = document.createElement('img');
configImage.src = server.ConfigImage;
const cardBody = document.createElement('div');
cardBody.classList.add('card-body');
const cardTitle = document.createElement('h5');
cardTitle.classList.add('card-title');
const configName = document.createElement('span');
configName.textContent = server.ConfigName;
cardTitle.appendChild(configImage);
cardTitle.appendChild(configName);
cardBody.appendChild(cardTitle);
card.appendChild(cardBody);
card.addEventListener('click', function () {
selectServer(server);
});
return card;
}
function selectServer(server) {
configModalButton.value = server.ConfigName;
app.returnConfigId(server.ConfigId);
localStorage.setItem('configSelecionada', JSON.stringify(server));
modal.hide();
}
servers.forEach(function (server) {
const card = createServerCard(server);
serverOptions.appendChild(card);
});
function startOrStop() {
if (user.value != "" && pass.value != "") {
localStorage.setItem('usuario', user.value);
localStorage.setItem('senha', pass.value);
app.setUserAndPass(user.value, pass.value);
}
app.startOrStop();
}
var previousLogs = [];
function checkAndLoadLogs() {
var logs = JSON.parse(app.getlogs());
if (!arraysAreEqual(logs, previousLogs)) {
previousLogs = logs;
loadLogs();
}
}
function arraysAreEqual(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
for (var i = 0; i < arr1.length; i++) {
if (arr1[i].TIME !== arr2[i].TIME) {
return false;
}
}
return true;
}
async function startCheckuser() {
try {
const dataString = await app.getCheckuserDados();
console.log("CHECKUSER: " + dataString);
if (dataString !== "null") {
const data = JSON.parse(dataString);
var myModal = new bootstrap.Modal(document.getElementById('checkuserModal'));
myModal.show();
const strCheckValidade =
`Usuario: <span style="color: green;">${data.username}</span><br/>
Expira em: <span style="color: green;">${data.expiration_date}</span><br/>
Dias Restantes: <span style="color: green;">${data.expiration_days}</span><br/>
Conectados: <span style="color: green;">${data.count_connection} / ${data.limiter_user}</span>`;
document.getElementById('checkuser').innerHTML = strCheckValidade;
}
} catch (error) {
console.error("Erro ao buscar dados do usuário:", error);
}
}
var previousState = null;
function updateState() {
var currentState = app.getState();
if (currentState !== previousState) {
if (currentState == "Conectado") {
state.innerHTML = "<span style='color: green;'>"+ currentState +"</span>";
startCheckuser();
startOrStopButton.innerText = "Parar VPN"
} else if (currentState == "Iniciando" || currentState == "Autenticando" || currentState == "Conectando") {
state.innerHTML = "<span style='color: orange;'>" + currentState + "</span>";
startOrStopButton.innerText = "Parar VPN"
} else if (currentState == "Reconectando" || currentState == "Desconectado") {
state.innerHTML = "<span style='color: red;'>" + currentState + "</span>";
} else {
state.innerHTML = "<span style='color: orange;'>" + currentState + "</span>";
startOrStopButton.innerText = "Iniciar VPN"
}
previousState = currentState;
}
}
setInterval(function() {
updateState();
checkAndLoadLogs();
}, 0);
logoImg.src = app.getLogoUrl();
document.body.style.backgroundImage = `url('${app.getBackUrl()}')`;
document.body.style.backgroundSize = 'cover';
document.body.style.backgroundRepeat = 'no-repeat';
document.body.style.backgroundPosition = 'center';
document.addEventListener("DOMContentLoaded", function () {
// Verificar se há usuário e senha salvos no localStorage
const usuarioSalvo = localStorage.getItem('usuario');
const senhaSalva = localStorage.getItem('senha');
const configSalva = localStorage.getItem('configSelecionada');
if (configSalva) {
const configSelecionada = JSON.parse(configSalva);
// Atualize a interface do usuário com a configuração salva
configModalButton.value = configSelecionada.ConfigName;
// Você pode fazer outras ações relacionadas à configuração aqui, se necessário
}
if (usuarioSalvo && senhaSalva) {
// Preencher os campos de usuário e senha com os valores salvos
user.value = usuarioSalvo;
pass.value = senhaSalva;
}
});
</script>
</body>
</html>