@@ -89,41 +89,39 @@ func (e *EcsData) parseLine(line string) {
89
89
if i := strings .IndexByte (line , '#' ); i >= 0 {
90
90
line = line [:i ]
91
91
}
92
- if strings .Index (line , ":" ) != - 1 {
93
- attrs := strings .Split (line , ":" )
94
- if len (attrs ) != 3 {
95
- return
96
- }
97
- if e .tag != strings .ToUpper (attrs [0 ]) {
98
- return
99
- }
100
- var ecsip = net .ParseIP (attrs [2 ])
101
- if ecsip == nil {
102
- return
103
- }
92
+ attrs := strings .Fields (line )
93
+ if len (attrs ) < 3 {
94
+ return
95
+ }
96
+ if e .tag != strings .ToUpper (attrs [0 ]) {
97
+ return
98
+ }
99
+ var ecsip = net .ParseIP (attrs [2 ])
100
+ if ecsip == nil {
101
+ return
102
+ }
104
103
105
- var addrs = attrs [1 ]
106
- var clist []string
107
- if strings .Index (addrs , "," ) != - 1 {
108
- clist = append (clist , strings .Split (addrs , "," )... )
109
- } else {
110
- clist = append (clist , addrs )
111
- }
112
- for _ , c := range clist {
113
- if strings .Index (c , "/" ) != - 1 {
114
- inet , err := netutils .ParseIpNet (c )
115
- if err != nil {
116
- continue
117
- }
118
- err = e .data .Set (inet .String (), ecsip )
119
- if err != nil {
120
- fmt .Println ("add ecsip error" + err .Error ())
121
- continue
122
- }
123
- e .netBindings .Add (inet )
124
- } else {
125
- _ = e .data .Set (c , ecsip )
104
+ var addrs = attrs [1 ]
105
+ var clist []string
106
+ if strings .Index (addrs , "," ) != - 1 {
107
+ clist = append (clist , strings .Split (addrs , "," )... )
108
+ } else {
109
+ clist = append (clist , addrs )
110
+ }
111
+ for _ , c := range clist {
112
+ if strings .Index (c , "/" ) != - 1 {
113
+ inet , err := netutils .ParseIpNet (c )
114
+ if err != nil {
115
+ continue
126
116
}
117
+ err = e .data .Set (inet .String (), ecsip )
118
+ if err != nil {
119
+ fmt .Println ("add ecsip error" + err .Error ())
120
+ continue
121
+ }
122
+ e .netBindings .Add (inet )
123
+ } else {
124
+ _ = e .data .Set (c , ecsip )
127
125
}
128
126
}
129
127
}
0 commit comments