| 260 | |
| 261 | |
| 262 | def p0f_correl(x, y): |
| 263 | d = 0 |
| 264 | # wwww can be "*" or "%nn". "Tnn" and "Snn" should work fine with |
| 265 | # the x[0] == y[0] test. |
| 266 | d += (x[0] == y[0] or y[0] == "*" or (y[0][0] == "%" and x[0].isdigit() and (int(x[0]) % int(y[0][1:])) == 0)) # noqa: E501 |
| 267 | # ttl |
| 268 | d += (y[1] >= x[1] and y[1] - x[1] < 32) |
| 269 | for i in [2, 5]: |
| 270 | d += (x[i] == y[i] or y[i] == '*') |
| 271 | # '*' has a special meaning for ss |
| 272 | d += x[3] == y[3] |
| 273 | xopt = x[4].split(",") |
| 274 | yopt = y[4].split(",") |
| 275 | if len(xopt) == len(yopt): |
| 276 | same = True |
| 277 | for i in range(len(xopt)): |
| 278 | if not (xopt[i] == yopt[i] or |
| 279 | (len(yopt[i]) == 2 and len(xopt[i]) > 1 and |
| 280 | yopt[i][1] == "*" and xopt[i][0] == yopt[i][0]) or |
| 281 | (len(yopt[i]) > 2 and len(xopt[i]) > 1 and |
| 282 | yopt[i][1] == "%" and xopt[i][0] == yopt[i][0] and |
| 283 | int(xopt[i][1:]) % int(yopt[i][2:]) == 0)): |
| 284 | same = False |
| 285 | break |
| 286 | if same: |
| 287 | d += len(xopt) |
| 288 | return d |
| 289 | |
| 290 | |
| 291 | @conf.commands.register |