Skip to content

Commit 1b22492

Browse files
committed
Add FAKE_CERT_LEN setting, domain support in links, fix TG bot link format
- FAKE_CERT_LEN persists in settings.conf (default 2048, min 512) - CUSTOM_IP now accepts domain names in addition to IPv4/IPv6 - TG bot messages now include clickable https://t.me/proxy?... links instead of raw server/port/secret fields
1 parent f3f580c commit 1b22492

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

mtproxymax.sh

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ PROXY_CONCURRENCY=8192
103103
PROXY_CPUS=""
104104
PROXY_MEMORY=""
105105
CUSTOM_IP=""
106+
FAKE_CERT_LEN=2048
106107
AD_TAG=""
107108
BLOCKLIST_COUNTRIES=""
108109
MASKING_ENABLED="true"
@@ -551,6 +552,7 @@ PROXY_CONCURRENCY='${PROXY_CONCURRENCY}'
551552
PROXY_CPUS='${PROXY_CPUS}'
552553
PROXY_MEMORY='${PROXY_MEMORY}'
553554
CUSTOM_IP='${CUSTOM_IP}'
555+
FAKE_CERT_LEN='${FAKE_CERT_LEN}'
554556
555557
# Ad-Tag (from @MTProxyBot)
556558
AD_TAG='${AD_TAG}'
@@ -602,7 +604,7 @@ load_settings() {
602604
# Whitelist of allowed keys
603605
case "$key" in
604606
PROXY_PORT|PROXY_METRICS_PORT|PROXY_DOMAIN|PROXY_CONCURRENCY|\
605-
PROXY_CPUS|PROXY_MEMORY|CUSTOM_IP|AD_TAG|BLOCKLIST_COUNTRIES|\
607+
PROXY_CPUS|PROXY_MEMORY|CUSTOM_IP|FAKE_CERT_LEN|AD_TAG|BLOCKLIST_COUNTRIES|\
606608
MASKING_ENABLED|MASKING_HOST|MASKING_PORT|\
607609
TELEGRAM_ENABLED|TELEGRAM_BOT_TOKEN|TELEGRAM_CHAT_ID|\
608610
TELEGRAM_INTERVAL|TELEGRAM_ALERTS_ENABLED|TELEGRAM_SERVER_LABEL|\
@@ -616,6 +618,7 @@ load_settings() {
616618
[[ "$PROXY_PORT" =~ ^[0-9]+$ ]] && [ "$PROXY_PORT" -ge 1 ] && [ "$PROXY_PORT" -le 65535 ] || PROXY_PORT=443
617619
[[ "$PROXY_METRICS_PORT" =~ ^[0-9]+$ ]] && [ "$PROXY_METRICS_PORT" -ge 1 ] && [ "$PROXY_METRICS_PORT" -le 65535 ] || PROXY_METRICS_PORT=9090
618620
[[ "$MASKING_PORT" =~ ^[0-9]+$ ]] && [ "$MASKING_PORT" -ge 1 ] && [ "$MASKING_PORT" -le 65535 ] || MASKING_PORT=443
621+
[[ "$FAKE_CERT_LEN" =~ ^[0-9]+$ ]] && [ "$FAKE_CERT_LEN" -ge 512 ] || FAKE_CERT_LEN=2048
619622
[[ "$PROXY_CONCURRENCY" =~ ^[0-9]+$ ]] || PROXY_CONCURRENCY=8192
620623
[[ "$TELEGRAM_INTERVAL" =~ ^[0-9]+$ ]] || TELEGRAM_INTERVAL=6
621624
[[ "$TELEGRAM_CHAT_ID" =~ ^-?[0-9]+$ ]] || TELEGRAM_CHAT_ID=""
@@ -1050,7 +1053,7 @@ tls_domain = "${domain}"
10501053
mask = ${mask_enabled}
10511054
mask_port = ${mask_port}
10521055
$([ "$mask_enabled" = "true" ] && [ -n "$mask_host" ] && echo "mask_host = \"${mask_host}\"")
1053-
fake_cert_len = 2048
1056+
fake_cert_len = ${FAKE_CERT_LEN:-2048}
10541057
# Note: geo-blocking is enforced at the host firewall level (iptables/nftables),
10551058
# not via telemt config. See: mtproxymax info -> Geo-Blocking
10561059
@@ -3131,7 +3134,7 @@ telegram_notify_proxy_started() {
31313134
server_ip=$(get_public_ip)
31323135
[ -z "$server_ip" ] && return 1
31333136

3134-
# Build message with all enabled secrets (split details — no full proxy URLs)
3137+
# Build message with all enabled secrets and clickable connect links
31353138
local msg="📱 *MTProxy Started*\n\n"
31363139
local i _first_secret=""
31373140
for i in "${!SECRETS_LABELS[@]}"; do
@@ -3140,13 +3143,12 @@ telegram_notify_proxy_started() {
31403143
full_secret=$(build_faketls_secret "${SECRETS_KEYS[$i]}")
31413144
[ -z "$_first_secret" ] && _first_secret="$full_secret"
31423145
msg+="🏷 *${SECRETS_LABELS[$i]}*\n"
3143-
msg+="📡 Server: \`${server_ip}\`\n"
3144-
msg+="🔌 Port: \`${PROXY_PORT}\`\n"
3145-
msg+="🔑 Secret: \`${full_secret}\`\n\n"
3146+
msg+="🔗 [Connect](https://t.me/proxy?server=${server_ip}&port=${PROXY_PORT}&secret=${full_secret})\n"
3147+
msg+="📡 \`${server_ip}:${PROXY_PORT}\` | 🔑 \`${full_secret}\`\n\n"
31463148
done
31473149

3148-
msg+="📊 Port: ${PROXY_PORT} | Domain: ${PROXY_DOMAIN}\n"
3149-
msg+="_Scan the QR code below to connect._"
3150+
msg+="📊 Domain: ${PROXY_DOMAIN}\n"
3151+
msg+="_Tap the link above or scan QR code to connect._"
31503152

31513153
telegram_send_message "$msg"
31523154

@@ -3616,7 +3618,7 @@ _process_cmd() {
36163618
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
36173619
local fs="ee${secret}${dh}"
36183620
[ -z "$_first_fs" ] && _first_fs="$fs"
3619-
msg+="🏷 *$(_esc "$label")*\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`\n\n"
3621+
msg+="🏷 *$(_esc "$label")*\n🔗 [Connect](https://t.me/proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs})\n📡 \`${ip}:${PROXY_PORT}\` | 🔑 \`${fs}\`\n\n"
36203622
done < "$SECRETS_FILE"
36213623
tg_send "$msg"
36223624
# Send QR for first enabled secret
@@ -3633,7 +3635,7 @@ _process_cmd() {
36333635
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
36343636
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
36353637
local fs="ee${ns}${dh}"
3636-
tg_send "✅ Secret *$(_esc "$label")* created!\n\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`"
3638+
tg_send "✅ Secret *$(_esc "$label")* created!\n\n🔗 [Connect](https://t.me/proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs})\n📡 \`${ip}:${PROXY_PORT}\` | 🔑 \`${fs}\`"
36373639
send_proxy_qr "$ip" "$PROXY_PORT" "$fs"
36383640
else
36393641
tg_send "❌ Failed to add secret '$(_esc "$label")' (may already exist)"
@@ -3672,7 +3674,7 @@ _process_cmd() {
36723674
local ns=$(grep "^${label}|" "$SECRETS_FILE" 2>/dev/null | head -1 | cut -d'|' -f2)
36733675
local dh=$(domain_to_hex "${PROXY_DOMAIN:-cloudflare.com}")
36743676
local fs="ee${ns}${dh}"
3675-
tg_send "🔄 Secret *$(_esc "$label")* rotated!\n\n📡 Server: \`${ip}\`\n🔌 Port: \`${PROXY_PORT}\`\n🔑 Secret: \`${fs}\`"
3677+
tg_send "🔄 Secret *$(_esc "$label")* rotated!\n\n🔗 [Connect](https://t.me/proxy?server=${ip}&port=${PROXY_PORT}&secret=${fs})\n📡 \`${ip}:${PROXY_PORT}\` | 🔑 \`${fs}\`"
36763678
send_proxy_qr "$ip" "$PROXY_PORT" "$fs"
36773679
else
36783680
tg_send "❌ Secret '$(_esc "$label")' not found"
@@ -3962,15 +3964,15 @@ run_installer() {
39623964
echo ""
39633965
local _detected_ip
39643966
_detected_ip=$(CUSTOM_IP="" get_public_ip)
3965-
echo -e " ${BOLD}Server IP${NC} ${DIM}(used in proxy links)${NC}"
3966-
echo -en " ${DIM}Detected: ${_detected_ip:-unknown} — Enter custom IP or press Enter [${_detected_ip:-auto}]:${NC} "
3967+
echo -e " ${BOLD}Server IP or Domain${NC} ${DIM}(used in proxy links — IP or hostname both work)${NC}"
3968+
echo -en " ${DIM}Detected: ${_detected_ip:-unknown} — Enter custom IP/domain or press Enter [${_detected_ip:-auto}]:${NC} "
39673969
local ip_input
39683970
read -r ip_input
39693971
if [ -n "$ip_input" ]; then
3970-
if [[ "$ip_input" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$ip_input" =~ ^[0-9a-fA-F:]+$ ]]; then
3972+
if [[ "$ip_input" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$ip_input" =~ ^[0-9a-fA-F:]+$ ]] || [[ "$ip_input" =~ ^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$ ]]; then
39713973
CUSTOM_IP="$ip_input"
39723974
else
3973-
log_warn "Invalid IP address, using auto-detected"
3975+
log_warn "Invalid IP/domain, using auto-detected"
39743976
fi
39753977
fi
39763978

@@ -4335,7 +4337,7 @@ show_cli_help() {
43354337
echo ""
43364338
echo -e " ${BOLD}Configuration:${NC}"
43374339
echo -e " ${GREEN}port${NC} [get|<number>] Show or change proxy port"
4338-
echo -e " ${GREEN}ip${NC} [get|auto|<address>] Show, reset, or set custom IP for links"
4340+
echo -e " ${GREEN}ip${NC} [get|auto|<address>] Show, reset, or set custom IP/domain for links"
43394341
echo -e " ${GREEN}domain${NC} [get|clear|<host>] Show, clear, or change FakeTLS domain"
43404342
echo -e " ${GREEN}adtag${NC} [set <hex>|remove|view] Manage ad-tag"
43414343
echo -e " ${GREEN}geoblock${NC} [add|remove|list|clear] Manage geo-blocking"
@@ -4604,12 +4606,12 @@ cli_main() {
46044606
;;
46054607
*)
46064608
check_root
4607-
if [[ "$ip_arg" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$ip_arg" =~ ^[0-9a-fA-F:]+$ ]]; then
4609+
if [[ "$ip_arg" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$ip_arg" =~ ^[0-9a-fA-F:]+$ ]] || [[ "$ip_arg" =~ ^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$ ]]; then
46084610
CUSTOM_IP="$ip_arg"
46094611
save_settings
4610-
log_success "IP set to ${ip_arg}"
4612+
log_success "IP/domain set to ${ip_arg}"
46114613
else
4612-
log_error "Invalid IP address: ${ip_arg}"
4614+
log_error "Invalid IP address or domain: ${ip_arg}"
46134615
return 1
46144616
fi
46154617
;;
@@ -5404,12 +5406,12 @@ show_settings_menu() {
54045406
save_settings
54055407
log_success "IP reset to auto-detect (${_det_ip})"
54065408
elif [ -n "$ip" ]; then
5407-
if [[ "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$ip" =~ ^[0-9a-fA-F:]+$ ]]; then
5409+
if [[ "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "$ip" =~ ^[0-9a-fA-F:]+$ ]] || [[ "$ip" =~ ^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$ ]]; then
54085410
CUSTOM_IP="$ip"
54095411
save_settings
5410-
log_success "IP set to ${ip}"
5412+
log_success "IP/domain set to ${ip}"
54115413
else
5412-
log_error "Invalid IP address"
5414+
log_error "Invalid IP address or domain"
54135415
fi
54145416
fi
54155417
press_any_key

0 commit comments

Comments
 (0)