Add admin panel, manager, node_manager, bandwidth limiter, connection limiter, bonding, failover, vless encryption, mkcp transport

This commit is contained in:
Sergei Maklagin
2026-02-26 22:44:31 +03:00
parent 287fe834db
commit c0aa3480c5
115 changed files with 12582 additions and 301 deletions

13
option/admin_panel.go Normal file
View File

@@ -0,0 +1,13 @@
package option
type AdminPanelServiceOptions struct {
ListenOptions
Manager string `json:"manager"`
Database AdminPanelServiceDatabase `json:"database"`
InboundTLSOptionsContainer
}
type AdminPanelServiceDatabase struct {
Driver string `json:"driver"`
DSN string `json:"dsn"`
}

16
option/bond.go Normal file
View File

@@ -0,0 +1,16 @@
package option
type BondInboundOptions struct {
Inbounds []Inbound `json:"inbounds"`
}
type BondOutboundOptions struct {
Outbounds []BondOutbound `json:"outbounds"`
}
type BondOutbound struct {
Outbound Outbound `json:"outbound"`
DownloadRatio uint8 `json:"download_ratio"`
UploadRatio uint8 `json:"upload_ratio"`
Count uint8 `json:"count"`
}

View File

@@ -16,3 +16,7 @@ type URLTestOutboundOptions struct {
IdleTimeout badoption.Duration `json:"idle_timeout,omitempty"`
InterruptExistConnections bool `json:"interrupt_exist_connections,omitempty"`
}
type FailoverOutboundOptions struct {
Outbounds []string `json:"outbounds"`
}

37
option/limiter.go Normal file
View File

@@ -0,0 +1,37 @@
package option
import (
"github.com/sagernet/sing/common/byteformats"
)
type BandwidthLimiterOutboundOptions struct {
Strategy string `json:"strategy"`
Mode string `json:"mode"`
ConnectionType string `json:"connection_type,omitempty"`
Speed *byteformats.NetworkBytesCompat `json:"speed"`
Users []BandwidthLimiterUser `json:"users,omitempty"`
Route RouteOptions `json:"route"`
}
type BandwidthLimiterUser struct {
Name string `json:"name"`
Strategy string `json:"strategy"`
Mode string `json:"mode"`
ConnectionType string `json:"connection_type,omitempty"`
Speed *byteformats.NetworkBytesCompat `json:"speed"`
}
type ConnectionLimiterOutboundOptions struct {
Strategy string `json:"strategy"`
ConnectionType string `json:"connection_type,omitempty"`
Count uint32 `json:"count"`
Users []ConnectionLimiterUser `json:"users,omitempty"`
Route RouteOptions `json:"route"`
}
type ConnectionLimiterUser struct {
Name string `json:"name"`
Strategy string `json:"strategy"`
ConnectionType string `json:"connection_type,omitempty"`
Count uint32 `json:"count"`
}

11
option/manager.go Normal file
View File

@@ -0,0 +1,11 @@
package option
type ManagerServiceDatabase struct {
Driver string `json:"driver"`
DSN string `json:"dsn"`
}
type ManagerServiceOptions struct {
Inbounds []string `json:"inbounds"`
Database ManagerServiceDatabase `json:"database"`
}

9
option/node.go Normal file
View File

@@ -0,0 +1,9 @@
package option
type NodeServiceOptions struct {
UUID string
Inbounds []string `json:"inbounds"`
ConnectionLimiters []string `json:"connection_limiters"`
BandwidthLimiters []string `json:"bandwidth_limiters"`
Manager string `json:"manager"`
}

13
option/node_manager.go Normal file
View File

@@ -0,0 +1,13 @@
package option
type NodeManagerServerServiceOptions struct {
ListenOptions
InboundTLSOptionsContainer
Manager string `json:"manager"`
}
type NodeManagerClientServiceOptions struct {
DialerOptions
ServerOptions
OutboundTLSOptionsContainer
}

View File

@@ -21,6 +21,7 @@ type _V2RayTransportOptions struct {
GRPCOptions V2RayGRPCOptions `json:"-"`
HTTPUpgradeOptions V2RayHTTPUpgradeOptions `json:"-"`
XHTTPOptions V2RayXHTTPOptions `json:"-"`
KCPOptions V2RayKCPOptions `json:"-"`
}
type V2RayTransportOptions _V2RayTransportOptions
@@ -40,6 +41,8 @@ func (o V2RayTransportOptions) MarshalJSON() ([]byte, error) {
v = o.HTTPUpgradeOptions
case C.V2RayTransportTypeXHTTP:
v = o.XHTTPOptions
case C.V2RayTransportTypeKCP:
v = o.KCPOptions
case "":
return nil, E.New("missing transport type")
default:
@@ -67,6 +70,8 @@ func (o *V2RayTransportOptions) UnmarshalJSON(bytes []byte) error {
v = &o.HTTPUpgradeOptions
case C.V2RayTransportTypeXHTTP:
v = &o.XHTTPOptions
case C.V2RayTransportTypeKCP:
v = &o.KCPOptions
default:
return E.New("unknown transport type: " + o.Type)
}
@@ -250,3 +255,64 @@ func (m *V2RayXHTTPXmuxOptions) GetNormalizedHMaxRequestTimes() Xbadoption.Range
func (m *V2RayXHTTPXmuxOptions) GetNormalizedHMaxReusableSecs() Xbadoption.Range {
return m.HMaxReusableSecs
}
type V2RayKCPOptions struct {
MTU uint32 `json:"mtu,omitempty"`
TTI uint32 `json:"tti,omitempty"`
UplinkCapacity uint32 `json:"uplink_capacity,omitempty"`
DownlinkCapacity uint32 `json:"downlink_capacity,omitempty"`
Congestion bool `json:"congestion,omitempty"`
ReadBufferSize uint32 `json:"read_buffer_size,omitempty"`
WriteBufferSize uint32 `json:"write_buffer_size,omitempty"`
HeaderType string `json:"header_type,omitempty"`
Seed string `json:"seed,omitempty"`
}
func (k *V2RayKCPOptions) GetMTU() uint32 {
if k.MTU == 0 {
return 1350
}
return k.MTU
}
func (k *V2RayKCPOptions) GetTTI() uint32 {
if k.TTI == 0 {
return 50
}
return k.TTI
}
func (k *V2RayKCPOptions) GetUplinkCapacity() uint32 {
if k.UplinkCapacity == 0 {
return 12
}
return k.UplinkCapacity
}
func (k *V2RayKCPOptions) GetDownlinkCapacity() uint32 {
if k.DownlinkCapacity == 0 {
return 100
}
return k.DownlinkCapacity
}
func (k *V2RayKCPOptions) GetReadBufferSize() uint32 {
if k.ReadBufferSize == 0 {
return 1
}
return k.ReadBufferSize
}
func (k *V2RayKCPOptions) GetWriteBufferSize() uint32 {
if k.WriteBufferSize == 0 {
return 1
}
return k.WriteBufferSize
}
func (k *V2RayKCPOptions) GetHeaderType() string {
if k.HeaderType == "" {
return "none"
}
return k.HeaderType
}

View File

@@ -33,15 +33,17 @@ type WireGuardPeer struct {
}
type WireGuardWARPEndpointOptions struct {
System bool `json:"system,omitempty"`
Name string `json:"name,omitempty"`
ListenPort uint16 `json:"listen_port,omitempty"`
UDPTimeout badoption.Duration `json:"udp_timeout,omitempty"`
Workers int `json:"workers,omitempty"`
PreallocatedBuffersPerPool uint32 `json:"preallocated_buffers_per_pool,omitempty"`
DisablePauses bool `json:"disable_pauses,omitempty"`
Amnezia *WireGuardAmnezia `json:"amnezia,omitempty"`
Profile WARPProfile `json:"profile,omitempty"`
System bool `json:"system,omitempty"`
Name string `json:"name,omitempty"`
ListenPort uint16 `json:"listen_port,omitempty"`
UDPTimeout badoption.Duration `json:"udp_timeout,omitempty"`
PersistentKeepaliveInterval uint16 `json:"persistent_keepalive_interval,omitempty"`
Reserved []uint8 `json:"reserved,omitempty"`
Workers int `json:"workers,omitempty"`
PreallocatedBuffersPerPool uint32 `json:"preallocated_buffers_per_pool,omitempty"`
DisablePauses bool `json:"disable_pauses,omitempty"`
Amnezia *WireGuardAmnezia `json:"amnezia,omitempty"`
Profile WARPProfile `json:"profile,omitempty"`
DialerOptions
}