Merge pull request #63 from itdoginfo/chore/fakeip-method

feat: update DNS checks and improve FakeIP status reporting
This commit is contained in:
itdoginfo
2025-03-12 17:02:18 +03:00
committed by GitHub
2 changed files with 28 additions and 43 deletions

View File

@@ -769,9 +769,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;
@@ -1015,12 +1012,12 @@ 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);
@@ -1092,30 +1089,12 @@ 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)';
}
};

View File

@@ -19,7 +19,7 @@ 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"
log() {
local message="$1"
@@ -511,12 +511,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 +626,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"
@@ -1717,28 +1721,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 +1947,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"