Remove urltest outbound

This commit is contained in:
世界
2022-07-28 16:36:31 +08:00
parent c240f1b359
commit c0a2f77258
14 changed files with 20 additions and 324 deletions

View File

@@ -77,16 +77,13 @@ func proxyInfo(server *Server, detour adapter.Outbound) *badjson.JSONObject {
case C.TypeSelector:
clashType = "Selector"
isGroup = true
case C.TypeURLTest:
clashType = "URLTest"
isGroup = true
default:
clashType = "Unknown"
}
info.Put("type", clashType)
info.Put("name", detour.Tag())
info.Put("udp", common.Contains(detour.Network(), C.NetworkUDP))
delayHistory := server.router.URLTestHistoryStorage(false).LoadURLTestHistory(outbound.RealTag(detour))
delayHistory := server.urlTestHistory.LoadURLTestHistory(adapter.OutboundTag(detour))
if delayHistory != nil {
info.Put("history", []*urltest.History{delayHistory})
} else {
@@ -218,9 +215,9 @@ func getProxyDelay(server *Server) func(w http.ResponseWriter, r *http.Request)
defer func() {
realTag := outbound.RealTag(proxy)
if err != nil {
server.router.URLTestHistoryStorage(true).DeleteURLTestHistory(realTag)
server.urlTestHistory.DeleteURLTestHistory(realTag)
} else {
server.router.URLTestHistoryStorage(true).StoreURLTestHistory(realTag, &urltest.History{
server.urlTestHistory.StoreURLTestHistory(realTag, &urltest.History{
Time: time.Now(),
Delay: delay,
})

View File

@@ -12,6 +12,7 @@ import (
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/common/json"
"github.com/sagernet/sing-box/common/urltest"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/experimental/clashapi/trafficontrol"
"github.com/sagernet/sing-box/log"
@@ -33,6 +34,7 @@ type Server struct {
logger log.Logger
httpServer *http.Server
trafficManager *trafficontrol.Manager
urlTestHistory *urltest.HistoryStorage
}
func NewServer(router adapter.Router, logFactory log.ObservableFactory, options option.ClashAPIOptions) *Server {
@@ -46,6 +48,7 @@ func NewServer(router adapter.Router, logFactory log.ObservableFactory, options
Handler: chiRouter,
},
trafficManager,
urltest.NewHistoryStorage(),
}
cors := cors.New(cors.Options{
AllowedOrigins: []string{"*"},