Add USB/IP service

This commit is contained in:
世界
2026-06-14 19:19:46 +08:00
parent 12f160ab5f
commit 7cffd47dd4
30 changed files with 3117 additions and 246 deletions
+1
View File
@@ -143,6 +143,7 @@ func ServiceRegistry() *service.Registry {
registerCCMService(registry)
registerOCMService(registry)
registerOOMKillerService(registry)
registerUSBIPServices(registry)
return registry
}
+12
View File
@@ -0,0 +1,12 @@
//go:build with_usbip && (linux || (darwin && cgo) || windows)
package include
import (
"github.com/sagernet/sing-box/adapter/service"
"github.com/sagernet/sing-box/service/usbip"
)
func registerUSBIPServices(registry *service.Registry) {
usbip.RegisterService(registry)
}
+23
View File
@@ -0,0 +1,23 @@
//go:build !with_usbip || !(linux || (darwin && cgo) || windows)
package include
import (
"context"
"github.com/sagernet/sing-box/adapter"
"github.com/sagernet/sing-box/adapter/service"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
E "github.com/sagernet/sing/common/exceptions"
)
func registerUSBIPServices(registry *service.Registry) {
service.Register[option.USBIPServerServiceOptions](registry, C.TypeUSBIPServer, func(ctx context.Context, logger log.ContextLogger, tag string, options option.USBIPServerServiceOptions) (adapter.Service, error) {
return nil, E.New(`USB/IP is not included in this build, rebuild with -tags with_usbip (supported on Linux, Windows, and macOS with CGO)`)
})
service.Register[option.USBIPClientServiceOptions](registry, C.TypeUSBIPClient, func(ctx context.Context, logger log.ContextLogger, tag string, options option.USBIPClientServiceOptions) (adapter.Service, error) {
return nil, E.New(`USB/IP is not included in this build, rebuild with -tags with_usbip (supported on Linux, Windows, and macOS with CGO)`)
})
}