Skip to content

Commit b0ae728

Browse files
committed
feat; remove machine file support
1 parent c77705a commit b0ae728

9 files changed

Lines changed: 27 additions & 25 deletions

File tree

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44

55
… because sometimes you just need to reliably identify your machines.
66

7-
[![GoDoc](https://godoc.org/github.com/denisbrodbeck/machineid?status.svg)](https://godoc.org/github.com/denisbrodbeck/machineid) [![Go Report Card](https://goreportcard.com/badge/github.com/denisbrodbeck/machineid)](https://goreportcard.com/report/github.com/denisbrodbeck/machineid)
8-
97
## Fork
108

11-
[This](https://github.com/panta/machineid) is a fork of [github.com/denisbrodbeck/machineid](https://github.com/denisbrodbeck/machineid).
12-
The fork solve some issues in the original library (docker support and customizable machine-id file, macOS cron support, ...).
9+
[This](https://github.com/fourcorelabs/machineid) is a fork of [github.com/panta/machineid](https://github.com/panta/machineid).
1310

1411
## Main Features
1512

@@ -23,13 +20,13 @@ The fork solve some issues in the original library (docker support and customiza
2320
Get the library with
2421

2522
```bash
26-
go get github.com/panta/machineid
23+
go get github.com/fourcorelabs/machineid
2724
```
2825

2926
You can also add the cli app directly to your `$GOPATH/bin` with
3027

3128
```bash
32-
go get github.com/panta/machineid/cmd/machineid
29+
go get github.com/fourcorelabs/machineid/cmd/machineid
3330
```
3431

3532
## Usage
@@ -40,7 +37,7 @@ package main
4037
import (
4138
"fmt"
4239
"log"
43-
"github.com/panta/machineid"
40+
"github.com/fourcorelabs/machineid"
4441
)
4542

4643
func main() {
@@ -60,7 +57,7 @@ package main
6057
import (
6158
"fmt"
6259
"log"
63-
"github.com/panta/machineid"
60+
"github.com/fourcorelabs/machineid"
6461
)
6562

6663
func main() {
@@ -118,7 +115,7 @@ import (
118115
"crypto/hmac"
119116
"crypto/sha256"
120117
"fmt"
121-
"github.com/panta/machineid"
118+
"github.com/fourcorelabs/machineid"
122119
)
123120

124121
const appKey = "WowSuchNiceApp"

cmd/machineid/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
// Usage: machineid [options]
44
//
55
// Options:
6-
// --appid <AppID> Protect machine id by hashing it together with an app id.
6+
//
7+
// --appid <AppID> Protect machine id by hashing it together with an app id.
78
//
89
// Try:
9-
// machineid
10-
// machineid --appid MyAppID
10+
//
11+
// machineid
12+
// machineid --appid MyAppID
1113
package main
1214

1315
import (
1416
"flag"
1517
"fmt"
1618
"log"
1719

18-
"github.com/panta/machineid"
20+
"github.com/fourcorelabs/machineid"
1921
)
2022

2123
const usageStr = `

example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"log"
66

7-
"github.com/panta/machineid"
7+
"github.com/fourcorelabs/machineid"
88
)
99

1010
func Example() {

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
module github.com/panta/machineid
1+
module github.com/fourcorelabs/machineid
22

33
go 1.15
4+
5+
require golang.org/x/sys v0.30.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
2+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

helper.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"crypto/sha256"
66
"encoding/hex"
77
"io"
8-
"io/ioutil"
98
"os"
109
"os/exec"
1110
"strings"
@@ -28,11 +27,11 @@ func protect(appID, id string) string {
2827
}
2928

3029
func readFile(filename string) ([]byte, error) {
31-
return ioutil.ReadFile(filename)
30+
return os.ReadFile(filename)
3231
}
3332

3433
func writeFile(filename string, data []byte) error {
35-
return ioutil.WriteFile(filename, data, 0644)
34+
return os.WriteFile(filename, data, 0644)
3635
}
3736

3837
// readFirstFile tries all the pathnames listed and returns the contents of the first readable file.

id.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Package machineid provides support for reading the unique machine id of most OSs (without admin privileges).
22
//
3-
// https://github.com/panta/machineid
3+
// https://github.com/fourcorelabs/machineid
44
//
5-
// https://godoc.org/github.com/panta/machineid/cmd/machineid
5+
// https://godoc.org/github.com/fourcorelabs/machineid/cmd/machineid
66
//
77
// This package is Cross-Platform (tested on Win7+, Debian 8+, Ubuntu 14.04+, OS X 10.6+, FreeBSD 11+)
88
// and does not use any internal hardware IDs (no MAC, BIOS, or CPU).
@@ -17,7 +17,7 @@
1717
// Linux users can generate a new id with `dbus-uuidgen` and put the id into
1818
// `/var/lib/dbus/machine-id` and `/etc/machine-id`.
1919
// Windows users can use the `sysprep` toolchain to create images, which produce valid images ready for distribution.
20-
package machineid // import "github.com/panta/machineid"
20+
package machineid // import "github.com/fourcorelabs/machineid"
2121

2222
import (
2323
"fmt"

id_linux.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build linux
12
// +build linux
23

34
package machineid
@@ -36,19 +37,17 @@ const (
3637
// The logic implemented is a variation of the one described in https://github.com/denisbrodbeck/machineid/issues/5#issuecomment-523803164
3738
// See also https://unix.stackexchange.com/questions/144812/generate-consistent-machine-unique-id
3839
func machineID() (string, error) {
39-
env_pathname := os.Getenv(ENV_VARNAME)
40-
4140
home := os.Getenv("HOME")
4241
userMachineId := path.Join(home, ".config", "machine-id")
4342

4443
id, err := readFirstFile([]string{
45-
env_pathname, dbusPath, dbusPathEtc, userMachineId,
44+
dbusPath, dbusPathEtc, userMachineId,
4645
})
4746
if err != nil {
4847
id, err = readFile(linuxRandomUuid)
4948
if err == nil {
5049
writeFirstFile([]string{
51-
env_pathname, dbusPathEtc, dbusPath, userMachineId,
50+
dbusPathEtc, dbusPath, userMachineId,
5251
}, id)
5352
}
5453
}

id_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build windows
12
// +build windows
23

34
package machineid

0 commit comments

Comments
 (0)