mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-21 16:11:32 +00:00
platform: Improve status
This commit is contained in:
parent
c40140bbae
commit
59987747e5
|
@ -7,7 +7,7 @@ const (
|
|||
TypeDirect = "direct"
|
||||
TypeBlock = "block"
|
||||
TypeDNS = "dns"
|
||||
TypeSocks = "socks"
|
||||
TypeSOCKS = "socks"
|
||||
TypeHTTP = "http"
|
||||
TypeMixed = "mixed"
|
||||
TypeShadowsocks = "shadowsocks"
|
||||
|
@ -27,3 +27,46 @@ const (
|
|||
TypeSelector = "selector"
|
||||
TypeURLTest = "urltest"
|
||||
)
|
||||
|
||||
func ProxyDisplayName(proxyType string) string {
|
||||
switch proxyType {
|
||||
case TypeDirect:
|
||||
return "Direct"
|
||||
case TypeBlock:
|
||||
return "Block"
|
||||
case TypeDNS:
|
||||
return "DNS"
|
||||
case TypeSOCKS:
|
||||
return "SOCKS"
|
||||
case TypeHTTP:
|
||||
return "HTTP"
|
||||
case TypeShadowsocks:
|
||||
return "Shadowsocks"
|
||||
case TypeVMess:
|
||||
return "VMess"
|
||||
case TypeTrojan:
|
||||
return "Trojan"
|
||||
case TypeNaive:
|
||||
return "Naive"
|
||||
case TypeWireGuard:
|
||||
return "WireGuard"
|
||||
case TypeHysteria:
|
||||
return "Hysteria"
|
||||
case TypeTor:
|
||||
return "Tor"
|
||||
case TypeSSH:
|
||||
return "SSH"
|
||||
case TypeShadowTLS:
|
||||
return "ShadowTLS"
|
||||
case TypeShadowsocksR:
|
||||
return "ShadowsocksR"
|
||||
case TypeVLESS:
|
||||
return "VLESS"
|
||||
case TypeSelector:
|
||||
return "Selector"
|
||||
case TypeURLTest:
|
||||
return "URLTest"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,38 +63,10 @@ func proxyInfo(server *Server, detour adapter.Outbound) *badjson.JSONObject {
|
|||
var info badjson.JSONObject
|
||||
var clashType string
|
||||
switch detour.Type() {
|
||||
case C.TypeDirect:
|
||||
clashType = "Direct"
|
||||
case C.TypeBlock:
|
||||
clashType = "Reject"
|
||||
case C.TypeSocks:
|
||||
clashType = "Socks"
|
||||
case C.TypeHTTP:
|
||||
clashType = "HTTP"
|
||||
case C.TypeShadowsocks:
|
||||
clashType = "Shadowsocks"
|
||||
case C.TypeVMess:
|
||||
clashType = "VMess"
|
||||
case C.TypeTrojan:
|
||||
clashType = "Trojan"
|
||||
case C.TypeHysteria:
|
||||
clashType = "Hysteria"
|
||||
case C.TypeWireGuard:
|
||||
clashType = "WireGuard"
|
||||
case C.TypeShadowsocksR:
|
||||
clashType = "ShadowsocksR"
|
||||
case C.TypeVLESS:
|
||||
clashType = "VLESS"
|
||||
case C.TypeTor:
|
||||
clashType = "Tor"
|
||||
case C.TypeSSH:
|
||||
clashType = "SSH"
|
||||
case C.TypeSelector:
|
||||
clashType = "Selector"
|
||||
case C.TypeURLTest:
|
||||
clashType = "URLTest"
|
||||
default:
|
||||
clashType = "Direct"
|
||||
clashType = C.ProxyDisplayName(detour.Type())
|
||||
}
|
||||
info.Put("type", clashType)
|
||||
info.Put("name", detour.Tag())
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/binary"
|
||||
"io"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/common/urltest"
|
||||
|
@ -71,6 +72,11 @@ func (s *CommandServer) handleGroupConn(conn net.Conn) error {
|
|||
}
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-time.After(2 * time.Second):
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-s.urlTestUpdate:
|
||||
|
|
|
@ -48,3 +48,7 @@ func Version() string {
|
|||
func FormatBytes(length int64) string {
|
||||
return humanize.IBytes(uint64(length))
|
||||
}
|
||||
|
||||
func ProxyDisplayType(proxyType string) string {
|
||||
return C.ProxyDisplayName(proxyType)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ func New(ctx context.Context, router adapter.Router, logger log.ContextLogger, o
|
|||
return NewTProxy(ctx, router, logger, options.Tag, options.TProxyOptions), nil
|
||||
case C.TypeDirect:
|
||||
return NewDirect(ctx, router, logger, options.Tag, options.DirectOptions), nil
|
||||
case C.TypeSocks:
|
||||
case C.TypeSOCKS:
|
||||
return NewSocks(ctx, router, logger, options.Tag, options.SocksOptions), nil
|
||||
case C.TypeHTTP:
|
||||
return NewHTTP(ctx, router, logger, options.Tag, options.HTTPOptions)
|
||||
|
|
|
@ -27,7 +27,7 @@ type Socks struct {
|
|||
func NewSocks(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.SocksInboundOptions) *Socks {
|
||||
inbound := &Socks{
|
||||
myInboundAdapter{
|
||||
protocol: C.TypeSocks,
|
||||
protocol: C.TypeSOCKS,
|
||||
network: []string{N.NetworkTCP},
|
||||
ctx: ctx,
|
||||
router: router,
|
||||
|
|
|
@ -38,7 +38,7 @@ func (h Inbound) MarshalJSON() ([]byte, error) {
|
|||
v = h.TProxyOptions
|
||||
case C.TypeDirect:
|
||||
v = h.DirectOptions
|
||||
case C.TypeSocks:
|
||||
case C.TypeSOCKS:
|
||||
v = h.SocksOptions
|
||||
case C.TypeHTTP:
|
||||
v = h.HTTPOptions
|
||||
|
@ -79,7 +79,7 @@ func (h *Inbound) UnmarshalJSON(bytes []byte) error {
|
|||
v = &h.TProxyOptions
|
||||
case C.TypeDirect:
|
||||
v = &h.DirectOptions
|
||||
case C.TypeSocks:
|
||||
case C.TypeSOCKS:
|
||||
v = &h.SocksOptions
|
||||
case C.TypeHTTP:
|
||||
v = &h.HTTPOptions
|
||||
|
|
|
@ -36,7 +36,7 @@ func (h Outbound) MarshalJSON() ([]byte, error) {
|
|||
v = h.DirectOptions
|
||||
case C.TypeBlock, C.TypeDNS:
|
||||
v = nil
|
||||
case C.TypeSocks:
|
||||
case C.TypeSOCKS:
|
||||
v = h.SocksOptions
|
||||
case C.TypeHTTP:
|
||||
v = h.HTTPOptions
|
||||
|
@ -81,7 +81,7 @@ func (h *Outbound) UnmarshalJSON(bytes []byte) error {
|
|||
v = &h.DirectOptions
|
||||
case C.TypeBlock, C.TypeDNS:
|
||||
v = nil
|
||||
case C.TypeSocks:
|
||||
case C.TypeSOCKS:
|
||||
v = &h.SocksOptions
|
||||
case C.TypeHTTP:
|
||||
v = &h.HTTPOptions
|
||||
|
|
|
@ -27,7 +27,7 @@ func New(ctx context.Context, router adapter.Router, logger log.ContextLogger, t
|
|||
return NewBlock(logger, tag), nil
|
||||
case C.TypeDNS:
|
||||
return NewDNS(router, tag), nil
|
||||
case C.TypeSocks:
|
||||
case C.TypeSOCKS:
|
||||
return NewSocks(router, logger, tag, options.SocksOptions)
|
||||
case C.TypeHTTP:
|
||||
return NewHTTP(router, logger, tag, options.HTTPOptions)
|
||||
|
|
|
@ -39,7 +39,7 @@ func NewSocks(router adapter.Router, logger log.ContextLogger, tag string, optio
|
|||
}
|
||||
outbound := &Socks{
|
||||
myOutboundAdapter: myOutboundAdapter{
|
||||
protocol: C.TypeSocks,
|
||||
protocol: C.TypeSOCKS,
|
||||
network: options.Network.Build(),
|
||||
router: router,
|
||||
logger: logger,
|
||||
|
|
|
@ -491,7 +491,7 @@ func testVLESSXrayInbound(t *testing.T, flow string) {
|
|||
},
|
||||
},
|
||||
{
|
||||
Type: C.TypeSocks,
|
||||
Type: C.TypeSOCKS,
|
||||
Tag: "vless-out",
|
||||
SocksOptions: option.SocksOutboundOptions{
|
||||
ServerOptions: option.ServerOptions{
|
||||
|
|
Loading…
Reference in a new issue