-
Notifications
You must be signed in to change notification settings - Fork 9
🐛 ipset.Check() has problem when version is v7+ #10
Copy link
Copy link
Open
Description
- version
> ipset --version
ipset v7.1, protocol version: 7
Warning: Kernel support protocol versions 6-6 while userspace supports protocol versions 6-7
- this code will return more than version info
out, err := execCommand(ipsetPath, _version).CombinedOutput()
# out is like this
Warning: Kernel support protocol versions 6-6 while userspace supports protocol versions 6-7
ipset v7.1, protocol version: 7
- this code can not get real version
func getMajorVersion(version []byte) int {
vIndex := bytes.IndexByte(version, 'v')
dotIndex := bytes.IndexByte(version, '.')
var majorVersion int
for i := vIndex + 1; i < dotIndex; i++ {
if c := version[i]; c >= '0' && c <= '9' {
majorVersion = majorVersion*10 + int(c-'0')
} else {
return 0
}
}
return majorVersion
}
- case error
ipset utility version is not supported, requiring version >= 6.0
this code can replace by regexp
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels