Files
im0o 3d7304dd22
release / release (push) Successful in 29s
入站详情可以测常用 AI 服务的可访问性
判定按状态码白名单而不是只认 200:探测不带鉴权,OpenAI 回 401、Anthropic 回 405
才是正常应答,说明 TLS 握手、路由、目标服务全都正常。清单和白名单照 sub2api 的
代理质量检查抄来。

失败文案不照抄 Bun:本机端口没人监听时它给的是「Unable to connect. Is the
computer able to access the url?」,把矛头指向目标网址,而真正的原因在本机。

对话框留在 InboundDetail 而不是提到 RouterPage——它不写配置文件也不改内核状态,
不需要走那条 commit 链路。firstPort 挪进 shared/inbounds.ts,两个页面都要用它了。
2026-08-31 03:59:08 +08:00

34 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'bun:test'
import { kernelPorts, modeLabel } from './dashboard.ts'
describe('运行模式', () => {
it('三个已知模式有中文名', () => {
expect(modeLabel('rule')).toBe('规则')
expect(modeLabel('global')).toBe('全局')
expect(modeLabel('direct')).toBe('直连')
})
it('没见过的值原样显示,缺省是破折号', () => {
expect(modeLabel('script')).toBe('script')
expect(modeLabel(undefined)).toBe('—')
expect(modeLabel('')).toBe('—')
})
})
describe('代理端口', () => {
it('挑出大于 0 的端口,按固定顺序', () => {
expect(kernelPorts({ 'mixed-port': 7890, port: 7891, 'socks-port': 0 })).toEqual([
{ name: 'port', port: 7891 },
{ name: 'mixed-port', port: 7890 },
])
})
it('0、缺省和非数字都不算启用', () => {
expect(kernelPorts({ port: 0, 'socks-port': 'abc' })).toEqual([])
})
it('字符串端口号也认得', () => {
expect(kernelPorts({ port: '7890' })).toEqual([{ name: 'port', port: 7890 }])
})
})