Skip to content

Commit afb10e6

Browse files
committed
Bump to v1.1 with comprehensive bug fixes from full codebase audit
- Fix slipnet:// URL field 28/29 ordering (dnsttAuthoritative vs naivePort) - Fix SOCKS test counting pass instead of fail when connectivity fails - Fix unguarded ln/systemctl commands that crash under set -euo pipefail - Add conflicting flag validation (--add-domain, --harden, --users) - Add dnstm install check to --harden mode - Add consecutive dot rejection in domain validation - Add EOF handling for menu read in user management TUI - Fix sshtun-user configure silently ignoring failures - Fix Farsi README missing ds2 NS record and incomplete management commands - Fix English README DNS record count (1 A + 4 NS, not 3 NS)
1 parent ebb1581 commit afb10e6

2 files changed

Lines changed: 50 additions & 28 deletions

File tree

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ The wizard has **12 steps**. Here's what each one does:
189189
<summary><b>Step 3 — 📝 DNS Records (Cloudflare)</b></summary>
190190

191191
- Shows you exactly which DNS records to create in Cloudflare
192-
- Displays a formatted box with all 4 records (1 A + 3 NS)
192+
- Displays a formatted box with all 5 records (1 A + 4 NS)
193193
- Explains why "DNS Only" (grey cloud) is required
194194
- Waits for your confirmation before proceeding
195195
</details>
@@ -795,13 +795,14 @@ sudo bash dnstm-setup.sh --users
795795
| IPv4 | آدرس IP سرور شما |
796796
| Proxy | **DNS Only** (ابر خاکستری ⚪ — نه نارنجی 🟠!) |
797797

798-
### رکوردهای 2 تا 4 — NS Record
798+
### رکوردهای 2 تا 5 — NS Record
799799

800800
| Type | Name | Target |
801801
|---|---|---|
802802
| `NS` | `t2` | `ns.yourdomain.com` |
803803
| `NS` | `d2` | `ns.yourdomain.com` |
804804
| `NS` | `s2` | `ns.yourdomain.com` |
805+
| `NS` | `ds2` | `ns.yourdomain.com` |
805806

806807
### ⚠️ اشتباهات رایج
807808

@@ -927,7 +928,9 @@ dnstm tunnel list
927928

928929
# 🔗 ایجاد لینک اشتراک‌گذاری (dnst:// برای dnstc)
929930
dnstm tunnel share -t slip1
931+
dnstm tunnel share -t dnstt-ssh --user tunnel --password secret
930932
# لینک‌های slipnet:// برای اپ SlipNet خودکار در خلاصه نصب نمایش داده می‌شوند
933+
# — لینک رو تو گوشی اندروید باز کنید تا پروفایل وارد SlipNet بشه
931934

932935
# 📊 بررسی وضعیت روتر
933936
dnstm router status
@@ -937,11 +940,17 @@ dnstm router logs
937940

938941
# 🔍 مشاهده لاگ تانل خاص
939942
dnstm tunnel logs --tag slip1
943+
dnstm tunnel logs --tag dnstt1
944+
dnstm tunnel logs --tag slip-ssh
940945

941946
# ⏹️ توقف / ▶️ شروع یک تانل
942947
dnstm tunnel stop --tag slip1
943948
dnstm tunnel start --tag slip1
944949

950+
# 🔀 توقف / شروع روتر DNS
951+
dnstm router stop
952+
dnstm router start
953+
945954
# 🧪 تست پروکسی SOCKS (بررسی پورت: ss -tlnp | grep microsocks)
946955
curl --socks5 127.0.0.1:<MICROSOCKS_PORT> https://api.ipify.org
947956
```

dnstm-setup.sh

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
set -euo pipefail
1212

13-
VERSION="1.0"
13+
VERSION="1.1"
1414
TOTAL_STEPS=12
1515

1616
# ─── Colors & Formatting ───────────────────────────────────────────────────────
@@ -550,7 +550,7 @@ show_about() {
550550

551551
# Generate a slipnet:// deep-link URL for the SlipNet Android app.
552552
# Usage: generate_slipnet_url <tunnel_type> <subdomain> [pubkey] [ssh_user] [ssh_pass]
553-
# tunnel_type: "slipstream" or "dnstt"
553+
# tunnel_type: "ss", "dnstt", "slipstream_ssh", or "dnstt_ssh" (SlipNet constants)
554554
# subdomain: e.g. "t2" or "d2"
555555
# pubkey: DNSTT public key (required for dnstt, empty for slipstream)
556556
# ssh_user: SSH tunnel username (optional)
@@ -578,7 +578,7 @@ generate_slipnet_url() {
578578
# 26:sshKeyPass 27:torBridges 28:dnsttAuthoritative 29:naivePort
579579
# 30:naiveUser 31:naivePass 32:isLocked 33:lockHash 34:expiration
580580
# 35:allowSharing 36:boundDeviceId
581-
local data="16|${tunnel_type}|${name}|${ns_domain}|${resolver}|0|5000|bbr|1080|127.0.0.1|0|${pubkey}|||${ssh_enabled}|${ssh_user}|${ssh_pass}|${ssh_port}|0|${ssh_host}|0||udp|password|||0|443||||0||0|0|"
581+
local data="16|${tunnel_type}|${name}|${ns_domain}|${resolver}|0|5000|bbr|1080|127.0.0.1|0|${pubkey}|||${ssh_enabled}|${ssh_user}|${ssh_pass}|${ssh_port}|0|${ssh_host}|0||udp|password|||0|0|443|||0||0|0|"
582582
echo "slipnet://$(echo -n "$data" | base64 -w0)"
583583
}
584584

@@ -628,7 +628,7 @@ EOF
628628
fi
629629

630630
if [[ -e /run/systemd/resolve/resolv.conf ]]; then
631-
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
631+
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf || true
632632
fi
633633

634634
return 0
@@ -744,7 +744,7 @@ apply_service_hardening() {
744744
write_service_override "microsocks.service" "nobody" "nogroup" "no"
745745
fi
746746

747-
systemctl daemon-reload
747+
systemctl daemon-reload 2>/dev/null || true
748748

749749
local hardening_ok=true
750750
for unit in $dnstm_units microsocks.service; do
@@ -756,7 +756,7 @@ apply_service_hardening() {
756756
print_warn "Failed to restart hardened unit: $unit — rolling back"
757757
local dropin="/etc/systemd/system/${unit}.d/20-hardening.conf"
758758
rm -f "$dropin"
759-
systemctl daemon-reload
759+
systemctl daemon-reload 2>/dev/null || true
760760
systemctl reset-failed "$unit" 2>/dev/null || true
761761
systemctl restart "$unit" 2>/dev/null || true
762762
hardening_ok=false
@@ -783,6 +783,11 @@ do_harden() {
783783
exit 1
784784
fi
785785

786+
if ! command -v dnstm &>/dev/null; then
787+
print_fail "dnstm is not installed. Run the setup first before hardening."
788+
exit 1
789+
fi
790+
786791
configure_systemd_resolved_no_stub || true
787792
apply_service_hardening
788793

@@ -890,7 +895,7 @@ do_uninstall() {
890895
systemctl enable systemd-resolved.service 2>/dev/null || true
891896
systemctl restart systemd-resolved.service 2>/dev/null || true
892897
if [[ -e /run/systemd/resolve/stub-resolv.conf ]]; then
893-
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
898+
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf || true
894899
fi
895900
print_ok "Restored systemd-resolved defaults (best effort)"
896901

@@ -926,8 +931,11 @@ do_manage_users() {
926931

927932
# Run initial configure
928933
print_info "Applying SSH security configuration..."
929-
sshtun-user configure 2>&1 || true
930-
print_ok "SSH configuration applied"
934+
if sshtun-user configure 2>&1; then
935+
print_ok "SSH configuration applied"
936+
else
937+
print_warn "SSH configuration may not have applied fully — user management may have issues"
938+
fi
931939
echo ""
932940
fi
933941

@@ -943,8 +951,8 @@ do_manage_users() {
943951
echo -e " ${BOLD}0${NC} Exit"
944952
echo ""
945953

946-
local choice
947-
read -rp " Select [0-4]: " choice
954+
local choice=""
955+
read -rp " Select [0-4]: " choice || true
948956

949957
case "$choice" in
950958
1)
@@ -1077,6 +1085,17 @@ while [[ $# -gt 0 ]]; do
10771085
esac
10781086
done
10791087

1088+
# ─── Validate conflicting flags ──────────────────────────────────────────────────
1089+
1090+
mode_count=0
1091+
[[ "$ADD_DOMAIN_MODE" == true ]] && ((mode_count++))
1092+
[[ "$HARDEN_ONLY_MODE" == true ]] && ((mode_count++))
1093+
[[ "$MANAGE_USERS_MODE" == true ]] && ((mode_count++))
1094+
if [[ $mode_count -gt 1 ]]; then
1095+
echo "Error: --add-domain, --harden, and --users cannot be combined."
1096+
exit 1
1097+
fi
1098+
10801099
# ─── Variables (populated during setup) ─────────────────────────────────────────
10811100

10821101
DOMAIN=""
@@ -1164,6 +1183,8 @@ step_ask_domain() {
11641183
print_fail "Domain cannot be empty. Please try again."
11651184
elif [[ ! "$DOMAIN" =~ \. ]]; then
11661185
print_fail "Invalid domain (must contain a dot). Please try again."
1186+
elif [[ "$DOMAIN" =~ \.\. ]]; then
1187+
print_fail "Invalid domain (consecutive dots not allowed). Please try again."
11671188
elif [[ ! "$DOMAIN" =~ ^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?$ ]]; then
11681189
print_fail "Invalid domain (use only letters, numbers, dots, hyphens). Please try again."
11691190
else
@@ -1831,7 +1852,7 @@ step_tests() {
18311852
elif ss -tlnp 2>/dev/null | grep -q "microsocks"; then
18321853
print_warn "SOCKS proxy: LISTENING on port ${socks_port} but connectivity test failed"
18331854
print_info "microsocks is running but outbound may be blocked or tunnels not ready"
1834-
pass=$((pass + 1))
1855+
fail=$((fail + 1))
18351856
else
18361857
print_fail "SOCKS proxy: FAIL (microsocks not running)"
18371858
fail=$((fail + 1))
@@ -2144,6 +2165,8 @@ do_add_domain() {
21442165
print_fail "Domain cannot be empty. Please try again."
21452166
elif [[ ! "$DOMAIN" =~ \. ]]; then
21462167
print_fail "Invalid domain (must contain a dot). Please try again."
2168+
elif [[ "$DOMAIN" =~ \.\. ]]; then
2169+
print_fail "Invalid domain (consecutive dots not allowed). Please try again."
21472170
elif [[ ! "$DOMAIN" =~ ^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?$ ]]; then
21482171
print_fail "Invalid domain (use only letters, numbers, dots, hyphens). Please try again."
21492172
elif echo "$existing_domains" | grep -qx "$DOMAIN"; then
@@ -2354,12 +2377,10 @@ do_add_domain() {
23542377
echo -e " ${GREEN}${tag}:${NC} ${share_url}"
23552378
fi
23562379
done
2357-
for tag in "$slip_ssh_tag" "$dnstt_ssh_tag"; do
2358-
share_url=$(dnstm tunnel share -t "$tag" 2>/dev/null || true)
2359-
if [[ -n "$share_url" ]]; then
2360-
echo -e " ${GREEN}${tag}:${NC} ${share_url}"
2361-
fi
2362-
done
2380+
echo ""
2381+
echo -e " ${DIM}Note: SSH tunnel share URLs require credentials. Generate them with:${NC}"
2382+
echo -e " ${DIM} dnstm tunnel share -t ${slip_ssh_tag} --user <username> --password <pass>${NC}"
2383+
echo -e " ${DIM} dnstm tunnel share -t ${dnstt_ssh_tag} --user <username> --password <pass>${NC}"
23632384
echo ""
23642385

23652386
# Generate SlipNet deep-link URLs for new tunnels (slipnet:// for SlipNet app)
@@ -2372,14 +2393,6 @@ do_add_domain() {
23722393
slipnet_url=$(generate_slipnet_url "dnstt" "d2" "$DNSTT_PUBKEY" "" "")
23732394
echo -e " ${GREEN}${dnstt_tag}:${NC} ${slipnet_url}"
23742395
fi
2375-
if [[ -n "$SSH_USER" && -n "$SSH_PASS" ]]; then
2376-
slipnet_url=$(generate_slipnet_url "slipstream_ssh" "s2" "" "$SSH_USER" "$SSH_PASS")
2377-
echo -e " ${GREEN}${slip_ssh_tag}:${NC} ${slipnet_url}"
2378-
if [[ -n "$DNSTT_PUBKEY" ]]; then
2379-
slipnet_url=$(generate_slipnet_url "dnstt_ssh" "ds2" "$DNSTT_PUBKEY" "$SSH_USER" "$SSH_PASS")
2380-
echo -e " ${GREEN}${dnstt_ssh_tag}:${NC} ${slipnet_url}"
2381-
fi
2382-
fi
23832396
echo ""
23842397

23852398
echo -e " ${DIM}To add more domains, run again: sudo bash $0 --add-domain${NC}"

0 commit comments

Comments
 (0)