Add direct io option for clash api

This commit is contained in:
世界
2022-09-26 15:31:02 +08:00
parent b5564ef3d3
commit 7f9c870bba
5 changed files with 157 additions and 51 deletions

View File

@@ -38,6 +38,7 @@ type Server struct {
trafficManager *trafficontrol.Manager
urlTestHistory *urltest.HistoryStorage
tcpListener net.Listener
directIO bool
mode string
storeSelected bool
cacheFile adapter.ClashCacheFile
@@ -55,6 +56,7 @@ func NewServer(router adapter.Router, logFactory log.ObservableFactory, options
},
trafficManager: trafficManager,
urlTestHistory: urltest.NewHistoryStorage(),
directIO: options.DirectIO,
mode: strings.ToLower(options.DefaultMode),
}
if server.mode == "" {
@@ -149,7 +151,7 @@ func (s *Server) HistoryStorage() *urltest.HistoryStorage {
}
func (s *Server) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule) (net.Conn, adapter.Tracker) {
tracker := trafficontrol.NewTCPTracker(conn, s.trafficManager, castMetadata(metadata), s.router, matchedRule)
tracker := trafficontrol.NewTCPTracker(conn, s.trafficManager, castMetadata(metadata), s.router, matchedRule, s.directIO)
return tracker, tracker
}