File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package cmd
55
66import (
77 "context"
8+ "crypto/rand"
89 "encoding/hex"
910 "fmt"
1011 "hash/fnv"
@@ -94,7 +95,22 @@ var rootCmd = &cobra.Command{
9495}
9596
9697func getMacHashTry () string {
97- ifaces := try .To1 (net .Interfaces ())
98+ ifaces , _ := net .Interfaces ()
99+ if len (ifaces ) == 0 {
100+ home := try .To1 (os .UserHomeDir ())
101+ lcodeDir := filepath .Join (home , ".lcode" )
102+ try .To (os .MkdirAll (lcodeDir , os .ModePerm ))
103+ fakeMacFile := filepath .Join (lcodeDir , "fake-mac" )
104+ fakeMac , _ := os .ReadFile (fakeMacFile )
105+ if len (fakeMac ) == 0 {
106+ fakeMac = make ([]byte , 6 )
107+ try .To1 (rand .Read (fakeMac ))
108+ try .To (os .WriteFile (fakeMacFile , fakeMac , os .ModePerm ))
109+ }
110+ ifaces = []net.Interface {
111+ {Flags : net .FlagUp , HardwareAddr : fakeMac },
112+ }
113+ }
98114 hasher := fnv .New32a ()
99115 for _ , iface := range ifaces {
100116 if iface .Flags & net .FlagUp != 0 && iface .HardwareAddr != nil {
You can’t perform that action at this time.
0 commit comments