Update to 2.0.23 release.

This commit is contained in:
Alex Dupre 2018-09-24 12:15:09 +00:00
parent 0d65439b66
commit 2ef74c87f7
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=480603
4 changed files with 10 additions and 205 deletions

View file

@ -2,7 +2,7 @@
# $FreeBSD$
PORTNAME= trezord
PORTVERSION= 2.0.21
PORTVERSION= 2.0.23
DISTVERSIONPREFIX= v
CATEGORIES= security
@ -18,8 +18,7 @@ USE_GITHUB= yes
GH_ACCOUNT= trezor
GH_PROJECT= ${PORTNAME}-go
GO_PKGNAME= github.com/${GH_ACCOUNT}/${GH_PROJECT}
PATCH_STRIP= -p1
GH_TAGNAME= 0e82873
PLIST_FILES= bin/${GH_PROJECT}

View file

@ -1,3 +1,3 @@
TIMESTAMP = 1535444563
SHA256 (trezor-trezord-go-v2.0.21_GH0.tar.gz) = e8987e2f998555d354297d0c00a79f0f3eb8343cff8e96241646638d7350f52a
SIZE (trezor-trezord-go-v2.0.21_GH0.tar.gz) = 953365
TIMESTAMP = 1537790982
SHA256 (trezor-trezord-go-v2.0.23-0e82873_GH0.tar.gz) = 87f359982952429d4f8303966ce750985fb1be484e3ee22ed636594b0dcc4345
SIZE (trezor-trezord-go-v2.0.23-0e82873_GH0.tar.gz) = 954886

View file

@ -1,8 +1,6 @@
diff --git a/usb/webusb.go b/usb/webusb.go
index eb8cadd..1366074 100644
--- a/usb/webusb.go
+++ b/usb/webusb.go
@@ -226,13 +232,21 @@ func (b *WebUSB) matchVidPid(vid uint16, pid uint16) bool {
--- usb/webusb.go.orig 2018-09-21 13:31:27 UTC
+++ usb/webusb.go
@@ -274,13 +274,21 @@ func (b *WebUSB) matchVidPid(vid uint16,
}
func (b *WebUSB) identify(dev lowlevel.Device) string {
@ -30,7 +28,7 @@ index eb8cadd..1366074 100644
}
type WUD struct {
@@ -279,6 +293,12 @@ func (d *WUD) finishReadQueue() {
@@ -331,6 +339,12 @@ func (d *WUD) finishReadQueue() {
}
func (d *WUD) readWrite(buf []byte, endpoint uint8) (int, error) {
@ -43,7 +41,7 @@ index eb8cadd..1366074 100644
d.mw.Println("webusb - rw - start")
for {
d.mw.Println("webusb - rw - checking closed")
@@ -291,7 +311,7 @@ func (d *WUD) readWrite(buf []byte, endpoint uint8) (int, error) {
@@ -343,7 +357,7 @@ func (d *WUD) readWrite(buf []byte, endp
d.mw.Println("webusb - rw - lock transfer mutex")
d.transferMutex.Lock()
d.mw.Println("webusb - rw - actual interrupt transport")

View file

@ -1,192 +0,0 @@
diff --git a/trezord.go b/trezord.go
index 91fb4b9..f8c545e 100644
--- a/trezord.go
+++ b/trezord.go
@@ -6,6 +6,7 @@ import (
"io"
"log"
"os"
+ "runtime"
"strconv"
"github.com/trezor/trezord-go/core"
@@ -83,7 +84,11 @@ func main() {
if err != nil {
stderrLogger.Fatalf("hidapi: %s", err)
}
- bus = append(bus, w, h)
+ if runtime.GOOS != "freebsd" {
+ bus = append(bus, w, h)
+ } else {
+ bus = append(bus, w)
+ }
}
longMemoryWriter.Println(fmt.Sprintf("UDP port count - %d", len(ports)))
diff --git a/usb/lowlevel/hid.go b/usb/lowlevel/hid.go
index 32ad167..c847c73 100644
--- a/usb/lowlevel/hid.go
+++ b/usb/lowlevel/hid.go
@@ -6,7 +6,7 @@
// Package hid provides an interface for USB HID devices.
-// +build linux,cgo darwin,!ios,cgo windows,cgo
+// +build linux,cgo freebsd,cgo darwin,!ios,cgo windows,cgo
package lowlevel
@@ -21,6 +21,8 @@ extern void goLog(const char *s);
#cgo linux CFLAGS: -DDEFAULT_VISIBILITY="" -DOS_LINUX -D_GNU_SOURCE -DPOLL_NFDS_TYPE=int
#cgo linux,!android LDFLAGS: -lrt
+#cgo freebsd CFLAGS: -DOS_FREEBSD
+#cgo freebsd LDFLAGS: -lusb
#cgo darwin CFLAGS: -DOS_DARWIN -DDEFAULT_VISIBILITY="" -DPOLL_NFDS_TYPE="unsigned int"
#cgo darwin LDFLAGS: -framework CoreFoundation -framework IOKit -lobjc
#cgo windows CFLAGS: -DOS_WINDOWS -DDEFAULT_VISIBILITY="" -DPOLL_NFDS_TYPE="unsigned int"
@@ -34,6 +36,8 @@ extern void goLog(const char *s);
#include "os/poll_posix.c"
#include "os/linux_usbfs.c"
#include "os/linux_netlink.c"
+#elif OS_FREEBSD
+ #include <stdlib.h>
#elif OS_DARWIN
#include <sys/poll.h>
@@ -50,15 +54,21 @@ extern void goLog(const char *s);
#include "os/threads_windows.c"
#endif
-#include "core.c"
-#include "descriptor.c"
-#include "hotplug.c"
-#include "io.c"
-#include "strerror.c"
-#include "sync.c"
+#ifndef OS_FREEBSD
+ #include "core.c"
+ #include "descriptor.c"
+ #include "hotplug.c"
+ #include "io.c"
+ #include "strerror.c"
+ #include "sync.c"
+#else
+ #include <libusb.h>
+#endif
#ifdef OS_LINUX
#include "linux/hid.c"
+#elif OS_FREEBSD
+ #include "linux/hid.c"
#elif OS_DARWIN
#include "mac/hid.c"
#elif OS_WINDOWS
diff --git a/usb/lowlevel/libusb.go b/usb/lowlevel/libusb.go
index 454c95c..acda2c6 100644
--- a/usb/lowlevel/libusb.go
+++ b/usb/lowlevel/libusb.go
@@ -1,4 +1,4 @@
-// +build linux,cgo darwin,!ios,cgo windows,cgo
+// +build linux,cgo freebsd,cgo darwin,!ios,cgo windows,cgo
//-----------------------------------------------------------------------------
/*
@@ -14,7 +14,13 @@ Copyright (c) 2017 Jason T. Harris
package lowlevel
/*
+#cgo freebsd LDFLAGS: -lusb
+
+#ifndef __FreeBSD__
#include "./c/libusb/libusb.h"
+#else
+#include <libusb.h>
+#endif
// When a C struct ends with a zero-sized field, but the struct itself is not zero-sized,
// Go code can no longer refer to the zero-sized field. Any such references will have to be rewritten.
@@ -921,9 +927,11 @@ func Get_Port_Numbers(dev Device, ports []byte) ([]byte, error) {
return ports[:rc], nil
}
+/*
func Get_Parent(dev Device) Device {
return C.libusb_get_parent(dev)
}
+*/
func Get_Device_Address(dev Device) uint8 {
return uint8(C.libusb_get_device_address(dev))
@@ -1066,10 +1074,12 @@ func Set_Auto_Detach_Kernel_Driver(hdl Device_Handle, enable bool) error {
//-----------------------------------------------------------------------------
// Miscellaneous
+/*
func Has_Capability(capability uint32) bool {
rc := int(C.libusb_has_capability((C.uint32_t)(capability)))
return rc != 0
}
+*/
func Error_Name(code int) string {
return C.GoString(C.libusb_error_name(C.int(code)))
@@ -1084,6 +1094,7 @@ func CPU_To_LE16(x uint16) uint16 {
return uint16(C.libusb_cpu_to_le16((C.uint16_t)(x)))
}
+/*
func Setlocale(locale string) error {
cstr := C.CString(locale)
rc := int(C.libusb_setlocale(cstr))
@@ -1092,6 +1103,7 @@ func Setlocale(locale string) error {
}
return nil
}
+*/
func Strerror(errcode int) string {
return C.GoString(C.libusb_strerror(int32(errcode)))
diff --git a/usb/lowlevel/wchar.go b/usb/lowlevel/wchar.go
index a85a143..8448510 100644
--- a/usb/lowlevel/wchar.go
+++ b/usb/lowlevel/wchar.go
@@ -7,7 +7,7 @@
// https://github.com/orofarne/gowchar/blob/master/LICENSE
// +build !ios
-// +build linux darwin windows
+// +build linux freebsd darwin windows
package lowlevel
diff --git a/usb/webusb.go b/usb/webusb.go
index eb8cadd..1366074 100644
--- a/usb/webusb.go
+++ b/usb/webusb.go
@@ -3,6 +3,7 @@ package usb
import (
"encoding/hex"
"fmt"
+ "runtime"
"strings"
"sync"
"sync/atomic"
@@ -214,9 +215,14 @@ func (b *WebUSB) match(dev lowlevel.Device) bool {
b.mw.Println("webusb - match - error getting config descriptor " + err.Error())
return false
}
- return (c.BNumInterfaces > webIfaceNum &&
- c.Interface[webIfaceNum].Num_altsetting > webAltSetting &&
- c.Interface[webIfaceNum].Altsetting[webAltSetting].BInterfaceClass == lowlevel.CLASS_VENDOR_SPEC)
+ if runtime.GOOS != "freebsd" {
+ return (c.BNumInterfaces > webIfaceNum &&
+ c.Interface[webIfaceNum].Num_altsetting > webAltSetting &&
+ c.Interface[webIfaceNum].Altsetting[webAltSetting].BInterfaceClass == lowlevel.CLASS_VENDOR_SPEC)
+ } else {
+ return (c.BNumInterfaces > webIfaceNum &&
+ c.Interface[webIfaceNum].Num_altsetting > webAltSetting)
+ }
}
func (b *WebUSB) matchVidPid(vid uint16, pid uint16) bool {