usbip: gate serverImportLease so unsupported-target builds compile

control_protocol.go was ungated but referenced ExportLeaseIdentity
from host.go (linux || (darwin && cgo)), breaking the stub-register
contract on Windows and darwin && !cgo. Move serverImportLease and
importLeaseTTL into export_ledger.go alongside their only consumers.
This commit is contained in:
世界
2026-05-16 11:32:24 +08:00
parent a438f6212b
commit f5d5a7f647
2 changed files with 14 additions and 14 deletions
-13
View File
@@ -6,7 +6,6 @@ import (
"io"
"slices"
"strings"
"time"
E "github.com/sagernet/sing/common/exceptions"
)
@@ -47,8 +46,6 @@ const (
leaseErrorBadRequest = "bad_request"
leaseErrorUnavailable = "unavailable"
leaseErrorBusy = "busy"
importLeaseTTL = 10 * time.Second
)
var controlPreface = [controlPrefaceSize]byte{'S', 'B', 'U', 'S', 'B', 'I', 'P', '1'}
@@ -121,16 +118,6 @@ type controlLeaseResponse struct {
ErrorMessage string `json:"error_message,omitempty"`
}
type serverImportLease struct {
ID uint64
SubscriberID uint64
BusID string
ClientNonce uint64
Generation uint64
Identity ExportLeaseIdentity
Expires time.Time
}
// controlReader reuses its payload scratch across successive reads on a
// single connection. The returned payload is only valid until the next call.
type controlReader struct {
+14 -1
View File
@@ -45,7 +45,20 @@ type exportSubscriber struct {
send chan controlMessage
}
const controlSubscriberSendBuffer = 16
type serverImportLease struct {
ID uint64
SubscriberID uint64
BusID string
ClientNonce uint64
Generation uint64
Identity ExportLeaseIdentity
Expires time.Time
}
const (
controlSubscriberSendBuffer = 16
importLeaseTTL = 10 * time.Second
)
func newExportLedger(logger log.ContextLogger, ttl time.Duration, now func() time.Time) *exportLedger {
if now == nil {