Skip to content

Commit b5800f7

Browse files
authored
Update SingboxDnsService.cs (2dust#8775)
* Update Utils.cs * Update SingboxDnsService.cs * Update package-rhel.sh * Update package-rhel.sh * Withdraw
1 parent 0f3a3ea commit b5800f7

3 files changed

Lines changed: 17 additions & 48 deletions

File tree

package-rhel.sh

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if [[ -r /etc/os-release ]]; then
1010
;;
1111
*)
1212
echo "[ERROR] Unsupported system: $NAME ($ID)."
13-
echo "This script only supports Red Hat Enterprise Linux/RockyLinux/AlmaLinux/CentOS or Ubuntu/Debian."
13+
echo "This script only supports Red Hat Enterprise Linux/RockyLinux/AlmaLinux/CentOS."
1414
exit 1
1515
;;
1616
esac
@@ -483,20 +483,11 @@ build_for_arch() {
483483
trap '[[ -n "${WORKDIR:-}" ]] && rm -rf "$WORKDIR"' RETURN
484484

485485
# rpmbuild topdir selection
486-
local TOPDIR SPECDIR SOURCEDIR USE_TOPDIR_DEFINE
487-
if [[ "$ID" =~ ^(rhel|rocky|almalinux|centos)$ ]]; then
488-
rpmdev-setuptree
489-
TOPDIR="${HOME}/rpmbuild"
490-
SPECDIR="${TOPDIR}/SPECS"
491-
SOURCEDIR="${TOPDIR}/SOURCES"
492-
USE_TOPDIR_DEFINE=0
493-
else
494-
TOPDIR="${WORKDIR}/rpmbuild"
495-
SPECDIR="${TOPDIR}/SPECS}"
496-
SOURCEDIR="${TOPDIR}/SOURCES"
497-
mkdir -p "${SPECDIR}" "${SOURCEDIR}" "${TOPDIR}/BUILD" "${TOPDIR}/RPMS" "${TOPDIR}/SRPMS"
498-
USE_TOPDIR_DEFINE=1
499-
fi
486+
local TOPDIR SPECDIR SOURCEDIR
487+
rpmdev-setuptree
488+
TOPDIR="${HOME}/rpmbuild"
489+
SPECDIR="${TOPDIR}/SPECS"
490+
SOURCEDIR="${TOPDIR}/SOURCES"
500491

501492
# Stage publish content
502493
mkdir -p "$WORKDIR/$PKGROOT"
@@ -533,8 +524,6 @@ build_for_arch() {
533524
download_singbox "$WORKDIR/$PKGROOT/bin/sing_box" || echo "[!] sing-box download failed (skipped)"
534525
fi
535526
download_geo_assets "$WORKDIR/$PKGROOT" || echo "[!] Geo rules download failed (skipped)"
536-
# ---- REQUIRED: always fetch mihomo in netcore mode, per-arch ----
537-
# download_mihomo "$WORKDIR/$PKGROOT" || echo "[!] mihomo download failed (skipped)"
538527
fi
539528

540529
# Tarball
@@ -588,6 +577,12 @@ https://github.com/2dust/v2rayN
588577
install -dm0755 %{buildroot}/opt/v2rayN
589578
cp -a * %{buildroot}/opt/v2rayN/
590579
580+
install -dm0755 %{buildroot}%{_sysconfdir}/sudoers.d
581+
cat > %{buildroot}%{_sysconfdir}/sudoers.d/v2rayn-mihomo-deny << 'EOF'
582+
ALL ALL=(ALL) !/home/*/.local/share/v2rayN/bin/mihomo/mihomo
583+
EOF
584+
chmod 0440 %{buildroot}%{_sysconfdir}/sudoers.d/v2rayn-mihomo-deny
585+
591586
# Launcher (prefer native ELF first, then DLL fallback)
592587
install -dm0755 %{buildroot}%{_bindir}
593588
cat > %{buildroot}%{_bindir}/v2rayn << 'EOF'
@@ -641,6 +636,7 @@ fi
641636
/opt/v2rayN
642637
%{_datadir}/applications/v2rayn.desktop
643638
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
639+
%config(noreplace) /etc/sudoers.d/v2rayn-mihomo-deny
644640
SPEC
645641

646642
# Autostart injection (inside %install) and %files entry
@@ -680,35 +676,8 @@ SPEC
680676
sed -i "s/__VERSION__/${VERSION}/g" "$SPECFILE"
681677
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$SPECFILE"
682678

683-
# ----- Select proper 'strip' per target arch on Ubuntu only (cross-binutils) -----
684-
# NOTE: We define only __strip to point to the target-arch strip.
685-
# DO NOT override __brp_strip (it must stay the brp script path).
686-
local STRIP_ARGS=()
687-
if [[ "$ID" == "ubuntu" ]]; then
688-
local STRIP_BIN=""
689-
if [[ "$short" == "x64" ]]; then
690-
STRIP_BIN="/usr/bin/x86_64-linux-gnu-strip"
691-
else
692-
STRIP_BIN="/usr/bin/aarch64-linux-gnu-strip"
693-
fi
694-
if [[ -x "$STRIP_BIN" ]]; then
695-
STRIP_ARGS=( --define "__strip $STRIP_BIN" )
696-
fi
697-
fi
698-
699679
# Build RPM for this arch (force rpm --target to match compile arch)
700-
if [[ "$USE_TOPDIR_DEFINE" -eq 1 ]]; then
701-
rpmbuild -ba "$SPECFILE" --define "_topdir $TOPDIR" --target "$rpm_target" "${STRIP_ARGS[@]}"
702-
else
703-
rpmbuild -ba "$SPECFILE" --target "$rpm_target" "${STRIP_ARGS[@]}"
704-
fi
705-
706-
# Copy temporary rpmbuild to ~/rpmbuild on Debian/Ubuntu path
707-
if [[ "$USE_TOPDIR_DEFINE" -eq 1 ]]; then
708-
mkdir -p "$HOME/rpmbuild"
709-
rsync -a "$TOPDIR"/ "$HOME/rpmbuild"/
710-
TOPDIR="$HOME/rpmbuild"
711-
fi
680+
rpmbuild -ba "$SPECFILE" --target "$rpm_target"
712681

713682
echo "Build done for $short. RPM at:"
714683
local f

v2rayN/ServiceLib/Common/Utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,13 @@ public static Dictionary<string, List<string>> ParseHostsToDictionary(string? ho
339339
return new();
340340
}
341341
var userHostsMap = hostsContent
342-
.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries)
342+
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
343343
.Select(line => line.Trim())
344344
// skip full-line comments
345345
.Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith('#'))
346346
// ensure line still contains valid parts
347347
.Where(line => !string.IsNullOrWhiteSpace(line) && line.Contains(' '))
348-
.Select(line => line.Split([' ', '\t'], StringSplitOptions.RemoveEmptyEntries))
348+
.Select(line => line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries))
349349
.Where(parts => parts.Length >= 2)
350350
.GroupBy(parts => parts[0])
351351
.ToDictionary(

v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxDnsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private async Task<int> GenDnsRules(ProfileItem? node, SingboxConfig singboxConf
301301
if (!string.IsNullOrEmpty(simpleDNSItem?.DirectExpectedIPs))
302302
{
303303
var ipItems = simpleDNSItem.DirectExpectedIPs
304-
.Split([',', ';'], StringSplitOptions.RemoveEmptyEntries)
304+
.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
305305
.Select(s => s.Trim())
306306
.Where(s => !string.IsNullOrEmpty(s))
307307
.ToList();

0 commit comments

Comments
 (0)