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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user