fixed windows build and build windows version

This commit is contained in:
duffyduck 2026-02-19 07:13:05 +01:00
parent cfc8a42417
commit 1c4ebddd05
5 changed files with 68 additions and 0 deletions

Binary file not shown.

BIN
bin/usb-client.exe Executable file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,47 @@
//go:build windows
package usbip
import (
"fmt"
"io"
"github.com/duffy/usb-server/internal/usb"
)
// Server is a stub on Windows - USB/IP server requires Linux usbdevfs.
type Server struct{}
func NewServer(dev *usb.Device) *Server {
return &Server{}
}
func (s *Server) Attach() error {
return fmt.Errorf("USB/IP server not supported on Windows")
}
func (s *Server) Detach() {}
func (s *Server) BuildDeviceDescriptor() DeviceDescriptor {
return DeviceDescriptor{}
}
func (s *Server) BuildInterfaceDescriptors() []InterfaceDescriptor {
return nil
}
func (s *Server) HandleConnection(r io.Reader, w io.Writer) error {
return fmt.Errorf("USB/IP server not supported on Windows")
}
func (s *Server) HandleDevlistRequest() ([]byte, error) {
return nil, fmt.Errorf("USB/IP server not supported on Windows")
}
func (s *Server) HandleImportRequest(requestedBusID string) ([]byte, error) {
return nil, fmt.Errorf("USB/IP server not supported on Windows")
}
func (s *Server) ReadManagementRequest(r io.Reader) (response []byte, startTransfer bool, err error) {
return nil, false, fmt.Errorf("USB/IP server not supported on Windows")
}

View File

@ -0,0 +1,21 @@
//go:build windows
package usbip
import "fmt"
func IsVHCIAvailable() bool {
return false
}
func FindFreePort(speed uint32) (int, error) {
return -1, fmt.Errorf("VHCI not supported on Windows")
}
func AttachDevice(port int, sockfd int, devID uint32, speed uint32) error {
return fmt.Errorf("VHCI not supported on Windows")
}
func DetachDevice(port int) error {
return fmt.Errorf("VHCI not supported on Windows")
}