chore: chore: update dependencies
Build / Build (push) Has been cancelled

This commit is contained in:
nadoo committed 2026-07-02 20:33:37 +08:00
1 parent 38b34030bc
commit 579b427e9d
10 files changed
+47 -41

No files matched your search

+4 -4
View File
@@ -33,9 +33,9 @@ type Forwarder struct {
func ForwarderFromURL(s, intface string, dialTimeout, relayTimeout time.Duration) (f *Forwarder, err error) {
f = &Forwarder{url: s}
ss := strings.Split(s, "#")
if len(ss) > 1 {
err = f.parseOption(ss[1])
chain, option, found := strings.Cut(s, "#")
if found {
err = f.parseOption(option)
}
iface := intface
@@ -50,7 +50,7 @@ func ForwarderFromURL(s, intface string, dialTimeout, relayTimeout time.Duration
}
var addrs []string
for _, url := range strings.Split(ss[0], ",") {
for url := range strings.SplitSeq(chain, ",") {
d, err = proxy.DialerFromURL(url, d)
if err != nil {
return nil, err
+12 -10
View File
@@ -6,7 +6,7 @@ import (
"net"
"net/url"
"path/filepath"
"sort"
"slices"
"strings"
"sync"
"sync/atomic"
@@ -16,18 +16,11 @@ import (
"github.com/nadoo/glider/proxy"
)
// forwarder slice orderd by priority.
type priSlice []*Forwarder
func (p priSlice) Len() int { return len(p) }
func (p priSlice) Less(i, j int) bool { return p[i].Priority() > p[j].Priority() }
func (p priSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
// FwdrGroup is a forwarder group.
type FwdrGroup struct {
name string
config *Strategy
fwdrs priSlice
fwdrs []*Forwarder
avail []*Forwarder // available forwarders
mu sync.RWMutex
index uint32
@@ -66,7 +59,16 @@ func NewFwdrGroup(rulePath string, s []string, c *Strategy) *FwdrGroup {
// newFwdrGroup returns a new FwdrGroup.
func newFwdrGroup(name string, fwdrs []*Forwarder, c *Strategy) *FwdrGroup {
p := &FwdrGroup{name: name, fwdrs: fwdrs, config: c}
sort.Sort(p.fwdrs)
slices.SortFunc(p.fwdrs, func(a, b *Forwarder) int {
switch {
case a.Priority() > b.Priority():
return -1
case a.Priority() < b.Priority():
return 1
default:
return 0
}
})
p.init()
+1 -1
View File
@@ -56,7 +56,7 @@ func NewProxy(mainForwarders []string, mainStrategy *Strategy, rules []*Config)
// if there's any forwarder defined in main config, make sure they will be accessed directly.
if len(mainForwarders) > 0 {
for _, f := range rd.main.fwdrs {
addr := strings.Split(f.addr, ",")[0]
addr, _, _ := strings.Cut(f.addr, ",")
host, _, _ := net.SplitHostPort(addr)
if _, err := netip.ParseAddr(host); err != nil {
rd.domainMap.Store(strings.ToLower(host), direct)