-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtypes.ts
More file actions
116 lines (108 loc) · 2.98 KB
/
types.ts
File metadata and controls
116 lines (108 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
export type listable<T> = T | T[]
export interface item_with_tag<T extends string> {
tag: T
}
export type headers = Record<string, listable<string>>
type can_empty<T extends string> = '' | T
type non_empty<T extends string> = T extends '' ? never : T
type empty_join<L extends string[]> = L extends [infer F extends string, ...infer R extends string[]] ? `${can_empty<F>}${empty_join<R>}` : ''
export type duration = non_empty<
empty_join<[
`${number}d`,
`${number}h`,
`${number}m`,
`${number}s`,
`${number}ms`,
`${number}us`,
`${number}ns`,
]>
>
export type strategy =
| 'prefer_ipv4'
| 'prefer_ipv6'
| 'ipv4_only'
| 'ipv6_only'
export type shadowsocks_method =
| '2022-blake3-aes-128-gcm'
| '2022-blake3-aes-256-gcm'
| '2022-blake3-chacha20-poly1305'
| 'none'
| 'aes-128-gcm'
| 'aes-192-gcm'
| 'aes-256-gcm'
| 'chacha20-ietf-poly1305'
| 'xchacha20-ietf-poly1305'
export type sniff_protocol =
| 'http'
| 'tls'
| 'quic'
| 'stun'
| 'dns'
| 'bittorrent'
| 'dtls'
| 'ssh'
| 'rdp'
export type network_strategy = 'default' | 'fallback' | 'hybrid' | 'wifi' | 'cellular' | 'ethernet' | 'wifi_only' | 'cellular_only' | 'ethernet_only'
export type network = 'tcp' | 'udp' | 'icmp'
export type dns_network = 'tcp' | 'udp'
export interface dialer<O extends string, DS extends string> {
detour?: O
bind_interface?: string
inet4_bind_address?: string
inet6_bind_address?: string
bind_address_no_port?: boolean
protect_path?: string
routing_mark?: number
reuse_addr?: boolean
connect_timeout?: duration
tcp_fast_open?: boolean
tcp_multi_path?: boolean
disable_tcp_keep_alive?: boolean
/**
* @default 5m
*/
tcp_keep_alive?: duration
/**
* @default 75s
*/
tcp_keep_alive_interval?: duration
udp_fragment?: boolean
domain_resolver?: DS | resolver<DS>
network_strategy?: network_strategy
network_type?: listable<network_type>
fallback_network_type?: listable<network_type>
fallback_delay?: duration
network_fallback_delay?: duration
/**
* @deprecated domain_strategy is merged to domain_resolver in sing-box 1.12.0
* @since 1.12.0
*/
domain_strategy?: strategy
}
export interface options {
disable_cache?: boolean
rewrite_ttl?: number
client_subnet?: string
}
export interface resolver<DS extends string> extends options {
server: DS
strategy?: strategy
}
export interface server {
server: string
server_port: number
}
export interface listen<T extends string, I extends string> extends item_with_tag<T> {
listen: string
listen_port: number
bind_interface?: string
routing_mark?: number
reuse_addr?: boolean
netns?: string
tcp_fast_open?: boolean
tcp_multi_path?: boolean
udp_fragment?: boolean
udp_timeout?: duration
detour?: I
}
export type network_type = 'wifi' | 'cellular' | 'ethernet' | 'other'