gods

a simple blocklist for ssh
Log | Files | Refs | README | LICENSE

commit 8f97d749fb2a7d518b21ea771a32268aa081abef
parent b8ff2a6a631e2d117a08b46d6580136e823fe785
Author: Naveen Narayanan <zerous@nocebo.space>
Date:   Sat, 18 Sep 2021 16:55:04 +0200

Implement isip()

Diffstat:
Mparser.c | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/parser.c b/parser.c @@ -243,6 +243,43 @@ procid() return 1; } +static int +isip(char *s) +{ + char ip[16]; + char *o; + int n, t; + + if ((n = strlen(token)) < 7 || n > 15) + return 0; + + strcpy(ip, token); + + o = strtok(ip, "."); + if (!o) + return 0; + if ((t = range(o, 0, 255)) == -1) + return 0; + + o = strtok(NULL, "."); + if (!o) + return 0; + if ((t = range(o, 0, 255)) == -1) + return 0; + + o = strtok(NULL, "."); + if (!o) + return 0; + if ((t = range(o, 0, 255)) == -1) + return 0; + + o = strtok(NULL, "."); + if (!o) + return 0; + if ((t = range(o, 0, 255)) == -1) + return 0; + + printf("isip ok\n"); return 1; }