update
This commit is contained in:
+13
-5
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -12,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/beego/beego/v2/adapter/httplib"
|
"github.com/beego/beego/v2/adapter/httplib"
|
||||||
"github.com/beego/beego/v2/adapter/logs"
|
"github.com/beego/beego/v2/adapter/logs"
|
||||||
|
"github.com/denisbrodbeck/machineid"
|
||||||
"github.com/robertkrimen/otto"
|
"github.com/robertkrimen/otto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,12 +37,18 @@ func init() {
|
|||||||
|
|
||||||
var OttoFuncs = map[string]func(string) string{
|
var OttoFuncs = map[string]func(string) string{
|
||||||
"machineId": func(_ string) string {
|
"machineId": func(_ string) string {
|
||||||
data, _ := os.ReadFile("/var/lib/dbus/machine-id")
|
// data, _ := os.ReadFile("/var/lib/dbus/machine-id")
|
||||||
id := regexp.MustCompile(`\w+`).FindString(string(data))
|
// id := regexp.MustCompile(`\w+`).FindString(string(data))
|
||||||
if id == "" {
|
// if id == "" {
|
||||||
data, _ = os.ReadFile("/etc/machine-id")
|
// data, _ = os.ReadFile("/etc/machine-id")
|
||||||
id = regexp.MustCompile(`\w+`).FindString(string(data))
|
// id = regexp.MustCompile(`\w+`).FindString(string(data))
|
||||||
|
// }
|
||||||
|
id, err := machineid.ProtectedID("sillyGirl")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
fmt.Println(id)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
},
|
},
|
||||||
"uuid": func(_ string) string {
|
"uuid": func(_ string) string {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ require (
|
|||||||
github.com/beego/beego/v2 v2.0.1
|
github.com/beego/beego/v2 v2.0.1
|
||||||
github.com/boltdb/bolt v1.3.1
|
github.com/boltdb/bolt v1.3.1
|
||||||
github.com/buger/jsonparser v1.1.1
|
github.com/buger/jsonparser v1.1.1
|
||||||
|
github.com/denisbrodbeck/machineid v1.0.1
|
||||||
github.com/gin-gonic/gin v1.7.0
|
github.com/gin-gonic/gin v1.7.0
|
||||||
github.com/google/uuid v1.1.1
|
github.com/google/uuid v1.1.1
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGii
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
|
||||||
|
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
|
||||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||||
|
|||||||
Reference in New Issue
Block a user