mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-04 15:57:44 +00:00
Update direct dependencies where possible
This commit is contained in:
4
vendor/github.com/rs/xid/hostid_darwin.go
generated
vendored
4
vendor/github.com/rs/xid/hostid_darwin.go
generated
vendored
@ -2,8 +2,8 @@
|
||||
|
||||
package xid
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import "syscall"
|
||||
|
||||
func readPlatformMachineID() (string, error) {
|
||||
return unix.Sysctl("kern.uuid")
|
||||
return syscall.Sysctl("kern.uuid")
|
||||
}
|
||||
|
4
vendor/github.com/rs/xid/hostid_freebsd.go
generated
vendored
4
vendor/github.com/rs/xid/hostid_freebsd.go
generated
vendored
@ -2,8 +2,8 @@
|
||||
|
||||
package xid
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import "syscall"
|
||||
|
||||
func readPlatformMachineID() (string, error) {
|
||||
return unix.Sysctl("kern.hostuuid")
|
||||
return syscall.Sysctl("kern.hostuuid")
|
||||
}
|
||||
|
21
vendor/github.com/rs/xid/hostid_windows.go
generated
vendored
21
vendor/github.com/rs/xid/hostid_windows.go
generated
vendored
@ -4,32 +4,31 @@ package xid
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func readPlatformMachineID() (string, error) {
|
||||
// source: https://github.com/shirou/gopsutil/blob/master/host/host_windows.go
|
||||
var h windows.Handle
|
||||
err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, windows.StringToUTF16Ptr(`SOFTWARE\Microsoft\Cryptography`), 0, windows.KEY_READ|windows.KEY_WOW64_64KEY, &h)
|
||||
// source: https://github.com/shirou/gopsutil/blob/master/host/host_syscall.go
|
||||
var h syscall.Handle
|
||||
err := syscall.RegOpenKeyEx(syscall.HKEY_LOCAL_MACHINE, syscall.StringToUTF16Ptr(`SOFTWARE\Microsoft\Cryptography`), 0, syscall.KEY_READ|syscall.KEY_WOW64_64KEY, &h)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer windows.RegCloseKey(h)
|
||||
defer syscall.RegCloseKey(h)
|
||||
|
||||
const windowsRegBufLen = 74 // len(`{`) + len(`abcdefgh-1234-456789012-123345456671` * 2) + len(`}`) // 2 == bytes/UTF16
|
||||
const syscallRegBufLen = 74 // len(`{`) + len(`abcdefgh-1234-456789012-123345456671` * 2) + len(`}`) // 2 == bytes/UTF16
|
||||
const uuidLen = 36
|
||||
|
||||
var regBuf [windowsRegBufLen]uint16
|
||||
bufLen := uint32(windowsRegBufLen)
|
||||
var regBuf [syscallRegBufLen]uint16
|
||||
bufLen := uint32(syscallRegBufLen)
|
||||
var valType uint32
|
||||
err = windows.RegQueryValueEx(h, windows.StringToUTF16Ptr(`MachineGuid`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen)
|
||||
err = syscall.RegQueryValueEx(h, syscall.StringToUTF16Ptr(`MachineGuid`), nil, &valType, (*byte)(unsafe.Pointer(®Buf[0])), &bufLen)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hostID := windows.UTF16ToString(regBuf[:])
|
||||
hostID := syscall.UTF16ToString(regBuf[:])
|
||||
hostIDLen := len(hostID)
|
||||
if hostIDLen != uuidLen {
|
||||
return "", fmt.Errorf("HostID incorrect: %q\n", hostID)
|
||||
|
12
vendor/github.com/rs/xid/id.go
generated
vendored
12
vendor/github.com/rs/xid/id.go
generated
vendored
@ -42,6 +42,7 @@
|
||||
package xid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"database/sql/driver"
|
||||
@ -51,10 +52,9 @@ import (
|
||||
"hash/crc32"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"bytes"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Code inspired from mgo/bson ObjectId
|
||||
@ -143,9 +143,14 @@ func randInt() uint32 {
|
||||
|
||||
// New generates a globally unique ID
|
||||
func New() ID {
|
||||
return NewWithTime(time.Now())
|
||||
}
|
||||
|
||||
// NewWithTime generates a globally unique ID with the passed in time
|
||||
func NewWithTime(t time.Time) ID {
|
||||
var id ID
|
||||
// Timestamp, 4 bytes, big endian
|
||||
binary.BigEndian.PutUint32(id[:], uint32(time.Now().Unix()))
|
||||
binary.BigEndian.PutUint32(id[:], uint32(t.Unix()))
|
||||
// Machine, first 3 bytes of md5(hostname)
|
||||
id[4] = machineID[0]
|
||||
id[5] = machineID[1]
|
||||
@ -339,7 +344,6 @@ func (id ID) Compare(other ID) int {
|
||||
return bytes.Compare(id[:], other[:])
|
||||
}
|
||||
|
||||
|
||||
type sorter []ID
|
||||
|
||||
func (s sorter) Len() int {
|
||||
|
Reference in New Issue
Block a user