Update SingboxDnsService.cs (#8775)
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / rpm (push) Has been cancelled

* Update Utils.cs

* Update SingboxDnsService.cs

* Update package-rhel.sh

* Update package-rhel.sh

* Withdraw
This commit is contained in:
JieXu 2026-02-07 19:31:35 +08:00 committed by GitHub
parent 0f3a3eac02
commit b5800f7dfc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 48 deletions

View file

@ -10,7 +10,7 @@ if [[ -r /etc/os-release ]]; then
;; ;;
*) *)
echo "[ERROR] Unsupported system: $NAME ($ID)." echo "[ERROR] Unsupported system: $NAME ($ID)."
echo "This script only supports Red Hat Enterprise Linux/RockyLinux/AlmaLinux/CentOS or Ubuntu/Debian." echo "This script only supports Red Hat Enterprise Linux/RockyLinux/AlmaLinux/CentOS."
exit 1 exit 1
;; ;;
esac esac
@ -483,20 +483,11 @@ build_for_arch() {
trap '[[ -n "${WORKDIR:-}" ]] && rm -rf "$WORKDIR"' RETURN trap '[[ -n "${WORKDIR:-}" ]] && rm -rf "$WORKDIR"' RETURN
# rpmbuild topdir selection # rpmbuild topdir selection
local TOPDIR SPECDIR SOURCEDIR USE_TOPDIR_DEFINE local TOPDIR SPECDIR SOURCEDIR
if [[ "$ID" =~ ^(rhel|rocky|almalinux|centos)$ ]]; then rpmdev-setuptree
rpmdev-setuptree TOPDIR="${HOME}/rpmbuild"
TOPDIR="${HOME}/rpmbuild" SPECDIR="${TOPDIR}/SPECS"
SPECDIR="${TOPDIR}/SPECS" SOURCEDIR="${TOPDIR}/SOURCES"
SOURCEDIR="${TOPDIR}/SOURCES"
USE_TOPDIR_DEFINE=0
else
TOPDIR="${WORKDIR}/rpmbuild"
SPECDIR="${TOPDIR}/SPECS}"
SOURCEDIR="${TOPDIR}/SOURCES"
mkdir -p "${SPECDIR}" "${SOURCEDIR}" "${TOPDIR}/BUILD" "${TOPDIR}/RPMS" "${TOPDIR}/SRPMS"
USE_TOPDIR_DEFINE=1
fi
# Stage publish content # Stage publish content
mkdir -p "$WORKDIR/$PKGROOT" mkdir -p "$WORKDIR/$PKGROOT"
@ -533,8 +524,6 @@ build_for_arch() {
download_singbox "$WORKDIR/$PKGROOT/bin/sing_box" || echo "[!] sing-box download failed (skipped)" download_singbox "$WORKDIR/$PKGROOT/bin/sing_box" || echo "[!] sing-box download failed (skipped)"
fi fi
download_geo_assets "$WORKDIR/$PKGROOT" || echo "[!] Geo rules download failed (skipped)" download_geo_assets "$WORKDIR/$PKGROOT" || echo "[!] Geo rules download failed (skipped)"
# ---- REQUIRED: always fetch mihomo in netcore mode, per-arch ----
# download_mihomo "$WORKDIR/$PKGROOT" || echo "[!] mihomo download failed (skipped)"
fi fi
# Tarball # Tarball
@ -588,6 +577,12 @@ https://github.com/2dust/v2rayN
install -dm0755 %{buildroot}/opt/v2rayN install -dm0755 %{buildroot}/opt/v2rayN
cp -a * %{buildroot}/opt/v2rayN/ cp -a * %{buildroot}/opt/v2rayN/
install -dm0755 %{buildroot}%{_sysconfdir}/sudoers.d
cat > %{buildroot}%{_sysconfdir}/sudoers.d/v2rayn-mihomo-deny << 'EOF'
ALL ALL=(ALL) !/home/*/.local/share/v2rayN/bin/mihomo/mihomo
EOF
chmod 0440 %{buildroot}%{_sysconfdir}/sudoers.d/v2rayn-mihomo-deny
# Launcher (prefer native ELF first, then DLL fallback) # Launcher (prefer native ELF first, then DLL fallback)
install -dm0755 %{buildroot}%{_bindir} install -dm0755 %{buildroot}%{_bindir}
cat > %{buildroot}%{_bindir}/v2rayn << 'EOF' cat > %{buildroot}%{_bindir}/v2rayn << 'EOF'
@ -641,6 +636,7 @@ fi
/opt/v2rayN /opt/v2rayN
%{_datadir}/applications/v2rayn.desktop %{_datadir}/applications/v2rayn.desktop
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png %{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
%config(noreplace) /etc/sudoers.d/v2rayn-mihomo-deny
SPEC SPEC
# Autostart injection (inside %install) and %files entry # Autostart injection (inside %install) and %files entry
@ -680,35 +676,8 @@ SPEC
sed -i "s/__VERSION__/${VERSION}/g" "$SPECFILE" sed -i "s/__VERSION__/${VERSION}/g" "$SPECFILE"
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$SPECFILE" sed -i "s/__PKGROOT__/${PKGROOT}/g" "$SPECFILE"
# ----- Select proper 'strip' per target arch on Ubuntu only (cross-binutils) -----
# NOTE: We define only __strip to point to the target-arch strip.
# DO NOT override __brp_strip (it must stay the brp script path).
local STRIP_ARGS=()
if [[ "$ID" == "ubuntu" ]]; then
local STRIP_BIN=""
if [[ "$short" == "x64" ]]; then
STRIP_BIN="/usr/bin/x86_64-linux-gnu-strip"
else
STRIP_BIN="/usr/bin/aarch64-linux-gnu-strip"
fi
if [[ -x "$STRIP_BIN" ]]; then
STRIP_ARGS=( --define "__strip $STRIP_BIN" )
fi
fi
# Build RPM for this arch (force rpm --target to match compile arch) # Build RPM for this arch (force rpm --target to match compile arch)
if [[ "$USE_TOPDIR_DEFINE" -eq 1 ]]; then rpmbuild -ba "$SPECFILE" --target "$rpm_target"
rpmbuild -ba "$SPECFILE" --define "_topdir $TOPDIR" --target "$rpm_target" "${STRIP_ARGS[@]}"
else
rpmbuild -ba "$SPECFILE" --target "$rpm_target" "${STRIP_ARGS[@]}"
fi
# Copy temporary rpmbuild to ~/rpmbuild on Debian/Ubuntu path
if [[ "$USE_TOPDIR_DEFINE" -eq 1 ]]; then
mkdir -p "$HOME/rpmbuild"
rsync -a "$TOPDIR"/ "$HOME/rpmbuild"/
TOPDIR="$HOME/rpmbuild"
fi
echo "Build done for $short. RPM at:" echo "Build done for $short. RPM at:"
local f local f

View file

@ -339,13 +339,13 @@ public class Utils
return new(); return new();
} }
var userHostsMap = hostsContent var userHostsMap = hostsContent
.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries) .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.Select(line => line.Trim()) .Select(line => line.Trim())
// skip full-line comments // skip full-line comments
.Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#')) .Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#'))
// ensure line still contains valid parts // ensure line still contains valid parts
.Where(line => !string.IsNullOrWhiteSpace(line) && line.Contains(' ')) .Where(line => !string.IsNullOrWhiteSpace(line) && line.Contains(' '))
.Select(line => line.Split([' ', '\t'], StringSplitOptions.RemoveEmptyEntries)) .Select(line => line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries))
.Where(parts => parts.Length >= 2) .Where(parts => parts.Length >= 2)
.GroupBy(parts => parts[0]) .GroupBy(parts => parts[0])
.ToDictionary( .ToDictionary(

View file

@ -301,7 +301,7 @@ public partial class CoreConfigSingboxService
if (!string.IsNullOrEmpty(simpleDNSItem?.DirectExpectedIPs)) if (!string.IsNullOrEmpty(simpleDNSItem?.DirectExpectedIPs))
{ {
var ipItems = simpleDNSItem.DirectExpectedIPs var ipItems = simpleDNSItem.DirectExpectedIPs
.Split([',', ';'], StringSplitOptions.RemoveEmptyEntries) .Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim()) .Select(s => s.Trim())
.Where(s => !string.IsNullOrEmpty(s)) .Where(s => !string.IsNullOrEmpty(s))
.ToList(); .ToList();