mirror of
https://github.com/Ground-Zerro/DomainMapper.git
synced 2025-12-10 01:47:18 +07:00
234 lines
10 KiB
HTML
234 lines
10 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>DNS Resolver Settings</title>
|
||
<script>
|
||
function validateForm(event) {
|
||
const services = document.querySelectorAll('input[name="services"]:checked');
|
||
const dnsServers = document.querySelectorAll('input[name="dns_servers"]:checked');
|
||
const format = document.querySelector('input[name="format"]:checked');
|
||
|
||
if (services.length === 0) {
|
||
alert("Выберите хотя бы один сервис.");
|
||
event.preventDefault();
|
||
return false;
|
||
}
|
||
|
||
if (dnsServers.length === 0) {
|
||
alert("Выберите хотя бы один DNS сервер.");
|
||
event.preventDefault();
|
||
return false;
|
||
}
|
||
|
||
if (!format) {
|
||
alert("Выберите формат сохранения.");
|
||
event.preventDefault();
|
||
return false;
|
||
}
|
||
|
||
if ((format.value === 'unix' || format.value === 'win' || format.value === 'keenetic') &&
|
||
!document.getElementById('gateway').value) {
|
||
alert("Укажите IP шлюза.");
|
||
event.preventDefault();
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
function generateConfig(event) {
|
||
event.preventDefault();
|
||
|
||
if (!validateForm(event)) {
|
||
return;
|
||
}
|
||
|
||
const services = Array.from(document.querySelectorAll('input[name="services"]:checked')).map(el => el.value).join(',');
|
||
const dnsServers = Array.from(document.querySelectorAll('input[name="dns_servers"]:checked')).map(el => el.value).join(' ');
|
||
const format = document.querySelector('input[name="format"]:checked').value;
|
||
const gateway = document.getElementById('gateway')?.value || '';
|
||
const commentary = document.getElementById('commentary')?.value || '';
|
||
const cloudflare = document.querySelector('input[name="cloudflare"]:checked') ? 'yes' : 'no';
|
||
const aggregation = document.querySelector('input[name="aggregation"]:checked').value;
|
||
|
||
const userId = Math.floor(Math.random() * 100000); // Случайный ID пользователя
|
||
const filename = `out-id_${userId}.txt`;
|
||
|
||
const config = `
|
||
[DomainMapper]
|
||
localplatform = no
|
||
localdns = no
|
||
service = ${services}
|
||
dnsserver = ${dnsServers}
|
||
cloudflare = ${cloudflare}
|
||
subnet = ${aggregation}
|
||
filename = ${filename}
|
||
filetype = ${format}
|
||
gateway = ${gateway}
|
||
keenetic = ${gateway}
|
||
listname = ${commentary}
|
||
mk_comment = off
|
||
cfginfo = no
|
||
run =
|
||
`;
|
||
|
||
sendConfigToServer(config, userId);
|
||
}
|
||
|
||
function sendConfigToServer(config, userId) {
|
||
fetch('/run', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json'
|
||
},
|
||
body: JSON.stringify({ config: config, userId: userId })
|
||
})
|
||
.then(response => response.text())
|
||
.then(data => {
|
||
document.getElementById('progress').innerText = `Конфигурация создана и скрипт запущен. Результат: ${data}`;
|
||
})
|
||
.catch(error => {
|
||
console.error('Ошибка при отправке конфигурации:', error);
|
||
document.getElementById('progress').innerText = 'Ошибка при выполнении.';
|
||
});
|
||
}
|
||
|
||
function loadServices() {
|
||
const serviceUrl = 'https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/refs/heads/main/platformdb';
|
||
|
||
fetch(serviceUrl)
|
||
.then(response => response.text())
|
||
.then(data => {
|
||
const lines = data.split('\n');
|
||
const servicesContainer = document.getElementById('servicesContainer');
|
||
|
||
lines.forEach(line => {
|
||
const parts = line.split(':');
|
||
if (parts.length > 1) {
|
||
const serviceName = parts[0].trim();
|
||
const label = document.createElement('label');
|
||
const input = document.createElement('input');
|
||
input.type = 'checkbox';
|
||
input.name = 'services';
|
||
input.value = serviceName;
|
||
label.appendChild(input);
|
||
label.appendChild(document.createTextNode(` ${serviceName}`));
|
||
servicesContainer.appendChild(label);
|
||
servicesContainer.appendChild(document.createElement('br'));
|
||
}
|
||
});
|
||
})
|
||
.catch(error => console.error('Error loading services:', error));
|
||
}
|
||
|
||
function loadDNSServers() {
|
||
const dnsUrl = 'https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/refs/heads/main/dnsdb';
|
||
|
||
fetch(dnsUrl)
|
||
.then(response => response.text())
|
||
.then(data => {
|
||
const lines = data.split('\n');
|
||
const dnsServersContainer = document.getElementById('dnsServersContainer');
|
||
|
||
lines.forEach(line => {
|
||
const parts = line.split(':');
|
||
if (parts.length > 1) {
|
||
const dnsServerName = parts[0].trim();
|
||
const label = document.createElement('label');
|
||
const input = document.createElement('input');
|
||
input.type = 'checkbox';
|
||
input.name = 'dns_servers';
|
||
input.value = dnsServerName;
|
||
label.appendChild(input);
|
||
label.appendChild(document.createTextNode(` ${dnsServerName}`));
|
||
dnsServersContainer.appendChild(label);
|
||
dnsServersContainer.appendChild(document.createElement('br'));
|
||
}
|
||
});
|
||
})
|
||
.catch(error => console.error('Error loading DNS servers:', error));
|
||
}
|
||
|
||
function toggleGatewayField() {
|
||
const format = document.querySelector('input[name="format"]:checked');
|
||
const gatewayField = document.getElementById('gatewayField');
|
||
if (format && (format.value === 'unix' || format.value === 'win' || format.value === 'keenetic')) {
|
||
gatewayField.style.display = 'block';
|
||
} else {
|
||
gatewayField.style.display = 'none';
|
||
}
|
||
}
|
||
|
||
function toggleCommentField() {
|
||
const format = document.querySelector('input[name="format"]:checked');
|
||
const commentField = document.getElementById('commentaryField');
|
||
if (format && (format.value === 'mikrotik' || format.value === 'keenetic')) {
|
||
commentField.style.display = 'block';
|
||
} else {
|
||
commentField.style.display = 'none';
|
||
}
|
||
}
|
||
|
||
window.onload = function() {
|
||
loadServices();
|
||
loadDNSServers();
|
||
|
||
toggleGatewayField();
|
||
toggleCommentField();
|
||
};
|
||
|
||
document.addEventListener('change', function(event) {
|
||
if (event.target.name === 'format') {
|
||
toggleGatewayField();
|
||
toggleCommentField();
|
||
}
|
||
});
|
||
</script>
|
||
</head>
|
||
<body>
|
||
<h2>Настройки</h2>
|
||
<form id="dnsForm" onsubmit="generateConfig(event)">
|
||
<label><strong>Список сервисов:</strong></label><br>
|
||
<div id="servicesContainer"></div><br>
|
||
|
||
<label><strong>Список используемых DNS серверов:</strong></label><br>
|
||
<div id="dnsServersContainer"></div><br>
|
||
|
||
<label><strong>Фильтрация Cloudflare:</strong></label><br>
|
||
<input type="checkbox" name="cloudflare" value="yes"> Исключить Cloudflare<br><br>
|
||
|
||
<label><strong>Агрегация подсетей:</strong></label><br>
|
||
<input type="radio" name="aggregation" value="16"> До /16 (255.255.0.0)<br>
|
||
<input type="radio" name="aggregation" value="24"> До /24 (255.255.255.0)<br>
|
||
<input type="radio" name="aggregation" value="mix"> Микс /24 и /32<br>
|
||
<input type="radio" name="aggregation" value="none" checked> Не агрегировать<br><br>
|
||
|
||
<label><strong>Формат сохранения:</strong></label><br>
|
||
<input type="radio" name="format" value="ip"> IP (только IP адреса)<br>
|
||
<input type="radio" name="format" value="cidr"> CIDR (%IP%/32)<br>
|
||
<input type="radio" name="format" value="win"> Windows Route (route add %IP% mask 255.255.255.255 %gateway%)<br>
|
||
<input type="radio" name="format" value="unix"> Unix Route (ip route %IP%/32 %gateway%)<br>
|
||
<input type="radio" name="format" value="wg"> Wireguard/AmneziaWG (%IP%/32, %IP%/32, и т.д...)<br>
|
||
<input type="radio" name="format" value="openvpn"> Open VPN (push "route %IP% 255.255.255.255")<br>
|
||
<input type="radio" name="format" value="keenetic"> Keenetic CLI (ip route %IP%/32 %gateway% auto !%commentary%)<br>
|
||
<input type="radio" name="format" value="mikrotik"> Mikrotik firewall (/ip/firewall/address-list add list=%commentary% address=%IP%/32)<br><br>
|
||
|
||
<div id="gatewayField" style="display:none;">
|
||
<label><strong>Укажите IP шлюза или имя интерфейса:</strong></label><br>
|
||
<input type="text" id="gateway" name="gateway" placeholder="IP или имя шлюза"><br><br>
|
||
</div>
|
||
|
||
<div id="commentaryField" style="display:none;">
|
||
<label><strong>Укажите комментарий для списка:</strong></label><br>
|
||
<input type="text" id="commentary" name="commentary" placeholder="Комментарий для списка"><br><br>
|
||
</div>
|
||
|
||
<button type="submit">Создать конфигурацию</button>
|
||
</form>
|
||
|
||
<div id="progress"></div>
|
||
</body>
|
||
</html>
|