aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/pborman/uuid/node_net.go
diff options
context:
space:
mode:
authorale <ale@incal.net>2017-12-18 22:35:16 +0000
committerale <ale@incal.net>2017-12-18 22:35:16 +0000
commit445bf898d2015d1e28e5f01ef07b26be9dd42bf1 (patch)
tree05bae03d8625be5dee79ac408cf96b6ffae97840 /vendor/github.com/pborman/uuid/node_net.go
parent394de2d98a9cfde6244620f0b188625b60f68f96 (diff)
downloadcrawl-445bf898d2015d1e28e5f01ef07b26be9dd42bf1.tar.gz
crawl-445bf898d2015d1e28e5f01ef07b26be9dd42bf1.zip
Add vendor deps
Diffstat (limited to 'vendor/github.com/pborman/uuid/node_net.go')
-rw-r--r--vendor/github.com/pborman/uuid/node_net.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/github.com/pborman/uuid/node_net.go b/vendor/github.com/pborman/uuid/node_net.go
new file mode 100644
index 0000000..330b544
--- /dev/null
+++ b/vendor/github.com/pborman/uuid/node_net.go
@@ -0,0 +1,36 @@
+// Copyright 2017 Google Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !js
+
+package uuid
+
+import "net"
+
+var interfaces []net.Interface // cached list of interfaces
+
+// getHardwareInterface returns the name and hardware address of interface name.
+// If name is "" then the name and hardware address of one of the system's
+// interfaces is returned. If no interfaces are found (name does not exist or
+// there are no interfaces) then "", nil is returned.
+//
+// Only addresses of at least 6 bytes are returned.
+func getHardwareInterface(name string) (string, []byte) {
+ if interfaces == nil {
+ var err error
+ interfaces, err = net.Interfaces()
+ if err != nil {
+ return "", nil
+ }
+ }
+ for _, ifs := range interfaces {
+ if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) {
+ if setNodeID(ifs.HardwareAddr) {
+ ifname = ifs.Name
+ return ifname, nodeID
+ }
+ }
+ }
+ return "", nil
+}