mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-11-10 21:21:02 +08:00
Changes to the cache file are collected in a write buffer and written in one transaction when the buffer reaches buffer_size, when the OOM killer releases memory, or when sing-box is closed. An optional flush_interval writes the buffer periodically. Previously each DNS response, RDRC entry and FakeIP mapping was committed in its own transaction. Also open the database with NoFreelistSync, and mark store_rdrc and rdrc_timeout as deprecated in the options.
63 lines
2.8 KiB
Go
63 lines
2.8 KiB
Go
package option
|
|
|
|
import (
|
|
"github.com/sagernet/sing/common/byteformats"
|
|
"github.com/sagernet/sing/common/json/badoption"
|
|
)
|
|
|
|
type ExperimentalOptions struct {
|
|
CacheFile *CacheFileOptions `json:"cache_file,omitempty"`
|
|
ClashAPI *ClashAPIOptions `json:"clash_api,omitempty"`
|
|
V2RayAPI *V2RayAPIOptions `json:"v2ray_api,omitempty"`
|
|
Debug *DebugOptions `json:"debug,omitempty"`
|
|
}
|
|
|
|
type CacheFileOptions struct {
|
|
Enabled bool `json:"enabled,omitempty"`
|
|
Path string `json:"path,omitempty"`
|
|
CacheID string `json:"cache_id,omitempty"`
|
|
StoreFakeIP bool `json:"store_fakeip,omitempty"`
|
|
StoreDNS bool `json:"store_dns,omitempty"`
|
|
BufferSize *byteformats.MemoryBytes `json:"buffer_size,omitempty"`
|
|
FlushInterval badoption.Duration `json:"flush_interval,omitempty"`
|
|
|
|
// Deprecated: replaced by store_dns
|
|
StoreRDRC bool `json:"store_rdrc,omitempty" schema:"omit"`
|
|
// Deprecated: replaced by store_dns
|
|
RDRCTimeout badoption.Duration `json:"rdrc_timeout,omitempty" schema:"omit"`
|
|
}
|
|
|
|
type ClashAPIOptions struct {
|
|
ExternalController string `json:"external_controller,omitempty"`
|
|
ExternalUI string `json:"external_ui,omitempty"`
|
|
ExternalUIDownloadURL string `json:"external_ui_download_url,omitempty"`
|
|
ExternalUIDownloadDetour string `json:"external_ui_download_detour,omitempty" reference:"outbound"`
|
|
Secret string `json:"secret,omitempty"`
|
|
DefaultMode string `json:"default_mode,omitempty"`
|
|
AccessControlAllowOrigin badoption.Listable[string] `json:"access_control_allow_origin,omitempty"`
|
|
AccessControlAllowPrivateNetwork bool `json:"access_control_allow_private_network,omitempty"`
|
|
|
|
// Deprecated: migrated to global cache file
|
|
CacheFile string `json:"cache_file,omitempty" schema:"omit"`
|
|
// Deprecated: migrated to global cache file
|
|
CacheID string `json:"cache_id,omitempty" schema:"omit"`
|
|
// Deprecated: migrated to global cache file
|
|
StoreMode bool `json:"store_mode,omitempty" schema:"omit"`
|
|
// Deprecated: migrated to global cache file
|
|
StoreSelected bool `json:"store_selected,omitempty" schema:"omit"`
|
|
// Deprecated: migrated to global cache file
|
|
StoreFakeIP bool `json:"store_fakeip,omitempty" schema:"omit"`
|
|
}
|
|
|
|
type V2RayAPIOptions struct {
|
|
Listen string `json:"listen,omitempty"`
|
|
Stats *V2RayStatsServiceOptions `json:"stats,omitempty"`
|
|
}
|
|
|
|
type V2RayStatsServiceOptions struct {
|
|
Enabled bool `json:"enabled,omitempty"`
|
|
Inbounds []string `json:"inbounds,omitempty"`
|
|
Outbounds []string `json:"outbounds,omitempty"`
|
|
Users []string `json:"users,omitempty"`
|
|
}
|