|
20 | 20 | (find x container)) |
21 | 21 | (:method ((substring string) (x string)) |
22 | 22 | (str:contains? substring x))) |
23 | | -(serapeum:defalias c? #'contains? "Alias for CONTAINS?") |
24 | 23 |
|
25 | | -(serapeum:defalias s= #'string= "Alias for STRING=") |
26 | | -(serapeum:defalias s/= #'string/= "Alias for STRING/=") |
| 24 | +(defmacro defalias (alias func &optional docstring) |
| 25 | + `(progn (setf (fdefinition ',alias) ,func) |
| 26 | + (when ,docstring |
| 27 | + (setf (documentation ',alias 'function) ,docstring)))) |
| 28 | + |
| 29 | +(defalias c? #'contains? "Alias for CONTAINS?") |
| 30 | + |
| 31 | +(defalias s= #'string= "Alias for STRING=") |
| 32 | +(defalias s/= #'string/= "Alias for STRING/=") |
27 | 33 |
|
28 | 34 | (defun f (path &optional (type :str) (max-vector-size 7)) |
29 | 35 | "Read in a list of TYPE data from a file, one per line, to use as a container for CONTAINS? searches. TYPE must be one of (:STR :IP :DNS). :DNS builds a CL-DNS:TRIE to check for domain membership, :IP builds a NETADDR:IP-SET for IP/CIDR membership, and :STR builds an array (or HASH-TABLE if the file contains over MAX-VECTOR-SIZE items)." |
|
45 | 51 | (:method ((ts real)) |
46 | 52 | (double-to-timestamp ts))) |
47 | 53 |
|
48 | | -(serapeum:defalias ts< #'local-time:timestamp< "Alias for LOCAL-TIME:TIMESTAMP<") |
49 | | -(serapeum:defalias ts<= #'local-time:timestamp<= "Alias for LOCAL-TIME:TIMESTAMP<=") |
50 | | -(serapeum:defalias ts> #'local-time:timestamp> "Alias for LOCAL-TIME:TIMESTAMP>") |
51 | | -(serapeum:defalias ts>= #'local-time:timestamp>= "Alias for LOCAL-TIME:TIMESTAMP>=") |
52 | | -(serapeum:defalias ts= #'local-time:timestamp= "Alias for LOCAL-TIME:TIMESTAMP=") |
53 | | -(serapeum:defalias ts/= #'local-time:timestamp/= "Alias for LOCAL-TIME:TIMESTAMP/=") |
| 54 | +(defalias ts< #'local-time:timestamp< "Alias for LOCAL-TIME:TIMESTAMP<") |
| 55 | +(defalias ts<= #'local-time:timestamp<= "Alias for LOCAL-TIME:TIMESTAMP<=") |
| 56 | +(defalias ts> #'local-time:timestamp> "Alias for LOCAL-TIME:TIMESTAMP>") |
| 57 | +(defalias ts>= #'local-time:timestamp>= "Alias for LOCAL-TIME:TIMESTAMP>=") |
| 58 | +(defalias ts= #'local-time:timestamp= "Alias for LOCAL-TIME:TIMESTAMP=") |
| 59 | +(defalias ts/= #'local-time:timestamp/= "Alias for LOCAL-TIME:TIMESTAMP/=") |
54 | 60 |
|
55 | 61 | (defmacro anno (field &rest containers-and-labels) |
56 | 62 | "Given a column in FIELD and an even number of pair-wise containers/labels, return the label for which container contains FIELD. A default container can be specified with T. Use with SETF to create a new column based on this label, for example: (setf @orig_label (anno @o_h #.#I(\"192.168.0.0/16\") \"192.168\" \".127.52.\" \"string-contains\" \'(\"fe80::1462:3ff9:fd68:b0fc\") \"list-contains\" t \"unknown\")) creates the column ORIG_LABEL based on IP checks, a string check, a list membership check, and a default case." |
|
117 | 123 | (let ((first-ip-anon (anonip na:first-ip))) |
118 | 124 | (na:make-ip-network (format nil "~a/~a" (na:str first-ip-anon) na::mask))))))) |
119 | 125 |
|
120 | | -(serapeum:defalias public? #'na:public? "Alias for NETADDR:PUBLIC? which returns T if the IP address is publicly routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).") |
121 | | -(serapeum:defalias private? #'na:private? "Alias for NETADDR:PRIVATE? which returns T if the IP address is privately routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).") |
122 | | -(serapeum:defalias reserved? #'na:reserved? "Alias for NETADDR:RESERVED? which returns T if the IP address is reserved. Requires a NETADDR::IP-LIKE (so fully parse with @@).") |
| 126 | +(defalias public? #'na:public? "Alias for NETADDR:PUBLIC? which returns T if the IP address is publicly routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).") |
| 127 | +(defalias private? #'na:private? "Alias for NETADDR:PRIVATE? which returns T if the IP address is privately routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).") |
| 128 | +(defalias reserved? #'na:reserved? "Alias for NETADDR:RESERVED? which returns T if the IP address is reserved. Requires a NETADDR::IP-LIKE (so fully parse with @@).") |
123 | 129 |
|
124 | 130 | ;; is there a reasonable way to anonymize domains? |
125 | 131 |
|
|
0 commit comments