mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-10 05:10:58 +00:00
d97bd8643e
Replace the upstream 9seconds/mtg sidecar with the dolonet/mtg-multi fork so a single MTProto inbound can serve many per-user secrets. Each panel client is now one named FakeTLS secret in the fork's [secrets] section: clients are first-class (attach/detach, limits, expiry, per-client tg:// links) exactly like every other protocol, mirroring the WireGuard multi-client model. Per-client traffic and online status come from the fork's /stats JSON API (its Prometheus output has no per-user label), fed into the existing email-keyed client_traffics accumulator; an optional throttle caps concurrent connections. A one-time seeder converts each legacy single-secret inbound into a one-client inbound. The fork ships only linux/darwin amd64/arm64 binaries but is pure Go, so provisioning builds it from source for every supported platform (release.yml, DockerInit.sh) while keeping the panel-expected mtg-<os>-<arch> filename and the 'run' verb, so process.go is untouched. Also fixes a pre-existing update.sh gap that never renamed the mtg binary for armv6/armv7 updates.
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
import { parseLinkParts, linkMetaText } from '@/lib/xray/link-label';
|
|
|
|
// The panel shows the subscription's remark verbatim. Per-client traffic/expiry
|
|
// info is rendered only into the body a client app imports (backend, first link
|
|
// only), so the panel's display links are already clean — nothing is stripped.
|
|
describe('link-label parseLinkParts', () => {
|
|
const linkWith = (remark: string) =>
|
|
`vless://uid@host.example.com:443?type=tcp&security=tls#${encodeURIComponent(remark)}`;
|
|
|
|
it('parses protocol / network / security and keeps the remark verbatim', () => {
|
|
const parts = parseLinkParts(linkWith('Germany-john@example.com'));
|
|
expect(parts?.protocol).toBe('Vless');
|
|
expect(parts?.network).toBe('TCP');
|
|
expect(parts?.security).toBe('TLS');
|
|
expect(parts?.remark).toBe('Germany-john@example.com');
|
|
expect(parts?.port).toBe('443');
|
|
});
|
|
|
|
it('linkMetaText joins the remark with the port', () => {
|
|
const parts = parseLinkParts(linkWith('Germany-john@example.com'));
|
|
expect(parts && linkMetaText(parts)).toBe('Germany-john@example.com:443');
|
|
});
|
|
|
|
it('returns null for an unparseable scheme', () => {
|
|
expect(parseLinkParts('not-a-link')).toBeNull();
|
|
});
|
|
|
|
// MTProto share links are tg://proxy deep links whose port rides in a query
|
|
// param, not the URL authority; they carry no transport and use FakeTLS.
|
|
it('labels an mtproto tg://proxy link with its query-param port and FakeTLS', () => {
|
|
const parts = parseLinkParts(
|
|
'tg://proxy?server=host.example.com&port=8443&secret=ee00#mt-inbound',
|
|
);
|
|
expect(parts?.protocol).toBe('MTProto');
|
|
expect(parts?.network).toBe('');
|
|
expect(parts?.security).toBe('FAKETLS');
|
|
expect(parts?.port).toBe('8443');
|
|
expect(parts?.remark).toBe('mt-inbound');
|
|
expect(parts && linkMetaText(parts)).toBe('mt-inbound:8443');
|
|
});
|
|
});
|