mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 08:20:05 +08:00
chore: restful api contains providerChains for connections
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
This commit is contained in:
parent
d2007fdc22
commit
6539b509cb
@ -219,6 +219,7 @@ func NewBase(opt BaseOption) *Base {
|
|||||||
type conn struct {
|
type conn struct {
|
||||||
N.ExtendedConn
|
N.ExtendedConn
|
||||||
chain C.Chain
|
chain C.Chain
|
||||||
|
pdChain C.Chain
|
||||||
adapterAddr string
|
adapterAddr string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,9 +241,15 @@ func (c *conn) Chains() C.Chain {
|
|||||||
return c.chain
|
return c.chain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProviderChains implements C.Connection
|
||||||
|
func (c *conn) ProviderChains() C.Chain {
|
||||||
|
return c.pdChain
|
||||||
|
}
|
||||||
|
|
||||||
// AppendToChains implements C.Connection
|
// AppendToChains implements C.Connection
|
||||||
func (c *conn) AppendToChains(a C.ProxyAdapter) {
|
func (c *conn) AppendToChains(a C.ProxyAdapter) {
|
||||||
c.chain = append(c.chain, a.Name())
|
c.chain = append(c.chain, a.Name())
|
||||||
|
c.pdChain = append(c.pdChain, a.ProxyInfo().ProviderName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conn) Upstream() any {
|
func (c *conn) Upstream() any {
|
||||||
@ -265,7 +272,7 @@ func NewConn(c net.Conn, a C.ProxyAdapter) C.Conn {
|
|||||||
if _, ok := c.(syscall.Conn); !ok { // exclusion system conn like *net.TCPConn
|
if _, ok := c.(syscall.Conn); !ok { // exclusion system conn like *net.TCPConn
|
||||||
c = N.NewDeadlineConn(c) // most conn from outbound can't handle readDeadline correctly
|
c = N.NewDeadlineConn(c) // most conn from outbound can't handle readDeadline correctly
|
||||||
}
|
}
|
||||||
cc := &conn{N.NewExtendedConn(c), nil, a.Addr()}
|
cc := &conn{N.NewExtendedConn(c), nil, nil, a.Addr()}
|
||||||
cc.AppendToChains(a)
|
cc.AppendToChains(a)
|
||||||
return cc
|
return cc
|
||||||
}
|
}
|
||||||
@ -273,6 +280,7 @@ func NewConn(c net.Conn, a C.ProxyAdapter) C.Conn {
|
|||||||
type packetConn struct {
|
type packetConn struct {
|
||||||
N.EnhancePacketConn
|
N.EnhancePacketConn
|
||||||
chain C.Chain
|
chain C.Chain
|
||||||
|
pdChain C.Chain
|
||||||
adapterName string
|
adapterName string
|
||||||
connID string
|
connID string
|
||||||
adapterAddr string
|
adapterAddr string
|
||||||
@ -293,9 +301,15 @@ func (c *packetConn) Chains() C.Chain {
|
|||||||
return c.chain
|
return c.chain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProviderChains implements C.Connection
|
||||||
|
func (c *packetConn) ProviderChains() C.Chain {
|
||||||
|
return c.pdChain
|
||||||
|
}
|
||||||
|
|
||||||
// AppendToChains implements C.Connection
|
// AppendToChains implements C.Connection
|
||||||
func (c *packetConn) AppendToChains(a C.ProxyAdapter) {
|
func (c *packetConn) AppendToChains(a C.ProxyAdapter) {
|
||||||
c.chain = append(c.chain, a.Name())
|
c.chain = append(c.chain, a.Name())
|
||||||
|
c.pdChain = append(c.pdChain, a.ProxyInfo().ProviderName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *packetConn) LocalAddr() net.Addr {
|
func (c *packetConn) LocalAddr() net.Addr {
|
||||||
@ -324,7 +338,7 @@ func newPacketConn(pc net.PacketConn, a ProxyAdapter) C.PacketConn {
|
|||||||
if _, ok := pc.(syscall.Conn); !ok { // exclusion system conn like *net.UDPConn
|
if _, ok := pc.(syscall.Conn); !ok { // exclusion system conn like *net.UDPConn
|
||||||
epc = N.NewDeadlineEnhancePacketConn(epc) // most conn from outbound can't handle readDeadline correctly
|
epc = N.NewDeadlineEnhancePacketConn(epc) // most conn from outbound can't handle readDeadline correctly
|
||||||
}
|
}
|
||||||
cpc := &packetConn{epc, nil, a.Name(), utils.NewUUIDV4().String(), a.Addr(), a.ResolveUDP}
|
cpc := &packetConn{epc, nil, nil, a.Name(), utils.NewUUIDV4().String(), a.Addr(), a.ResolveUDP}
|
||||||
cpc.AppendToChains(a)
|
cpc.AppendToChains(a)
|
||||||
return cpc
|
return cpc
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,7 +156,7 @@ func (pp *proxySetProvider) Initial() error {
|
|||||||
|
|
||||||
func (pp *proxySetProvider) closeAllConnections() {
|
func (pp *proxySetProvider) closeAllConnections() {
|
||||||
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
|
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
|
||||||
for _, chain := range c.Chains() {
|
for _, chain := range c.ProviderChains() {
|
||||||
if chain == pp.Name() {
|
if chain == pp.Name() {
|
||||||
_ = c.Close()
|
_ = c.Close()
|
||||||
break
|
break
|
||||||
|
|||||||
@ -59,6 +59,7 @@ var ErrNotSupport = errors.New("no support")
|
|||||||
|
|
||||||
type Connection interface {
|
type Connection interface {
|
||||||
Chains() Chain
|
Chains() Chain
|
||||||
|
ProviderChains() Chain
|
||||||
AppendToChains(adapter ProxyAdapter)
|
AppendToChains(adapter ProxyAdapter)
|
||||||
RemoteDestination() string
|
RemoteDestination() string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ type TrackerInfo struct {
|
|||||||
DownloadTotal atomic.Int64 `json:"download"`
|
DownloadTotal atomic.Int64 `json:"download"`
|
||||||
Start time.Time `json:"start"`
|
Start time.Time `json:"start"`
|
||||||
Chain C.Chain `json:"chains"`
|
Chain C.Chain `json:"chains"`
|
||||||
|
ProviderChain C.Chain `json:"providerChains"`
|
||||||
Rule string `json:"rule"`
|
Rule string `json:"rule"`
|
||||||
RulePayload string `json:"rulePayload"`
|
RulePayload string `json:"rulePayload"`
|
||||||
}
|
}
|
||||||
@ -126,6 +127,7 @@ func NewTCPTracker(conn C.Conn, manager *Manager, metadata *C.Metadata, rule C.R
|
|||||||
Start: time.Now(),
|
Start: time.Now(),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
Chain: conn.Chains(),
|
Chain: conn.Chains(),
|
||||||
|
ProviderChain: conn.ProviderChains(),
|
||||||
Rule: "",
|
Rule: "",
|
||||||
UploadTotal: atomic.NewInt64(uploadTotal),
|
UploadTotal: atomic.NewInt64(uploadTotal),
|
||||||
DownloadTotal: atomic.NewInt64(downloadTotal),
|
DownloadTotal: atomic.NewInt64(downloadTotal),
|
||||||
@ -217,6 +219,7 @@ func NewUDPTracker(conn C.PacketConn, manager *Manager, metadata *C.Metadata, ru
|
|||||||
Start: time.Now(),
|
Start: time.Now(),
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
Chain: conn.Chains(),
|
Chain: conn.Chains(),
|
||||||
|
ProviderChain: conn.ProviderChains(),
|
||||||
Rule: "",
|
Rule: "",
|
||||||
UploadTotal: atomic.NewInt64(uploadTotal),
|
UploadTotal: atomic.NewInt64(uploadTotal),
|
||||||
DownloadTotal: atomic.NewInt64(downloadTotal),
|
DownloadTotal: atomic.NewInt64(downloadTotal),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user