mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-22 15:47:59 +08:00
chore: restful api displays more information
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 11s
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 11s
This commit is contained in:
parent
462343531e
commit
eb985b002e
@ -163,10 +163,14 @@ func (p *Proxy) MarshalJSON() ([]byte, error) {
|
||||
mapping["alive"] = p.alive.Load()
|
||||
mapping["name"] = p.Name()
|
||||
mapping["udp"] = p.SupportUDP()
|
||||
mapping["uot"] = p.SupportUOT()
|
||||
mapping["xudp"] = p.SupportXUDP()
|
||||
mapping["tfo"] = p.SupportTFO()
|
||||
mapping["mptcp"] = p.SupportMPTCP()
|
||||
mapping["smux"] = p.SupportSMUX()
|
||||
mapping["interface"] = p.SupportInterface()
|
||||
mapping["dialer-proxy"] = p.SupportDialerProxy()
|
||||
mapping["routing-mark"] = p.SupportRoutingMark()
|
||||
return json.Marshal(mapping)
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,18 @@ func (b *Base) SupportSMUX() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *Base) SupportDialerProxy() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (b *Base) SupportInterface() string {
|
||||
return b.iface
|
||||
}
|
||||
|
||||
func (b *Base) SupportRoutingMark() int {
|
||||
return b.rmark
|
||||
}
|
||||
|
||||
// IsL3Protocol implements C.ProxyAdapter
|
||||
func (b *Base) IsL3Protocol(metadata *C.Metadata) bool {
|
||||
return false
|
||||
|
@ -92,6 +92,11 @@ func (h *Http) SupportWithDialer() C.NetWork {
|
||||
return C.TCP
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (h *Http) SupportDialerProxy() string {
|
||||
return h.option.DialerProxy
|
||||
}
|
||||
|
||||
func (h *Http) shakeHand(metadata *C.Metadata, rw io.ReadWriter) error {
|
||||
addr := metadata.RemoteAddress()
|
||||
HeaderString := "CONNECT " + addr + " HTTP/1.1\r\n"
|
||||
|
@ -87,6 +87,11 @@ func (h *Hysteria) genHdc(ctx context.Context, opts ...dialer.Option) utils.Pack
|
||||
}
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (h *Hysteria) SupportDialerProxy() string {
|
||||
return h.option.DialerProxy
|
||||
}
|
||||
|
||||
type HysteriaOption struct {
|
||||
BasicOption
|
||||
Name string `proxy:"name"`
|
||||
|
@ -96,6 +96,11 @@ func closeHysteria2(h *Hysteria2) {
|
||||
}
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (h *Hysteria2) SupportDialerProxy() string {
|
||||
return h.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewHysteria2(option Hysteria2Option) (*Hysteria2, error) {
|
||||
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
||||
var salamanderPassword string
|
||||
|
@ -196,6 +196,11 @@ func (ss *ShadowSocks) SupportWithDialer() C.NetWork {
|
||||
return C.ALLNet
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (ss *ShadowSocks) SupportDialerProxy() string {
|
||||
return ss.option.DialerProxy
|
||||
}
|
||||
|
||||
// ListenPacketOnStreamConn implements C.ProxyAdapter
|
||||
func (ss *ShadowSocks) ListenPacketOnStreamConn(ctx context.Context, c net.Conn, metadata *C.Metadata) (_ C.PacketConn, err error) {
|
||||
if ss.option.UDPOverTCP {
|
||||
|
@ -122,6 +122,11 @@ func (ssr *ShadowSocksR) SupportWithDialer() C.NetWork {
|
||||
return C.ALLNet
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (ssr *ShadowSocksR) SupportDialerProxy() string {
|
||||
return ssr.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewShadowSocksR(option ShadowSocksROption) (*ShadowSocksR, error) {
|
||||
// SSR protocol compatibility
|
||||
// https://github.com/metacubex/mihomo/pull/2056
|
||||
|
@ -141,6 +141,11 @@ func (s *Snell) SupportUOT() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (s *Snell) SupportDialerProxy() string {
|
||||
return s.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewSnell(option SnellOption) (*Snell, error) {
|
||||
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
||||
psk := []byte(option.Psk)
|
||||
@ -204,7 +209,7 @@ func NewSnell(option SnellOption) (*Snell, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return streamConn(c, streamOption{psk, option.Version, addr, obfsOption}), nil
|
||||
})
|
||||
}
|
||||
|
@ -171,6 +171,11 @@ func (ss *Socks5) ListenPacketContext(ctx context.Context, metadata *C.Metadata,
|
||||
return newPacketConn(&socksPacketConn{PacketConn: pc, rAddr: bindUDPAddr, tcpConn: c}, ss), nil
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (ss *Socks5) SupportDialerProxy() string {
|
||||
return ss.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewSocks5(option Socks5Option) (*Socks5, error) {
|
||||
var tlsConfig *tls.Config
|
||||
if option.TLS {
|
||||
|
@ -121,6 +121,11 @@ func closeSsh(s *Ssh) {
|
||||
_ = s.client.Close()
|
||||
}
|
||||
|
||||
// SupportWithDialer implements C.ProxyAdapter
|
||||
func (s *Ssh) SupportDialerProxy() string {
|
||||
return s.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewSsh(option SshOption) (*Ssh, error) {
|
||||
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
||||
|
||||
|
@ -244,6 +244,11 @@ func (t *Trojan) SupportUOT() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (t *Trojan) SupportDialerProxy() string {
|
||||
return t.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewTrojan(option TrojanOption) (*Trojan, error) {
|
||||
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
||||
|
||||
|
@ -146,6 +146,11 @@ func (t *Tuic) dialWithDialer(ctx context.Context, dialer C.Dialer) (transport *
|
||||
return
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (t *Tuic) SupportDialerProxy() string {
|
||||
return t.option.DialerProxy
|
||||
}
|
||||
|
||||
func NewTuic(option TuicOption) (*Tuic, error) {
|
||||
addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port))
|
||||
serverName := option.Server
|
||||
|
@ -379,6 +379,11 @@ func (v *Vless) SupportUOT() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// SupportDialerProxy implements C.ProxyAdapter
|
||||
func (v *Vless) SupportDialerProxy() string {
|
||||
return v.option.DialerProxy
|
||||
}
|
||||
|
||||
func parseVlessAddr(metadata *C.Metadata, xudp bool) *vless.DstAddr {
|
||||
var addrType byte
|
||||
var addr []byte
|
||||
|
@ -388,6 +388,10 @@ func (v *Vmess) SupportWithDialer() C.NetWork {
|
||||
return C.ALLNet
|
||||
}
|
||||
|
||||
func (v *Vmess) SupportDialerProxy() string {
|
||||
return v.option.DialerProxy
|
||||
}
|
||||
|
||||
// ListenPacketOnStreamConn implements C.ProxyAdapter
|
||||
func (v *Vmess) ListenPacketOnStreamConn(ctx context.Context, c net.Conn, metadata *C.Metadata) (_ C.PacketConn, err error) {
|
||||
// vmess use stream-oriented udp with a special address, so we need a net.UDPAddr
|
||||
|
@ -674,6 +674,27 @@ func (r *refProxyAdapter) SupportUOT() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *refProxyAdapter) SupportDialerProxy() string {
|
||||
if r.proxyAdapter != nil {
|
||||
return r.proxyAdapter.SupportDialerProxy()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (r *refProxyAdapter) SupportInterface() string {
|
||||
if r.proxyAdapter != nil {
|
||||
return r.proxyAdapter.SupportInterface()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (r *refProxyAdapter) SupportRoutingMark() int {
|
||||
if r.proxyAdapter != nil {
|
||||
return r.proxyAdapter.SupportRoutingMark()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (r *refProxyAdapter) SupportWithDialer() C.NetWork {
|
||||
if r.proxyAdapter != nil {
|
||||
return r.proxyAdapter.SupportWithDialer()
|
||||
|
@ -108,6 +108,9 @@ type ProxyAdapter interface {
|
||||
SupportTFO() bool
|
||||
SupportMPTCP() bool
|
||||
SupportSMUX() bool
|
||||
SupportInterface() string
|
||||
SupportRoutingMark() int
|
||||
SupportDialerProxy() string
|
||||
MarshalJSON() ([]byte, error)
|
||||
|
||||
// Deprecated: use DialContextWithDialer and ListenPacketWithDialer instead.
|
||||
|
Loading…
Reference in New Issue
Block a user