mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +03:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98797d93b1 | ||
|
|
66c6e998a2 | ||
|
|
3d9f82b571 | ||
|
|
38d082e236 | ||
|
|
9f5abcae6d | ||
|
|
7836d2c6ec | ||
|
|
f46c934c59 | ||
|
|
23ed10d393 | ||
|
|
26488baad3 | ||
|
|
c79016e456 | ||
|
|
884bbfee42 | ||
|
|
1263b9b1b8 | ||
|
|
23203fd7a1 | ||
|
|
25c887a952 | ||
|
|
e7a3c7adf1 | ||
|
|
3e96b9a1af |
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -11,6 +11,22 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.1
|
||||
|
||||
- name: Check version match
|
||||
run: |
|
||||
PODKOP_VERSION=$(grep '^PKG_VERSION:=' podkop/Makefile | cut -d '=' -f 2)
|
||||
LUCI_APP_PODKOP_VERSION=$(grep '^PKG_VERSION:=' luci-app-podkop/Makefile | cut -d '=' -f 2)
|
||||
|
||||
TAG_VERSION=${GITHUB_REF#refs/tags/v}
|
||||
|
||||
echo "Podkop version: $PODKOP_VERSION"
|
||||
echo "Luci-app-podkop version: $LUCI_APP_PODKOP_VERSION"
|
||||
echo "Tag version: $TAG_VERSION"
|
||||
|
||||
if [ "$PODKOP_VERSION" != "$TAG_VERSION" ] || [ "$LUCI_APP_PODKOP_VERSION" != "$TAG_VERSION" ]; then
|
||||
echo "Error: Version mismatch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6.9.0
|
||||
with:
|
||||
|
||||
@@ -80,12 +80,13 @@ Luci: Services/podkop
|
||||
# ToDo
|
||||
Этот раздел не означает задачи, которые нужно брать и делать. Это общий список хотелок. Если вы хотите помочь, пожалуйста, спросите сначала в телеграмме.
|
||||
|
||||
- [ ] Проверка, что версия в makefile совпадает с тегом
|
||||
- [x] Проверка, что версия в makefile совпадает с тегом
|
||||
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
|
||||
- [x] Обработка ошибки `sing-box[9345]: FATAL[0000] start service: initialize DNS rule[2]: rule-set not found: main`. Когда не задана строка\интерфейс
|
||||
- [x] Проверка `/etc/resolv.conf` на наличие DNS-серверов
|
||||
- [x] Отслеживание интерфейса wan в sing-box
|
||||
- [ ] Рестарт сервиса без рестарта dnsmasq
|
||||
- [ ] `ash: can't kill pid 9848: No such process` при обновлении
|
||||
|
||||
Низкий приоритет
|
||||
- [ ] Галочка, которая режет доступ к doh серверам
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-podkop
|
||||
PKG_VERSION:=0.3.26
|
||||
PKG_VERSION:=0.3.29
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI podkop app
|
||||
|
||||
@@ -41,18 +41,15 @@ function formatDiagnosticOutput(output) {
|
||||
.replace(/\r/g, '\n');
|
||||
}
|
||||
|
||||
function getNetworkInterfaces(o, section_id) {
|
||||
const excludeInterfaces = ['br-lan', 'eth0', 'eth1', 'wan', 'phy0-ap0', 'phy1-ap0', 'pppoe-wan'];
|
||||
|
||||
function getNetworkInterfaces(o, section_id, excludeInterfaces = []) {
|
||||
return network.getDevices().then(devices => {
|
||||
// Reset the options by creating a new keylist
|
||||
o.keylist = [];
|
||||
o.vallist = [];
|
||||
|
||||
devices.forEach(device => {
|
||||
if (device.dev && device.dev.name) {
|
||||
const deviceName = device.dev.name;
|
||||
if (!excludeInterfaces.includes(deviceName) && !/^lan\d+$/.test(deviceName)) {
|
||||
if (!excludeInterfaces.includes(deviceName)) {
|
||||
o.value(deviceName, deviceName);
|
||||
}
|
||||
}
|
||||
@@ -243,11 +240,17 @@ function createConfigSection(section, map, network) {
|
||||
}
|
||||
};
|
||||
|
||||
o = s.taboption('basic', form.Flag, 'ss_uot', _('Shadowsocks UDP over TCP'), _('Apply for SS2022'));
|
||||
o.default = '0';
|
||||
o.depends('mode', 'proxy');
|
||||
o.rmempty = false;
|
||||
o.ucisection = 'main';
|
||||
|
||||
o = s.taboption('basic', form.ListValue, 'interface', _('Network Interface'), _('Select network interface for VPN connection'));
|
||||
o.depends('mode', 'vpn');
|
||||
o.ucisection = s.section;
|
||||
o.load = function (section_id) {
|
||||
return getNetworkInterfaces(this, section_id).then(() => {
|
||||
return getNetworkInterfaces(this, section_id, ['br-lan', 'eth0', 'eth1', 'wan', 'phy0-ap0', 'phy1-ap0', 'pppoe-wan']).then(() => {
|
||||
return this.super('load', section_id);
|
||||
});
|
||||
};
|
||||
@@ -614,6 +617,16 @@ const ButtonFactory = {
|
||||
});
|
||||
},
|
||||
|
||||
createInitActionButton: function (config) {
|
||||
return this.createButton({
|
||||
label: config.label,
|
||||
additionalClass: `cbi-button-${config.type || ''}`,
|
||||
onClick: () => safeExec('/etc/init.d/podkop', [config.action])
|
||||
.then(() => config.reload && location.reload()),
|
||||
style: config.style
|
||||
});
|
||||
},
|
||||
|
||||
createModalButton: function (config) {
|
||||
return this.createButton({
|
||||
label: config.label,
|
||||
@@ -656,26 +669,19 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s
|
||||
E('div', { 'class': 'table', style: 'display: flex; gap: 20px;' }, [
|
||||
// Podkop Status Panel
|
||||
createStatusPanel('Podkop Status', podkopStatus, [
|
||||
podkopStatus.running ?
|
||||
ButtonFactory.createActionButton({
|
||||
label: 'Stop Podkop',
|
||||
type: 'remove',
|
||||
action: 'stop',
|
||||
reload: true
|
||||
}) :
|
||||
ButtonFactory.createActionButton({
|
||||
label: 'Start Podkop',
|
||||
type: 'apply',
|
||||
action: 'start',
|
||||
reload: true
|
||||
}),
|
||||
ButtonFactory.createActionButton({
|
||||
label: podkopStatus.running ? 'Stop Podkop' : 'Start Podkop',
|
||||
type: podkopStatus.running ? 'remove' : 'apply',
|
||||
action: podkopStatus.running ? 'stop' : 'start',
|
||||
reload: true
|
||||
}),
|
||||
ButtonFactory.createActionButton({
|
||||
label: 'Restart Podkop',
|
||||
type: 'apply',
|
||||
action: 'restart',
|
||||
reload: true
|
||||
}),
|
||||
ButtonFactory.createActionButton({
|
||||
ButtonFactory.createInitActionButton({
|
||||
label: podkopStatus.enabled ? 'Disable Podkop' : 'Enable Podkop',
|
||||
type: podkopStatus.enabled ? 'remove' : 'apply',
|
||||
action: podkopStatus.enabled ? 'disable' : 'enable',
|
||||
@@ -769,9 +775,6 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s
|
||||
return view.extend({
|
||||
async render() {
|
||||
document.head.insertAdjacentHTML('beforeend', `
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<style>
|
||||
.cbi-value {
|
||||
margin-bottom: 10px !important;
|
||||
@@ -917,6 +920,15 @@ return view.extend({
|
||||
return true;
|
||||
};
|
||||
|
||||
o = mainSection.taboption('additional', form.MultiValue, 'iface', _('Source Network Interface'), _('Select the network interface from which the traffic will originate'));
|
||||
o.ucisection = 'main';
|
||||
o.default = 'br-lan';
|
||||
o.load = function (section_id) {
|
||||
return getNetworkInterfaces(this, section_id, ['wan', 'phy0-ap0', 'phy1-ap0', 'pppoe-wan']).then(() => {
|
||||
return this.super('load', section_id);
|
||||
});
|
||||
};
|
||||
|
||||
// Extra IPs and exclusions (main section)
|
||||
o = mainSection.taboption('basic', form.Flag, 'exclude_from_ip_enabled', _('IP for exclusion'), _('Specify local IP addresses that will never use the configured route'));
|
||||
o.default = '0';
|
||||
@@ -950,7 +962,39 @@ return view.extend({
|
||||
|
||||
o = mainSection.taboption('diagnostics', form.DummyValue, '_status');
|
||||
o.rawhtml = true;
|
||||
o.cfgvalue = () => E('div', { id: 'diagnostics-status' }, _('Loading diagnostics...'));
|
||||
o.cfgvalue = () => E('div', {
|
||||
id: 'diagnostics-status',
|
||||
'style': 'cursor: pointer;'
|
||||
}, _('Click to load diagnostics...'));
|
||||
|
||||
let diagnosticsUpdateTimer = null;
|
||||
|
||||
function startDiagnosticsUpdates() {
|
||||
if (diagnosticsUpdateTimer) {
|
||||
clearInterval(diagnosticsUpdateTimer);
|
||||
}
|
||||
|
||||
const container = document.getElementById('diagnostics-status');
|
||||
if (container) {
|
||||
container.innerHTML = _('Loading diagnostics...');
|
||||
}
|
||||
|
||||
updateDiagnostics();
|
||||
diagnosticsUpdateTimer = setInterval(updateDiagnostics, 10000);
|
||||
}
|
||||
|
||||
function stopDiagnosticsUpdates() {
|
||||
if (diagnosticsUpdateTimer) {
|
||||
clearInterval(diagnosticsUpdateTimer);
|
||||
diagnosticsUpdateTimer = null;
|
||||
}
|
||||
|
||||
// Reset the loading state when stopping updates
|
||||
const container = document.getElementById('diagnostics-status');
|
||||
if (container) {
|
||||
container.removeAttribute('data-loading');
|
||||
}
|
||||
}
|
||||
|
||||
function checkFakeIP() {
|
||||
const createStatus = (state, message, color) => ({
|
||||
@@ -990,7 +1034,6 @@ return view.extend({
|
||||
return resolve(createStatus('error', message, 'WARNING'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in checkFakeIP:', error);
|
||||
return resolve(createStatus('error', 'check error', 'WARNING'));
|
||||
}
|
||||
});
|
||||
@@ -1015,15 +1058,14 @@ return view.extend({
|
||||
return resolve(createStatus('not_working', 'DNS not configured', 'ERROR'));
|
||||
}
|
||||
|
||||
const fakeipResult = await safeExec('/usr/bin/podkop', ['check_fakeip']);
|
||||
const result = await safeExec('nslookup', ['-timeout=2', 'fakeip.tech-domain.club', '127.0.0.42']);
|
||||
|
||||
if (fakeipResult.stdout && fakeipResult.stdout.includes('198.18')) {
|
||||
return resolve(createStatus('working', 'FakeIP working (CLI)', 'SUCCESS'));
|
||||
if (result.stdout && result.stdout.includes('198.18')) {
|
||||
return resolve(createStatus('working', 'working on router', 'SUCCESS'));
|
||||
} else {
|
||||
return resolve(createStatus('not_working', 'FakeIP not working (CLI)', 'ERROR'));
|
||||
return resolve(createStatus('not_working', 'not working on router', 'ERROR'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in checkFakeIPCLI:', error);
|
||||
return resolve(createStatus('error', 'CLI check error', 'WARNING'));
|
||||
}
|
||||
});
|
||||
@@ -1077,7 +1119,6 @@ return view.extend({
|
||||
]).outerHTML;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error updating diagnostics:', e);
|
||||
const container = document.getElementById('diagnostics-status');
|
||||
if (container) {
|
||||
container.innerHTML = E('div', { 'class': 'alert-message warning' }, [
|
||||
@@ -1089,62 +1130,6 @@ return view.extend({
|
||||
}
|
||||
}
|
||||
|
||||
function startPeriodicUpdates(titleDiv) {
|
||||
let updateTimer = null;
|
||||
let isVisible = !document.hidden;
|
||||
let versionText = _('Podkop');
|
||||
let versionReceived = false;
|
||||
|
||||
const updateStatus = async () => {
|
||||
try {
|
||||
if (!versionReceived) {
|
||||
const version = await safeExec('/usr/bin/podkop', ['show_version'], 2000);
|
||||
if (version.stdout) {
|
||||
versionText = _('Podkop') + ' v' + version.stdout.trim();
|
||||
versionReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
const singboxStatusResult = await safeExec('/usr/bin/podkop', ['get_sing_box_status']);
|
||||
const singboxStatus = JSON.parse(singboxStatusResult.stdout || '{"running":0,"dns_configured":0}');
|
||||
const fakeipStatus = await checkFakeIP();
|
||||
const fakeipCLIStatus = await checkFakeIPCLI();
|
||||
|
||||
titleDiv.textContent = versionText + (!singboxStatus.running || !singboxStatus.dns_configured === 'not_working' ? ' (not working)' : '');
|
||||
|
||||
await updateDiagnostics();
|
||||
} catch (error) {
|
||||
console.warn('Failed to update status:', error);
|
||||
titleDiv.textContent = versionText + ' (not working)';
|
||||
}
|
||||
};
|
||||
|
||||
const toggleUpdates = (visible) => {
|
||||
if (visible) {
|
||||
updateStatus();
|
||||
if (!updateTimer) {
|
||||
updateTimer = setInterval(updateStatus, 10000);
|
||||
}
|
||||
} else if (updateTimer) {
|
||||
clearInterval(updateTimer);
|
||||
updateTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
isVisible = !document.hidden;
|
||||
toggleUpdates(isVisible);
|
||||
});
|
||||
|
||||
toggleUpdates(isVisible);
|
||||
|
||||
window.addEventListener('unload', () => {
|
||||
if (updateTimer) {
|
||||
clearInterval(updateTimer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Extra Section
|
||||
const extraSection = m.section(form.TypedSection, 'extra', _('Extra configurations'));
|
||||
extraSection.anonymous = false;
|
||||
@@ -1157,8 +1142,47 @@ return view.extend({
|
||||
const titleDiv = E('h2', { 'class': 'cbi-map-title' }, _('Podkop'));
|
||||
node.insertBefore(titleDiv, node.firstChild);
|
||||
|
||||
setTimeout(() => {
|
||||
const diagnosticsContainer = document.getElementById('diagnostics-status');
|
||||
if (diagnosticsContainer) {
|
||||
diagnosticsContainer.addEventListener('click', function () {
|
||||
if (!this.hasAttribute('data-loading')) {
|
||||
this.setAttribute('data-loading', 'true');
|
||||
startDiagnosticsUpdates();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const tabs = node.querySelectorAll('.cbi-tabmenu');
|
||||
if (tabs.length > 0) {
|
||||
tabs[0].addEventListener('click', function (e) {
|
||||
const tab = e.target.closest('.cbi-tab');
|
||||
if (tab) {
|
||||
const tabName = tab.getAttribute('data-tab');
|
||||
if (tabName === 'diagnostics') {
|
||||
const container = document.getElementById('diagnostics-status');
|
||||
if (container && !container.hasAttribute('data-loading')) {
|
||||
container.setAttribute('data-loading', 'true');
|
||||
startDiagnosticsUpdates();
|
||||
}
|
||||
} else {
|
||||
stopDiagnosticsUpdates();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const activeTab = tabs[0].querySelector('.cbi-tab[data-tab="diagnostics"]');
|
||||
if (activeTab) {
|
||||
const container = document.getElementById('diagnostics-status');
|
||||
if (container && !container.hasAttribute('data-loading')) {
|
||||
container.setAttribute('data-loading', 'true');
|
||||
startDiagnosticsUpdates();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
||||
node.classList.add('fade-in');
|
||||
startPeriodicUpdates(titleDiv);
|
||||
return node;
|
||||
});
|
||||
|
||||
|
||||
@@ -746,4 +746,7 @@ msgid "not works in browser"
|
||||
msgstr "не работает в браузере"
|
||||
|
||||
msgid "not works on router"
|
||||
msgstr "не работает на роутере"
|
||||
msgstr "не работает на роутере"
|
||||
|
||||
msgid "Diagnostics"
|
||||
msgstr "Диагностика"
|
||||
@@ -1100,4 +1100,7 @@ msgid "not works in browser"
|
||||
msgstr ""
|
||||
|
||||
msgid "not works on router"
|
||||
msgstr ""
|
||||
|
||||
msgid "Diagnostics"
|
||||
msgstr ""
|
||||
@@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=podkop
|
||||
PKG_VERSION:=0.3.26
|
||||
PKG_VERSION:=0.3.29
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=ITDog <podkop@itdog.info>
|
||||
|
||||
@@ -34,4 +34,6 @@ config main 'main'
|
||||
option dns_type 'doh'
|
||||
option dns_server '8.8.8.8'
|
||||
option dns_rewrite_ttl '60'
|
||||
option cache_file '/tmp/cache.db'
|
||||
option cache_file '/tmp/cache.db'
|
||||
list iface 'br-lan'
|
||||
option ss_uot '0'
|
||||
@@ -19,7 +19,9 @@ SING_BOX_CONFIG="/etc/sing-box/config.json"
|
||||
FAKEIP="198.18.0.0/15"
|
||||
VALID_SERVICES="russia_inside russia_outside ukraine_inside geoblock block porn news anime youtube discord meta twitter hdrezka tiktok telegram"
|
||||
DNS_RESOLVERS="1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 9.9.9.9 9.9.9.11 94.140.14.14 94.140.15.15 208.67.220.220 208.67.222.222 77.88.8.1 77.88.8.8"
|
||||
TEST_DOMAIN="google.com"
|
||||
TEST_DOMAIN="fakeip.tech-domain.club"
|
||||
INTERFACES_LIST=""
|
||||
SRC_INTERFACE=""
|
||||
|
||||
log() {
|
||||
local message="$1"
|
||||
@@ -50,7 +52,7 @@ start() {
|
||||
sleep 3
|
||||
|
||||
mkdir -p /tmp/podkop
|
||||
|
||||
|
||||
# base
|
||||
route_table_rule_mark
|
||||
create_nft_table
|
||||
@@ -261,20 +263,51 @@ route_table_rule_mark() {
|
||||
fi
|
||||
}
|
||||
|
||||
process_interfaces() {
|
||||
local interface="$1"
|
||||
INTERFACES_LIST="$INTERFACES_LIST $interface"
|
||||
}
|
||||
|
||||
nft_interfaces() {
|
||||
local table=PodkopTable
|
||||
|
||||
config_list_foreach "main" "iface" "process_interfaces"
|
||||
|
||||
if [ $(echo "$INTERFACES_LIST" | wc -w) -eq 1 ]; then
|
||||
SRC_INTERFACE=$INTERFACES_LIST
|
||||
else
|
||||
local set_name="interfaces"
|
||||
if ! nft list set inet $table $set_name &>/dev/null; then
|
||||
nft add set inet $table $set_name { type ifname\; flags interval\; }
|
||||
fi
|
||||
|
||||
for interface in $INTERFACES_LIST; do
|
||||
if ! nft list element inet $table $set_name { $interface } &>/dev/null; then
|
||||
nft add element inet $table $set_name { $interface }
|
||||
fi
|
||||
done
|
||||
|
||||
SRC_INTERFACE=@$set_name
|
||||
fi
|
||||
}
|
||||
|
||||
create_nft_table() {
|
||||
local table="PodkopTable"
|
||||
|
||||
nft add table inet $table
|
||||
|
||||
nft_interfaces
|
||||
|
||||
log "Create nft rules"
|
||||
nft add chain inet $table mangle { type filter hook prerouting priority -150 \; policy accept \;}
|
||||
nft add chain inet $table proxy { type filter hook prerouting priority -100 \; policy accept \;}
|
||||
|
||||
nft add set inet $table podkop_subnets { type ipv4_addr\; flags interval\; auto-merge\; }
|
||||
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr @podkop_subnets meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr @podkop_subnets meta l4proto udp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr "$FAKEIP" meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr "$FAKEIP" meta l4proto udp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr @podkop_subnets meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr @podkop_subnets meta l4proto udp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr "$FAKEIP" meta l4proto tcp meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr "$FAKEIP" meta l4proto udp meta mark set 0x105 counter
|
||||
|
||||
nft add rule inet $table proxy meta mark 0x105 meta l4proto tcp tproxy ip to :1602 counter
|
||||
nft add rule inet $table proxy meta mark 0x105 meta l4proto udp tproxy ip to :1602 counter
|
||||
@@ -511,12 +544,11 @@ list_update() {
|
||||
find_working_resolver() {
|
||||
local resolver_found=""
|
||||
for resolver in $DNS_RESOLVERS; do
|
||||
if nslookup $TEST_DOMAIN $resolver >/dev/null 2>&1; then
|
||||
if nslookup -timeout=2 $TEST_DOMAIN $resolver >/dev/null 2>&1; then
|
||||
echo "$resolver"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "8.8.8.8"
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -627,7 +659,12 @@ sing_box_dns() {
|
||||
if [ "$is_ip" = "0" ]; then
|
||||
log "Finding working DNS resolver"
|
||||
local dns_resolver=$(find_working_resolver)
|
||||
log "Found working resolver: $dns_resolver"
|
||||
if [ -z "$dns_resolver" ]; then
|
||||
log "No working resolver found, using default DNS server"
|
||||
dns_resolver="1.1.1.1"
|
||||
else
|
||||
log "Found working resolver: $dns_resolver"
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Configure DNS in sing-box"
|
||||
@@ -796,7 +833,8 @@ sing_box_outdound() {
|
||||
fi
|
||||
|
||||
if [[ "$active_proxy_string" =~ ^ss:// ]]; then
|
||||
sing_box_config_shadowsocks "$section" "$active_proxy_string"
|
||||
config_get ss_uot $section "ss_uot"
|
||||
sing_box_config_shadowsocks "$section" "$active_proxy_string" "$ss_uot"
|
||||
elif [[ "$active_proxy_string" =~ ^vless:// ]]; then
|
||||
sing_box_config_vless "$section" "$active_proxy_string"
|
||||
else
|
||||
@@ -903,6 +941,7 @@ sing_box_config_outbound_json() {
|
||||
sing_box_config_shadowsocks() {
|
||||
local section="$1"
|
||||
local STRING="$2"
|
||||
local ss_uot="$3"
|
||||
|
||||
if echo "$STRING" | cut -d'/' -f3 | cut -d'@' -f1 | base64 -d 2>/dev/null | grep -q ":"; then
|
||||
local encrypted_part=$(echo "$STRING" | cut -d'/' -f3 | cut -d'@' -f1 | base64 -d 2>/dev/null )
|
||||
@@ -926,6 +965,7 @@ sing_box_config_shadowsocks() {
|
||||
--argjson port "$port" \
|
||||
--arg method "$method" \
|
||||
--arg password "$password" \
|
||||
--argjson ss_uot "$ss_uot" \
|
||||
'. |
|
||||
.outbounds |= (
|
||||
map(
|
||||
@@ -935,9 +975,8 @@ sing_box_config_shadowsocks() {
|
||||
"server": $server,
|
||||
"server_port": ($port | tonumber),
|
||||
"method": $method,
|
||||
"password": $password,
|
||||
"udp_over_tcp": { "enabled": true, "version": 2 }
|
||||
}
|
||||
"password": $password
|
||||
} + (if $ss_uot == 1 then { "udp_over_tcp": { "enabled": true, "version": 2 } } else {} end)
|
||||
else . end
|
||||
) +
|
||||
(
|
||||
@@ -948,9 +987,8 @@ sing_box_config_shadowsocks() {
|
||||
"server": $server,
|
||||
"server_port": ($port | tonumber),
|
||||
"method": $method,
|
||||
"password": $password,
|
||||
"udp_over_tcp": { "enabled": true, "version": 2 }
|
||||
}]
|
||||
"password": $password
|
||||
} + (if $ss_uot == 1 then { "udp_over_tcp": { "enabled": true, "version": 2 } } else {} end)]
|
||||
else [] end
|
||||
)
|
||||
)' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
||||
@@ -1286,7 +1324,7 @@ list_subnets_download() {
|
||||
"discord")
|
||||
URL=$SUBNETS_DISCORD
|
||||
nft add set inet $table podkop_discord_subnets { type ipv4_addr\; flags interval\; auto-merge\; }
|
||||
nft add rule inet $table mangle iifname "br-lan" ip daddr @podkop_discord_subnets udp dport { 50000-65535 } meta mark set 0x105 counter
|
||||
nft add rule inet $table mangle iifname "$SRC_INTERFACE" ip daddr @podkop_discord_subnets udp dport { 50000-65535 } meta mark set 0x105 counter
|
||||
;;
|
||||
*)
|
||||
return
|
||||
@@ -1526,9 +1564,11 @@ sing_box_rules_source_ip_cidr() {
|
||||
## nftables
|
||||
list_all_traffic_from_ip() {
|
||||
local ip="$1"
|
||||
if ! nft list chain inet PodkopTable mangle | grep -q "ip saddr $ip"; then
|
||||
nft add set inet PodkopTable localv4 { type ipv4_addr\; flags interval\; }
|
||||
nft add element inet PodkopTable localv4 { \
|
||||
local table="PodkopTable"
|
||||
|
||||
if ! nft list chain inet $table mangle | grep -q "ip saddr $ip"; then
|
||||
nft add set inet $table localv4 { type ipv4_addr\; flags interval\; }
|
||||
nft add element inet $table localv4 { \
|
||||
0.0.0.0/8, \
|
||||
10.0.0.0/8, \
|
||||
127.0.0.0/8, \
|
||||
@@ -1542,8 +1582,8 @@ list_all_traffic_from_ip() {
|
||||
203.0.113.0/24, \
|
||||
224.0.0.0/4, \
|
||||
240.0.0.0-255.255.255.255 }
|
||||
nft insert rule inet PodkopTable mangle iifname "br-lan" ip saddr $ip meta l4proto { tcp, udp } meta mark set 0x105 counter
|
||||
nft insert rule inet PodkopTable mangle ip saddr $ip ip daddr @localv4 return
|
||||
nft insert rule inet $table mangle iifname "$SRC_INTERFACE" ip saddr $ip meta l4proto { tcp, udp } meta mark set 0x105 counter
|
||||
nft insert rule inet $table mangle ip saddr $ip ip daddr @localv4 return
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1717,28 +1757,30 @@ check_fakeip() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local test_domain="fakeip.tech-domain.club"
|
||||
local test_domain="$TEST_DOMAIN"
|
||||
|
||||
# Additional DNS checks with different servers
|
||||
nolog "Testing DNS resolution with default DNS server"
|
||||
echo "=== Testing with default DNS server ==="
|
||||
nslookup $test_domain
|
||||
nslookup -timeout=2 $test_domain
|
||||
echo ""
|
||||
|
||||
nolog "Testing DNS resolution with Google DNS (8.8.8.8)"
|
||||
echo "=== Testing with Google DNS (8.8.8.8) ==="
|
||||
nslookup $test_domain 8.8.8.8
|
||||
echo ""
|
||||
|
||||
nolog "Testing DNS resolution with Cloudflare DNS (1.1.1.1)"
|
||||
echo "=== Testing with Cloudflare DNS (1.1.1.1) ==="
|
||||
nslookup $test_domain 1.1.1.1
|
||||
echo ""
|
||||
nolog "Finding a working DNS resolver..."
|
||||
local working_resolver=$(find_working_resolver)
|
||||
if [ -z "$working_resolver" ]; then
|
||||
nolog "No working resolver found, skipping resolver check"
|
||||
else
|
||||
nolog "Using resolver: $working_resolver"
|
||||
|
||||
nolog "Testing DNS resolution with working resolver ($working_resolver)"
|
||||
echo "=== Testing with working resolver ($working_resolver) ==="
|
||||
nslookup -timeout=2 $test_domain $working_resolver
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Main FakeIP check
|
||||
nolog "Testing DNS resolution for $test_domain using 127.0.0.42"
|
||||
echo "=== Testing with FakeIP DNS (127.0.0.42) ==="
|
||||
local result=$(nslookup $test_domain 127.0.0.42 2>&1)
|
||||
local result=$(nslookup -timeout=2 $test_domain 127.0.0.42 2>&1)
|
||||
echo "$result"
|
||||
|
||||
if echo "$result" | grep -q "198.18"; then
|
||||
@@ -1941,7 +1983,7 @@ get_status() {
|
||||
}
|
||||
|
||||
sing_box_add_secure_dns_probe_domain() {
|
||||
local domain="fakeip.tech-domain.club"
|
||||
local domain="$TEST_DOMAIN"
|
||||
local override_port=8443
|
||||
|
||||
log "Adding DNS probe domain ${domain} to fakeip-server configuration"
|
||||
|
||||
Reference in New Issue
Block a user