Skip to content

Commit

Permalink
Update guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Jun 23, 2024
1 parent df78c9d commit d7d0bbe
Showing 1 changed file with 70 additions and 68 deletions.
138 changes: 70 additions & 68 deletions roles/frontman/files/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if (hash) {
render(hash);
} else {
window.location.href = '/';
quit();
}
};

Expand All @@ -20,26 +20,31 @@
if (!_hash) {
_hash = window.location.hash.substring(1);
// invalidate location so that users cannot share personal links
window.history.replaceState({}, null, '/#do-not-share-your-personal-link');
window.location.hash = '#do-not-share-your-personal-link';
}
return _hash;
}

function quit () {
window.location.href = '/';
}

function getSsConfig(hash) {
return fetch('/' + hash)
.then(response => response.json());
.then(response => response.json())
.catch(quit);
}

function getSsConfUri(hash) {
return 'ssconf://' + location.host + '/' + hash;
}

function getSsUri(config) {
return 'ss://' + btoa(config.method + ':' + config.password) + '@' + config.server + ':' + config['server_port'];
function getSsUri(server) {
return 'ss://' + btoa(server.method + ':' + server.password) + '@' + server.server + ':' + server['server_port'];
}

function getStraisandUri(conf) {
return 'streisand://import/' + getSsUri(conf);
function getStraisandUri(server) {
return 'streisand://import/' + getSsUri(server);
}

function render(hash) {
Expand All @@ -54,40 +59,57 @@
background-color: white;
padding: 1rem;
`;
document.getElementById('sip008').style = 'display: block';
document.getElementById('sip008_uri').innerHTML = ssConfUri;

getSsConfig(hash)
.then(config => {
document.getElementById('nerd').style = 'display: block';
var ssUri = getSsUri(config);

document.getElementById('ss').style = 'display: block';
document.getElementById('ss_uri').innerHTML = ssUri;
document.getElementById('ss_connect').addEventListener('click', () => {
window.location.href = ssUri;
});

var streisandUri = getStraisandUri(config);
document.getElementById('streisand').style = 'display: block';
document.getElementById('streisand_uri').innerHTML = streisandUri;
document.getElementById('streisand_connect').addEventListener('click', () => {
window.location.href = streisandUri;
});

document.getElementById('manual').style = 'display: block';
document.getElementById('manual_server').innerHTML = config.server;
document.getElementById('manual_port').innerHTML = config['server_port'];
document.getElementById('manual_password').innerHTML = config.password;
document.getElementById('manual_method').innerHTML = config.method;
});
.then(renderStaticConfigurations)
.then(html => document.getElementById('nerd').innerHTML = html);
}

function renderStaticConfigurations (config) {
return `
<h2>Статические конфигурации</h2>
<p>
Конфигурации ниже временные, пока не обновится динамический конфиг. Когда это произойдёт, впн перестанет работать.
В этом случае нужно будет открыть эту страницу и перенастроить клиент с новыми параметрами. Конфиг обновиться может в любой момент.
</p>
${config['servers'].map(renderStaticServerConfig).join('')}
`;
};

const renderStaticServerConfig = function (server) {
const streisandUri = getStraisandUri(server);
const ssUri = getSsUri(server);
return `
<hr/>
<h3>${server['remarks']}</h3>
<div>
<h4><a href="https://apps.apple.com/app/id6450534064">Streisand</a> (iOS & OS X only)</h4>
<div style="text-align: center; margin: 1rem;">
<button onClick="window.location.href = '${streisandUri}'">Подключить</button>
</div>
<code>${streisandUri}</code>
</div>
<div>
<h4>Shadowsocks URI</h4>
<div style="text-align: center; margin: 1rem;">
<button onClick="window.location.href = '${ssUri}'">Подключить</button>
</div>
<code>${ssUri}</code>
</div>
<div>
<h4>Ваще ручная настройка</h4>
<ul>
<li>Server: <code>${server['server']}</code></li>
<li>Port: <code>${server['server_port']}</code></li>
<li>Password: <code>${server['password']}</code></li>
<li>Method: <code>${server['method']}</code></li>
</ul>
</div>
`;
}
</script>
<style>
h1, h2, h3 {
text-align: center;
}

.download_link {
max-width: 100%;
cursor: pointer;
Expand Down Expand Up @@ -128,6 +150,10 @@
font-size: 0.75rem;
}

h1, h2, h3, h4, .text-center {
text-align: center;
}

.connect-vpn {
border: solid 2px red;
border-radius: 1rem;
Expand All @@ -145,7 +171,8 @@
</style>
</head>
<body id="body">
<p style="text-align: center;">Если ты читаешь этот текст, то у тебя есть персональный ВПН.<br/><b>Эта ссылка -- персональная, никому её не скидывай.</b></p>
<p class="text-center">Если ты читаешь этот текст, то у тебя есть персональный ВПН.</p>
<p class="text-center" style="color: blue;"><b>Эта ссылка — персональная, не публикуй её в интернете и не передавай её другим людям.</b></p>

<section>
<h1>Итак, как подключить впн:</h1>
Expand Down Expand Up @@ -238,43 +265,18 @@ <h1>FAQ</h1>

<section>
<h1>Ручная настройка</h1>
<p>Если ты тоже задрот и дочитал до сюда, можешь настроить впн вручную. Для этого выбери способ и используй соответствующие параметры.</p>
<div id="sip008" style="display: none">
<h2>SIP008</h2>
<p>
Если ты тоже задрот и дочитал до сюда, можешь настроить впн вручную. Для этого выбери способ и используй соответствующие параметры. Существует 2 типа конфигураций: динамеческая (SIP008) и статическая.
</p>
<div>
<h2>Динамическая конфигурация (SIP008)</h2>
<p>
Если клиент поддерживает <a href="https://shadowsocks.org/doc/sip008.html">SIP008</a>, используйте следующий URI:
</p>
<code id="sip008_uri"></code>
</div>
<section id="nerd" style="display: none">
<h2>Временные конфигурации</h2>
<p>
Конфигурации ниже временные, пока не обновится динамический конфиг. Когда это произойдёт, впн перестанет работать.
В этом случае нужно будет открыть эту страницу и перенастроить клиент с новыми параметрами.
</p>
<div id="streisand" style="display: none">
<h3><a href="https://apps.apple.com/app/id6450534064">Streisand</a> (iOS & OS X only)</h3>
<div style="text-align: center; margin: 1rem;">
<button id="streisand_connect">Подключить</button>
</div>
<code id="streisand_uri"></code>
</div>
<div id="ss" style="display: none">
<h3>Shadowsocks URI</h3>
<div style="text-align: center; margin: 1rem;">
<button id="ss_connect">Подключить</button>
</div>
<code id="ss_uri"></code>
</div>
<div id="manual" style="display: none">
<h3>Ваще ручная настройка</h3>
<ul>
<li>Server: <code id="manual_server"></code></li>
<li>Port: <code id="manual_port"></code></li>
<li>Password: <code id="manual_password"></code></li>
<li>Method: <code id="manual_method"></code></li>
</ul>
</div>
<section id="nerd">

</section>
</section>
</body>
Expand Down

0 comments on commit d7d0bbe

Please sign in to comment.