V2bX/conf/sing.go

83 lines
2.1 KiB
Go
Raw Permalink Normal View History

2023-07-29 06:47:47 -04:00
package conf
2023-08-28 03:24:28 -04:00
import (
2023-10-26 01:06:43 -04:00
"github.com/sagernet/sing-box/option"
2023-08-28 03:24:28 -04:00
)
2023-07-29 06:47:47 -04:00
type SingConfig struct {
2025-01-10 02:33:05 -05:00
LogConfig SingLogConfig `json:"Log"`
NtpConfig SingNtpConfig `json:"NTP"`
OriginalPath string `json:"OriginalPath"`
2023-07-29 06:47:47 -04:00
}
type SingLogConfig struct {
2023-08-20 03:13:52 -04:00
Disabled bool `json:"Disable"`
Level string `json:"Level"`
Output string `json:"Output"`
Timestamp bool `json:"Timestamp"`
2023-07-29 06:47:47 -04:00
}
func NewSingConfig() *SingConfig {
return &SingConfig{
LogConfig: SingLogConfig{
Level: "error",
Timestamp: true,
},
2023-08-25 23:38:18 -04:00
NtpConfig: SingNtpConfig{
Enable: false,
Server: "time.apple.com",
ServerPort: 0,
},
2023-07-29 06:47:47 -04:00
}
}
2023-08-20 03:13:52 -04:00
type SingOptions struct {
TCPFastOpen bool `json:"EnableTFO"`
SniffEnabled bool `json:"EnableSniff"`
2024-10-31 04:46:31 -04:00
SniffOverrideDestination bool `json:"SniffOverrideDestination"`
2023-09-21 00:34:03 -04:00
EnableDNS bool `json:"EnableDNS"`
2023-08-28 03:24:28 -04:00
DomainStrategy option.DomainStrategy `json:"DomainStrategy"`
2023-08-20 03:13:52 -04:00
FallBackConfigs *FallBackConfigForSing `json:"FallBackConfigs"`
2024-10-31 02:21:02 -04:00
Multiplex *MultiplexConfig `json:"MultiplexConfig"`
2023-08-20 03:13:52 -04:00
}
2023-08-25 23:38:18 -04:00
type SingNtpConfig struct {
Enable bool `json:"Enable"`
Server string `json:"Server"`
ServerPort uint16 `json:"ServerPort"`
}
2023-08-20 03:13:52 -04:00
type FallBackConfigForSing struct {
// sing-box
FallBack FallBack `json:"FallBack"`
FallBackForALPN map[string]FallBack `json:"FallBackForALPN"`
}
type FallBack struct {
Server string `json:"Server"`
ServerPort string `json:"ServerPort"`
}
2024-10-31 02:21:02 -04:00
type MultiplexConfig struct {
Enabled bool `json:"Enable"`
Padding bool `json:"Padding"`
Brutal BrutalOptions `json:"Brutal"`
}
type BrutalOptions struct {
Enabled bool `json:"Enable"`
UpMbps int `json:"UpMbps"`
DownMbps int `json:"DownMbps"`
}
2023-08-20 03:13:52 -04:00
func NewSingOptions() *SingOptions {
return &SingOptions{
2023-09-21 00:34:03 -04:00
EnableDNS: false,
2023-08-20 03:13:52 -04:00
TCPFastOpen: false,
SniffEnabled: true,
SniffOverrideDestination: true,
FallBackConfigs: &FallBackConfigForSing{},
2024-10-31 02:21:02 -04:00
Multiplex: &MultiplexConfig{},
2023-08-20 03:13:52 -04:00
}
}