feat(mtproto): expose mtg-multi's per-IP pending-handshake limit

mtg-multi v1.16.0 adds [defense.pending-handshakes] max-per-ip, which
closes new connections from an IP already holding that many
unauthenticated handshakes, so one address cannot pin the workers other
clients need. The MTProto inbound form now carries it as
pendingHandshakesMaxPerIp; the key is written only when set above 0, so
existing inbounds render a byte-identical config and are not restarted.
A change to it moves the structural fingerprint and restarts the sidecar.

dry-run is left out on purpose: it only feeds the pending_handshake_limit
Prometheus metric, which the panel does not surface. The hint warns that
clients behind carrier NAT share the limit.
This commit is contained in:
MHSanaei
2026-10-14 16:46:20 +02:00
parent 6bd1b8676a
commit b177b98ce8
17 changed files with 96 additions and 42 deletions
@@ -74,6 +74,13 @@ export default function MtprotoFields() {
>
<InputNumber min={0} placeholder="0" style={{ width: '100%' }} />
</FormField>
<FormField
name={['settings', 'pendingHandshakesMaxPerIp']}
label={t('pages.inbounds.form.mtgPendingHandshakesMaxPerIp')}
tooltip={t('pages.inbounds.form.mtgPendingHandshakesMaxPerIpHint')}
>
<InputNumber min={0} placeholder="0" style={{ width: '100%' }} />
</FormField>
<FormField
name={['settings', 'routeThroughXray']}
label={t('pages.inbounds.form.mtgRouteThroughXray')}
@@ -53,6 +53,8 @@ export const MtprotoInboundSettingsSchema = z.object({
// Caps concurrent connections across all users with a fair-share algorithm;
// 0 or unset disables throttling.
throttleMaxConnections: z.number().int().min(0).optional(),
// mtg's [defense.pending-handshakes] max-per-ip; 0 or unset leaves it off.
pendingHandshakesMaxPerIp: z.number().int().min(0).optional(),
// When set, the mtg sidecar dials Telegram through a loopback SOCKS bridge in
// the Xray config so the egress obeys routing rules. `outboundTag` optionally
// forces that traffic out a specific outbound/balancer. `routeXrayPort` is the