Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Language: Keepalived configure file #2417

Merged
merged 31 commits into from Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ac26293
pug: Improved class(named "attr-class") and id(named "attr-id") in ta…
dev-itsheng May 3, 2020
c48d654
pug: rewrite the better code, run "npx gulp" and commit ".min.js"
dev-itsheng May 3, 2020
0d7da48
Merge remote-tracking branch 'upstream/master'
dev-itsheng May 4, 2020
a882579
Stylus: Fix comment-like grammar(/**/ or //) in property url() and st…
dev-itsheng May 4, 2020
c3da26f
Stylus: replace the `comment` in the `inside` object
dev-itsheng May 4, 2020
eb73dbb
Merge remote-tracking branch 'upstream/master'
dev-itsheng May 6, 2020
2cb260f
Stylus: Add `color`, `entity`, `unit`, change `number` and `operator`…
dev-itsheng May 6, 2020
2d162ff
Stylus: remove extra `|` in `number` property and add relative tests.
dev-itsheng May 7, 2020
eee68e7
Merge branch 'master' of https://github.com/PrismJS/prism
dev-itsheng May 7, 2020
a37cd5e
Stylus: Put the `comment` token behind the `string` token and set the…
dev-itsheng May 7, 2020
ea3f3ff
Merge branch 'master' of https://github.com/PrismJS/prism
dev-itsheng May 8, 2020
49a6eda
CSS Extra: (1) rename `attr-name`, `attr-value` (2) change `pseudo-cl…
dev-itsheng May 8, 2020
fb011be
CSS Extra: add `?:` in regex to pass the test.
dev-itsheng May 8, 2020
4848fda
CSS Extra: restore `pseudo-class` tokenize, put the `combinator` and …
dev-itsheng May 8, 2020
c500ca3
CSS Extra: rewrite the `combinator` regex and add relative tests to t…
dev-itsheng May 8, 2020
61920bc
CSS Extra: remove `tag` token but left comment describing this history
dev-itsheng May 8, 2020
72fca6d
Merge branch 'master' of https://github.com/PrismJS/prism
dev-itsheng May 13, 2020
2a86a3f
Merge branch 'master' of https://github.com/PrismJS/prism
dev-itsheng Jun 3, 2020
7873e93
New Language: Keepalived configure language whose grammar like Nginx.
dev-itsheng Jun 9, 2020
3c6e657
Merge remote-tracking branch 'upstream/master'
dev-itsheng Jun 9, 2020
468491d
Fix test bug.
dev-itsheng Jun 9, 2020
4a4ec98
run `gulp` after change.
dev-itsheng Jun 9, 2020
42e746a
add `?:` to regex
dev-itsheng Jun 9, 2020
dadc727
add example file.
dev-itsheng Jun 9, 2020
373f701
...... commit minify JS and HTML
dev-itsheng Jun 9, 2020
b370309
Fix all problems.
dev-itsheng Jun 16, 2020
f75b720
Resolved merge conflicts
RunDevelopment Oct 3, 2021
4e51c7f
Fixed linting errors and addressed review comments
RunDevelopment Oct 3, 2021
699110f
Improved string pattern
RunDevelopment Oct 3, 2021
01d264c
Made one long `property` regex
RunDevelopment Oct 3, 2021
e8194b1
Sorted languages list
RunDevelopment Oct 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Expand Up @@ -587,6 +587,10 @@
"title": "Keyman",
"owner": "mcdurdin"
},
"keepalived": {
"title": "Keepalived Configure",
"owner": "dev-itsheng"
},
"kotlin": {
"title": "Kotlin",
"require": "clike",
Expand Down
32 changes: 32 additions & 0 deletions components/prism-keepalived.js
@@ -0,0 +1,32 @@
Prism.languages.keepalived = {
'comment': {
pattern: /(^|[^"{\\])#.*/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true
},
'property': {
pattern: /([\s\t]*)(?:\bglobal_defs|notification_email|notification_email_from|smtp_server|smtp_connect_timeout|router_id|virtual_server|fwmark|delay_loop|lb_algo|lb_kind|persistence_timeout|persistence_granularity|virtualhost|protocol|sorry_server|real_server|weight|TCP_CHECK|MISC_CHECK|misc_path|HTTP_GET|SSL_GET|url|path|digest|connect_port|connect_timeout|retry|delay_before_retry|vrrp_instance|state|interface|mcast_src_ip|lvs_sync_daemon_inteface|virtual_router_id|priority|advert_int|smtp_alert|authentication|auth_type|auth_pass|virtual_ipaddress|virtual_ipaddress_excluded|notify_master|notify_backup|notify_fault|vrrp_sync_group|vrrp_script|interval|script)\b/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true
},
'constant': {
pattern: /(^[ \t]*)(?:rr|wrr|lc|wlc|sh|dh|lblc|NAT|DR|TUN|TCP|UDP|MASTER|BACKUP|PASS|AH)\b/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true
},
'string': /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
'email': {
pattern: /(?:[\w-])+@(?:[\w-])+(?:(?:\.[\w-]{2,3}){1,2})/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
alias: 'string',
},
'path': {
pattern: /(?:\/(?:[^\/\s]+\/)*[^\/\s]*)|(?:[a-zA-Z]:\\(?:\w+\\)*(?:\w+\.\w+)?)/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
alias: 'string',
},
'ip': {
pattern: /(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:225[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)/,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
alias: 'number'
},
'number': {
pattern: /(^|[^\w.-])-?\d*\.?\d+/,
lookbehind: true
},
'punctuation': /[\{\}]/
};
1 change: 1 addition & 0 deletions components/prism-keepalived.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 130 additions & 0 deletions examples/prism-keepalived.html
@@ -0,0 +1,130 @@
<h2>A example from keepalived document</h2>
<pre><code>
# Configuration File for keepalived
global_defs {
notification_email {
admin@domain.com
0633225522@domain.com
}
notification_email_from keepalived@domain.com
smtp_server 192.168.200.20
smtp_connect_timeout 30
router_id LVS_MAIN
}

# VRRP Instances definitions
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass k@l!ve1
}
virtual_ipaddress {
192.168.200.10
192.168.200.11
}
}
vrrp_instance VI_2 {
state MASTER
interface eth1
virtual_router_id 52
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass k@l!ve2
}
virtual_ipaddress {
192.168.100.10
}
}
vrrp_instance VI_3 {
state BACKUP
interface eth0
virtual_router_id 53
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass k@l!ve3
}
virtual_ipaddress {
192.168.200.12
192.168.200.13
}
}
vrrp_instance VI_4 {
state BACKUP
interface eth1
virtual_router_id 54
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass k@l!ve4
}
virtual_ipaddress {
192.168.100.11
}
}
# Virtual Servers definitions
virtual_server 192.168.200.10 80 {
delay_loop 30
lb_algo wrr
lb_kind NAT
persistence_timeout 50
protocol TCP
sorry_server 192.168.100.100 80
real_server 192.168.100.2 80 {
weight 2
HTTP_GET {
url {
path /testurl/test.jsp
digest ec90a42b99ea9a2f5ecbe213ac9eba03
}
url {
path /testurl2/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334c
}
connect_timeout 3
retry 3
delay_before_retry 2
}
}
real_server 192.168.100.3 80 {
weight 1
HTTP_GET {
url {
path /testurl/test.jsp
digest 640205b7b0fc66c1ea91c463fac6334c
}
connect_timeout 3
retry 3
delay_before_retry 2
}
}
}
virtual_server 192.168.200.12 443 {
delay_loop 20
lb_algo rr
lb_kind NAT
persistence_timeout 360
protocol TCP
real_server 192.168.100.2 443 {
weight 1
TCP_CHECK {
connect_timeout 3
}
}
real_server 192.168.100.3 443 {
weight 1
TCP_CHECK {
connect_timeout 3
}
}
}
</code></pre>
1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -93,6 +93,7 @@
"webmanifest": "Web App Manifest",
"jsonp": "JSONP",
"json5": "JSON5",
"keepalived": "Keepalived Configure",
"latex": "LaTeX",
"tex": "TeX",
"context": "ConTeXt",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/languages/keepalived/comment_feature.test
@@ -0,0 +1,13 @@
#
# Foobar

----------------------------------------------------

[
["comment", "#"],
["comment", "# Foobar"]
]

----------------------------------------------------

Checks for comments.
79 changes: 79 additions & 0 deletions tests/languages/keepalived/constant_feature.test
@@ -0,0 +1,79 @@
virtual_server 192.168.1.200 3306 {
lb_algo rr
lb_algo wrr
lb_algo lc
lb_algo wlc
lb_algo sh
lb_algo dh
lb_algo lblc

lb_kind NAT
lb_kind DR
lb_kind TUN

protocol TCP
protocol UDP
}

vrrp_instance test {
state MASTER
state BACKUP

authentication {
auth_type PASS
auth_type AH
}
}

----------------------------------------------------

[
["property", "virtual_server"],
["ip", "192.168.1.200"],
["number", "3306"],
["punctuation", "{"],
["property", "lb_algo"],
["constant", "rr"],
["property", "lb_algo"],
["constant", "wrr"],
["property", "lb_algo"],
["constant", "lc"],
["property", "lb_algo"],
["constant", "wlc"],
["property", "lb_algo"],
["constant", "sh"],
["property", "lb_algo"],
["constant", "dh"],
["property", "lb_algo"],
["constant", "lblc"],
["property", "lb_kind"],
["constant", "NAT"],
["property", "lb_kind"],
["constant", "DR"],
["property", "lb_kind"],
["constant", "TUN"],
["property", "protocol"],
["constant", "TCP"],
["property", "protocol"],
["constant", "UDP"],
["punctuation", "}"],
["property", "vrrp_instance"],
" test ",
["punctuation", "{"],
["property", "state"],
["constant", "MASTER"],
["property", "state"],
["constant", "BACKUP"],
["property", "authentication"],
["punctuation", "{"],
["property", "auth_type"],
["constant", "PASS"],
["property", "auth_type"],
["constant", "AH"],
["punctuation", "}"],
["punctuation", "}"]
]

----------------------------------------------------

Checks for constants, ip (alias number), number, punctuations.