File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,19 @@ type macTransformer struct {
17
17
18
18
func NewFileTransformer () proxy.Transformer {
19
19
return & macTransformer {
20
- ipmac : readIPMacMap (),
20
+ ipmac : readIPMacMap (getFilePath () ),
21
21
}
22
22
}
23
23
24
+ func getFilePath () string {
25
+ path , exists := os .LookupEnv ("MAC_FILE" )
26
+ if exists {
27
+ return path
28
+ }
29
+
30
+ return "/var/lib/promscan/all"
31
+ }
32
+
24
33
func (trans * macTransformer ) Transform (line string ) string {
25
34
mac := getMac (trans .ipmac , line )
26
35
@@ -41,9 +50,9 @@ func getMac(ipmac map[string]string, line string) string {
41
50
return "UNKNOWN"
42
51
}
43
52
44
- func readIPMacMap () map [string ]string {
53
+ func readIPMacMap (filePath string ) map [string ]string {
45
54
ipmac := make (map [string ]string )
46
- file , err := os .Open ("./all" ) // TODO
55
+ file , err := os .Open (filePath )
47
56
if err != nil {
48
57
log .Fatal (err )
49
58
}
You can’t perform that action at this time.
0 commit comments