mirror of
https://github.com/bestnite/sub2sing-box.git
synced 2025-06-16 10:03:18 +08:00
update dependency
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
C "github.com/nitezs/sub2sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
)
|
||||
|
||||
@ -10,20 +9,22 @@ type Outbound struct {
|
||||
}
|
||||
|
||||
func (h *Outbound) GetOutbounds() []string {
|
||||
if h.Type == C.TypeSelector {
|
||||
return h.SelectorOptions.Outbounds
|
||||
}
|
||||
if h.Type == C.TypeURLTest {
|
||||
return h.URLTestOptions.Outbounds
|
||||
switch v := h.Options.(type) {
|
||||
case option.URLTestOutboundOptions:
|
||||
return v.Outbounds
|
||||
case option.SelectorOutboundOptions:
|
||||
return v.Outbounds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Outbound) SetOutbounds(outbounds []string) {
|
||||
if h.Type == C.TypeSelector {
|
||||
h.SelectorOptions.Outbounds = outbounds
|
||||
}
|
||||
if h.Type == C.TypeURLTest {
|
||||
h.URLTestOptions.Outbounds = outbounds
|
||||
switch v := h.Options.(type) {
|
||||
case option.URLTestOutboundOptions:
|
||||
v.Outbounds = outbounds
|
||||
h.Options = v
|
||||
case option.SelectorOutboundOptions:
|
||||
v.Outbounds = outbounds
|
||||
h.Options = v
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
C "github.com/nitezs/sub2sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
|
||||
"golang.org/x/text/collate"
|
||||
"golang.org/x/text/language"
|
||||
@ -13,17 +13,17 @@ func (a SortByNumber) Len() int { return len(a) }
|
||||
func (a SortByNumber) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a SortByNumber) Less(i, j int) bool {
|
||||
var size1, size2 int
|
||||
if a[i].Type == C.TypeSelector {
|
||||
size1 = len(a[i].SelectorOptions.Outbounds)
|
||||
switch v := a[i].Options.(type) {
|
||||
case option.SelectorOutboundOptions:
|
||||
size1 = len(v.Outbounds)
|
||||
case option.URLTestOutboundOptions:
|
||||
size1 = len(v.Outbounds)
|
||||
}
|
||||
if a[i].Type == C.TypeURLTest {
|
||||
size1 = len(a[j].URLTestOptions.Outbounds)
|
||||
}
|
||||
if a[j].Type == C.TypeSelector {
|
||||
size2 = len(a[j].SelectorOptions.Outbounds)
|
||||
}
|
||||
if a[j].Type == C.TypeURLTest {
|
||||
size2 = len(a[j].URLTestOptions.Outbounds)
|
||||
switch v := a[j].Options.(type) {
|
||||
case option.SelectorOutboundOptions:
|
||||
size2 = len(v.Outbounds)
|
||||
case option.URLTestOutboundOptions:
|
||||
size2 = len(v.Outbounds)
|
||||
}
|
||||
return size1 < size2
|
||||
}
|
||||
|
Reference in New Issue
Block a user