Ubuntu 工具 graph-easy

reference:

1. install graph-easy

$sudo apt install libgraph-easy-perl

2. edit file

$vim simple.txt
graph { flow: south; }
[start] -> [userpass search?]
[userpass search?] - match ->  [fast accept/drop]
[userpass search?] - not found -> [black search?]
[black search?] - match -> [try_cnt over?]
[black search?] - not found -> [LDAP/RADIUS check]
[LDAP/RADIUS check] - success -> [accept and update userpass]
[LDAP/RADIUS check] - fail  -> [drop and update userpass/black]
[try_cnt over?] - yes -> [ban drop, is hacker?]
[try_cnt over?] - no -> [LDAP/RADIUS check]

3. graph it

$graph-easy ./simple.txt

4. LRU cache as example

cache display:

### LRU - Least Recently Used Cache ###
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
' 1.userpass cache:                                         '
'                                                           '
' +-----------------++--------++--------------------------+ '
' |     latest      || oldest ||         expired          | '
' +-----------------++--------++--------------------------+ '
'                                                           '
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +

+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
' 2.black cache:                                            '
'                                                           '
' +-----------------++--------++--------------------------+ '
' |     latest      || oldest ||         expired          | '
' +-----------------++--------++--------------------------+ '
'                                                           '
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
head                                                     tail

graph display:

                                            +----------------------------+
                                            |           start            |
                                            +----------------------------+
                                              |
                                              |
                                              v
+--------------------------------+  match   +----------------------------+
|        fast accept/drop        | <------- |      userpass search?      |
+--------------------------------+          +----------------------------+
                                              |
                                              | not found
                                              v
                                            +----------------------------+
                                            |       black search?        | -+
                                            +----------------------------+  |
                                              |                             |
                                              | match                       |
                                              v                             |
+--------------------------------+  yes     +----------------------------+  |
|      ban drop, is hacker?      | <------- |       try_cnt over?        |  | not found
+--------------------------------+          +----------------------------+  |
                                              |                             |
                                              | no                          |
                                              v                             |
+--------------------------------+  fail    +----------------------------+  |
| drop and update userpass/black | <------- |     LDAP/RADIUS check      | <+
+--------------------------------+          +----------------------------+
                                              |
                                              | success
                                              v
                                            +----------------------------+
                                            | accept and update userpass |
                                            +----------------------------+

  轉載請註明: YuYan's blog Ubuntu 工具 graph-easy

  目錄