Skip to content

Commit d908e45

Browse files
那里好脏不可以RunDevelopment
那里好脏不可以
andauthoredOct 3, 2021
New Language: Keepalived configure file (#2417)
Co-authored-by: RunDevelopment <mitchi5000.ms@googlemail.com>
1 parent a80a68b commit d908e45

17 files changed

+1125
-3
lines changed
 

‎components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎components.json

+4
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,10 @@
713713
"title": "Julia",
714714
"owner": "cdagnino"
715715
},
716+
"keepalived": {
717+
"title": "Keepalived Configure",
718+
"owner": "dev-itsheng"
719+
},
716720
"keyman": {
717721
"title": "Keyman",
718722
"owner": "mcdurdin"

‎components/prism-keepalived.js

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎components/prism-keepalived.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/prism-keepalived.html

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<h2>A example from keepalived document</h2>
2+
<pre><code>
3+
# Configuration File for keepalived
4+
global_defs {
5+
notification_email {
6+
admin@domain.com
7+
0633225522@domain.com
8+
}
9+
notification_email_from keepalived@domain.com
10+
smtp_server 192.168.200.20
11+
smtp_connect_timeout 30
12+
router_id LVS_MAIN
13+
}
14+
15+
# VRRP Instances definitions
16+
vrrp_instance VI_1 {
17+
state MASTER
18+
interface eth0
19+
virtual_router_id 51
20+
priority 150
21+
advert_int 1
22+
authentication {
23+
auth_type PASS
24+
auth_pass k@l!ve1
25+
}
26+
virtual_ipaddress {
27+
192.168.200.10
28+
192.168.200.11
29+
}
30+
}
31+
vrrp_instance VI_2 {
32+
state MASTER
33+
interface eth1
34+
virtual_router_id 52
35+
priority 150
36+
advert_int 1
37+
authentication {
38+
auth_type PASS
39+
auth_pass k@l!ve2
40+
}
41+
virtual_ipaddress {
42+
192.168.100.10
43+
}
44+
}
45+
vrrp_instance VI_3 {
46+
state BACKUP
47+
interface eth0
48+
virtual_router_id 53
49+
priority 100
50+
advert_int 1
51+
authentication {
52+
auth_type PASS
53+
auth_pass k@l!ve3
54+
}
55+
virtual_ipaddress {
56+
192.168.200.12
57+
192.168.200.13
58+
}
59+
}
60+
vrrp_instance VI_4 {
61+
state BACKUP
62+
interface eth1
63+
virtual_router_id 54
64+
priority 100
65+
advert_int 1
66+
authentication {
67+
auth_type PASS
68+
auth_pass k@l!ve4
69+
}
70+
virtual_ipaddress {
71+
192.168.100.11
72+
}
73+
}
74+
# Virtual Servers definitions
75+
virtual_server 192.168.200.10 80 {
76+
delay_loop 30
77+
lb_algo wrr
78+
lb_kind NAT
79+
persistence_timeout 50
80+
protocol TCP
81+
sorry_server 192.168.100.100 80
82+
real_server 192.168.100.2 80 {
83+
weight 2
84+
HTTP_GET {
85+
url {
86+
path /testurl/test.jsp
87+
digest ec90a42b99ea9a2f5ecbe213ac9eba03
88+
}
89+
url {
90+
path /testurl2/test.jsp
91+
digest 640205b7b0fc66c1ea91c463fac6334c
92+
}
93+
connect_timeout 3
94+
retry 3
95+
delay_before_retry 2
96+
}
97+
}
98+
real_server 192.168.100.3 80 {
99+
weight 1
100+
HTTP_GET {
101+
url {
102+
path /testurl/test.jsp
103+
digest 640205b7b0fc66c1ea91c463fac6334c
104+
}
105+
connect_timeout 3
106+
retry 3
107+
delay_before_retry 2
108+
}
109+
}
110+
}
111+
virtual_server 192.168.200.12 443 {
112+
delay_loop 20
113+
lb_algo rr
114+
lb_kind NAT
115+
persistence_timeout 360
116+
protocol TCP
117+
real_server 192.168.100.2 443 {
118+
weight 1
119+
TCP_CHECK {
120+
connect_timeout 3
121+
}
122+
}
123+
real_server 192.168.100.3 443 {
124+
weight 1
125+
TCP_CHECK {
126+
connect_timeout 3
127+
}
128+
}
129+
}
130+
</code></pre>

‎examples/prism-nginx.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ <h2>Server Block</h2>
2222
location / {
2323
proxy_pass http://127.0.0.1:8080;
2424
}
25-
}</code></pre>
25+
}
26+
</code></pre>

‎plugins/show-language/prism-show-language.js

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"jsonp": "JSONP",
125125
"jsstacktrace": "JS stack trace",
126126
"js-templates": "JS Templates",
127+
"keepalived": "Keepalived Configure",
127128
"kts": "Kotlin Script",
128129
"kt": "Kotlin",
129130
"kumir": "KuMir (КуМир)",

‎plugins/show-language/prism-show-language.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
strict_mode on
2+
strict_mode off
3+
strict_mode true
4+
strict_mode false
5+
strict_mode yes
6+
strict_mode no
7+
8+
----------------------------------------------------
9+
10+
[
11+
["property", "strict_mode"],
12+
["boolean", "on"],
13+
["property", "strict_mode"],
14+
["boolean", "off"],
15+
["property", "strict_mode"],
16+
["boolean", "true"],
17+
["property", "strict_mode"],
18+
["boolean", "false"],
19+
["property", "strict_mode"],
20+
["boolean", "yes"],
21+
["property", "strict_mode"],
22+
["boolean", "no"]
23+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Foobar
3+
4+
----------------------------------------------------
5+
6+
[
7+
["comment", "#"],
8+
["comment", "# Foobar"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for comments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
global_defs {
2+
@main router_id main_router
3+
}
4+
5+
vrrp_instance VRRP {
6+
@main unicast_src_ip 1.2.3.4
7+
unicast_peer {
8+
@^main 1.2.3.4
9+
}
10+
}
11+
12+
----------------------------------------------------
13+
14+
[
15+
["property", "global_defs"],
16+
["punctuation", "{"],
17+
["conditional-configuration", "@main"],
18+
["property", "router_id"],
19+
" main_router\r\n",
20+
["punctuation", "}"],
21+
["property", "vrrp_instance"],
22+
" VRRP ",
23+
["punctuation", "{"],
24+
["conditional-configuration", "@main"],
25+
["property", "unicast_src_ip"],
26+
["ip", "1.2.3.4"],
27+
["property", "unicast_peer"],
28+
["punctuation", "{"],
29+
["conditional-configuration", "@^main"],
30+
["ip", "1.2.3.4"],
31+
["punctuation", "}"],
32+
["punctuation", "}"]
33+
]
34+
35+
36+
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
virtual_server 192.168.1.200 3306 {
2+
lvs_sched rr
3+
lvs_sched wrr
4+
lvs_sched lc
5+
lvs_sched wlc
6+
lvs_sched lblc
7+
lvs_sched sh
8+
lvs_sched mh
9+
lvs_sched dh
10+
lvs_sched fo
11+
lvs_sched ovf
12+
lvs_sched lblcr
13+
lvs_sched sed
14+
lvs_sched nq
15+
16+
lvs_method NAT
17+
lvs_method DR
18+
lvs_method TUN
19+
20+
protocol TCP
21+
protocol UDP
22+
protocol SCTP
23+
}
24+
25+
vrrp_instance test {
26+
state MASTER
27+
state BACKUP
28+
29+
authentication {
30+
auth_type PASS
31+
auth_type AH
32+
}
33+
}
34+
35+
DNS_CHECK {
36+
type A
37+
type NS
38+
type CNAME
39+
type SOA
40+
type MX
41+
type TXT
42+
type AAAA
43+
}
44+
45+
----------------------------------------------------
46+
47+
[
48+
["property", "virtual_server"],
49+
["ip", "192.168.1.200"],
50+
["number", "3306"],
51+
["punctuation", "{"],
52+
["property", "lvs_sched"],
53+
["constant", "rr"],
54+
["property", "lvs_sched"],
55+
["constant", "wrr"],
56+
["property", "lvs_sched"],
57+
["constant", "lc"],
58+
["property", "lvs_sched"],
59+
["constant", "wlc"],
60+
["property", "lvs_sched"],
61+
["constant", "lblc"],
62+
["property", "lvs_sched"],
63+
["constant", "sh"],
64+
["property", "lvs_sched"],
65+
["constant", "mh"],
66+
["property", "lvs_sched"],
67+
["constant", "dh"],
68+
["property", "lvs_sched"],
69+
["constant", "fo"],
70+
["property", "lvs_sched"],
71+
["constant", "ovf"],
72+
["property", "lvs_sched"],
73+
["constant", "lblcr"],
74+
["property", "lvs_sched"],
75+
["constant", "sed"],
76+
["property", "lvs_sched"],
77+
["constant", "nq"],
78+
["property", "lvs_method"],
79+
["constant", "NAT"],
80+
["property", "lvs_method"],
81+
["constant", "DR"],
82+
["property", "lvs_method"],
83+
["constant", "TUN"],
84+
["property", "protocol"],
85+
["constant", "TCP"],
86+
["property", "protocol"],
87+
["constant", "UDP"],
88+
["property", "protocol"],
89+
["constant", "SCTP"],
90+
["punctuation", "}"],
91+
["property", "vrrp_instance"],
92+
" test ",
93+
["punctuation", "{"],
94+
["property", "state"],
95+
["constant", "MASTER"],
96+
["property", "state"],
97+
["constant", "BACKUP"],
98+
["property", "authentication"],
99+
["punctuation", "{"],
100+
["property", "auth_type"],
101+
["constant", "PASS"],
102+
["property", "auth_type"],
103+
["constant", "AH"],
104+
["punctuation", "}"],
105+
["punctuation", "}"],
106+
["property", "DNS_CHECK"],
107+
["punctuation", "{"],
108+
["property", "type"],
109+
["constant", "A"],
110+
["property", "type"],
111+
["constant", "NS"],
112+
["property", "type"],
113+
["constant", "CNAME"],
114+
["property", "type"],
115+
["constant", "SOA"],
116+
["property", "type"],
117+
["constant", "MX"],
118+
["property", "type"],
119+
["constant", "TXT"],
120+
["property", "type"],
121+
["constant", "AAAA"],
122+
["punctuation", "}"]
123+
]
124+
125+
----------------------------------------------------
126+
127+
Checks for constants, number, punctuations.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
virtual_server 192.168.1.200 3306
2+
virtual_server 192.168.1.200/32 3306
3+
virtual_server ABCD:EF01:2345:6789:ABCD:EF01:2345:6789 3306
4+
virtual_server ABCD:EF01:2345:6789:ABCD:EF01:2345:6789/128 3306
5+
6+
----------------------------------------------------
7+
8+
[
9+
["property", "virtual_server"],
10+
["ip", "192.168.1.200"],
11+
["number", "3306"],
12+
["property", "virtual_server"],
13+
["ip", "192.168.1.200/32"],
14+
["number", "3306"],
15+
["property", "virtual_server"],
16+
["ip", "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789"],
17+
["number", "3306"],
18+
["property", "virtual_server"],
19+
["ip", "ABCD:EF01:2345:6789:ABCD:EF01:2345:6789/128"],
20+
["number", "3306"]
21+
]
22+
23+
----------------------------------------------------
24+
25+
Checks for ip (IPv4, IPv6, subnet mask).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
vrrp_instance VI_1 {
2+
notify_master /etc/keepalived/to_master.sh
3+
notify_backup C:\keepalived\to_backup.bat
4+
net_namespace /var/run/keepalived
5+
net_namespace C:\users\prism\keepalived
6+
}
7+
8+
----------------------------------------------------
9+
10+
[
11+
["property", "vrrp_instance"],
12+
" VI_1 ",
13+
["punctuation", "{"],
14+
["property", "notify_master"],
15+
["path", "/etc/keepalived/to_master.sh"],
16+
["property", "notify_backup"],
17+
["path", "C:\\keepalived\\to_backup.bat"],
18+
["property", "net_namespace"],
19+
["path", "/var/run/keepalived"],
20+
["property", "net_namespace"],
21+
["path", "C:\\users\\prism\\keepalived"],
22+
["punctuation", "}"]
23+
]
24+
25+
----------------------------------------------------
26+
27+
Checks for path.

‎tests/languages/keepalived/property_feature.test

+625
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
global_defs {
2+
notification_email {
3+
example@163.com
4+
}
5+
notification_email_from example@example.com
6+
}
7+
8+
vrrp_instance VI_1 {
9+
notify_fault "/etc/keepalived/to_fault.sh"
10+
}
11+
12+
----------------------------------------------------
13+
14+
[
15+
["property", "global_defs"],
16+
["punctuation", "{"],
17+
["property", "notification_email"],
18+
["punctuation", "{"],
19+
["email", "example@163.com"],
20+
["punctuation", "}"],
21+
["property", "notification_email_from"],
22+
["email", "example@example.com"],
23+
["punctuation", "}"],
24+
["property", "vrrp_instance"],
25+
" VI_1 ",
26+
["punctuation", "{"],
27+
["property", "notify_fault"],
28+
["string", "\"/etc/keepalived/to_fault.sh\""],
29+
["punctuation", "}"]
30+
]
31+
32+
----------------------------------------------------
33+
34+
Checks for string, email (alias string).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$ADDRESS_BASE=10.2.${ADDRESS_BASE_SUB}
2+
$ADDRESS_BASE_SUB=0
3+
${ADDRESS_BASE}.100/32
4+
$ADDRESS_BASE_SUB=10
5+
6+
----------------------------------------------------
7+
8+
[
9+
["variable", "$ADDRESS_BASE"],
10+
["operator", "="],
11+
["number", "10.2"],
12+
".",
13+
["variable", "${ADDRESS_BASE_SUB}"],
14+
["variable", "$ADDRESS_BASE_SUB"],
15+
["operator", "="],
16+
["number", "0"],
17+
["variable", "${ADDRESS_BASE}"],
18+
".100/",
19+
["number", "32"],
20+
["variable", "$ADDRESS_BASE_SUB"],
21+
["operator", "="],
22+
["number", "10"]
23+
]

0 commit comments

Comments
 (0)
Please sign in to comment.