mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-02 01:07:31 +03:00
Add selector outbound
This commit is contained in:
@@ -41,7 +41,7 @@ func (o Options) Equals(other Options) bool {
|
||||
return common.ComparablePtrEquals(o.Log, other.Log) &&
|
||||
common.PtrEquals(o.DNS, other.DNS) &&
|
||||
common.SliceEquals(o.Inbounds, other.Inbounds) &&
|
||||
common.ComparableSliceEquals(o.Outbounds, other.Outbounds) &&
|
||||
common.SliceEquals(o.Outbounds, other.Outbounds) &&
|
||||
common.PtrEquals(o.Route, other.Route) &&
|
||||
common.ComparablePtrEquals(o.Experimental, other.Experimental)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package option
|
||||
|
||||
import (
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing/common"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
|
||||
@@ -16,10 +17,22 @@ type _Outbound struct {
|
||||
HTTPOptions HTTPOutboundOptions `json:"-"`
|
||||
ShadowsocksOptions ShadowsocksOutboundOptions `json:"-"`
|
||||
VMessOptions VMessOutboundOptions `json:"-"`
|
||||
SelectorOptions SelectorOutboundOptions `json:"-"`
|
||||
}
|
||||
|
||||
type Outbound _Outbound
|
||||
|
||||
func (h Outbound) Equals(other Outbound) bool {
|
||||
return h.Type == other.Type &&
|
||||
h.Tag == other.Tag &&
|
||||
h.DirectOptions == other.DirectOptions &&
|
||||
h.SocksOptions == other.SocksOptions &&
|
||||
h.HTTPOptions == other.HTTPOptions &&
|
||||
h.ShadowsocksOptions == other.ShadowsocksOptions &&
|
||||
h.VMessOptions == other.VMessOptions &&
|
||||
common.Equals(h.SelectorOptions, other.SelectorOptions)
|
||||
}
|
||||
|
||||
func (h Outbound) MarshalJSON() ([]byte, error) {
|
||||
var v any
|
||||
switch h.Type {
|
||||
@@ -35,6 +48,8 @@ func (h Outbound) MarshalJSON() ([]byte, error) {
|
||||
v = h.ShadowsocksOptions
|
||||
case C.TypeVMess:
|
||||
v = h.VMessOptions
|
||||
case C.TypeSelector:
|
||||
v = h.SelectorOptions
|
||||
default:
|
||||
return nil, E.New("unknown outbound type: ", h.Type)
|
||||
}
|
||||
@@ -60,6 +75,8 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error {
|
||||
v = &h.ShadowsocksOptions
|
||||
case C.TypeVMess:
|
||||
v = &h.VMessOptions
|
||||
case C.TypeSelector:
|
||||
v = &h.SelectorOptions
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@@ -144,3 +161,13 @@ type VMessOutboundOptions struct {
|
||||
Network NetworkList `json:"network,omitempty"`
|
||||
TLSOptions *OutboundTLSOptions `json:"tls,omitempty"`
|
||||
}
|
||||
|
||||
type SelectorOutboundOptions struct {
|
||||
Outbounds []string `json:"outbounds"`
|
||||
Default string `json:"default,omitempty"`
|
||||
}
|
||||
|
||||
func (o SelectorOutboundOptions) Equals(other SelectorOutboundOptions) bool {
|
||||
return common.ComparableSliceEquals(o.Outbounds, other.Outbounds) &&
|
||||
o.Default == other.Default
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user