mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
internal/router: relax dnsmasq lease file parsing condition
On DD-WRT v3.0-r52189, dnsmasq version 2.89 lease format looks like: 1685794060 <mac> <ip> <hostname> 00:00:00:00:00:04 9 It has 6 fields, while the current parser only looks for line with exact 5 fields, which is too restricted. In fact, the parser shold just skip line with less than 4 fields, because the 4th field is the hostname, which is the last client info that ctrld needs.
This commit is contained in:
committed by
Cuong Manh Le
parent
1cd54a48e9
commit
bbfa7c6c22
@@ -105,7 +105,7 @@ func dnsmasqReadClientInfoReader(reader io.Reader) error {
|
||||
r := routerPlatform.Load()
|
||||
return lineread.Reader(reader, func(line []byte) error {
|
||||
fields := bytes.Fields(line)
|
||||
if len(fields) != 5 {
|
||||
if len(fields) < 4 {
|
||||
return nil
|
||||
}
|
||||
mac := string(fields[1])
|
||||
|
||||
@@ -78,6 +78,12 @@ lease 192.168.1.2 {
|
||||
iscDHCPReadClientInfoReader,
|
||||
"00:00:00:00:00:02",
|
||||
},
|
||||
{
|
||||
"",
|
||||
`1685794060 00:00:00:00:00:04 192.168.0.209 cuonglm-ThinkPad-X1-Carbon-Gen-9 00:00:00:00:00:04 9`,
|
||||
dnsmasqReadClientInfoReader,
|
||||
"00:00:00:00:00:04",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
||||
Reference in New Issue
Block a user