diff --git a/docs/css-classes-reference.rst b/docs/css-classes-reference.rst index fa2cab41d0..da28145efe 100644 --- a/docs/css-classes-reference.rst +++ b/docs/css-classes-reference.rst @@ -1338,3 +1338,14 @@ Dockerfile ("dockerfile", "docker") * ``comment``: comment * ``number``: number * ``string``: string + +PF ("pf", "pf.conf") +-------------------- + +* ``built_in``: top level action, e.g. block/match/pass +* ``keyword``: some parameter/modifier to an action (in, on, nat-to, most reserved words) +* ``literal``: words representing special values, e.g. all, egress +* ``comment``: comment +* ``number``: number +* ``string``: string +* ``variable``: used for both macros and tables diff --git a/src/languages/pf.js b/src/languages/pf.js new file mode 100644 index 0000000000..00d59cf697 --- /dev/null +++ b/src/languages/pf.js @@ -0,0 +1,58 @@ +/* +Language: pf +Category: config +Author: Peter Piwowarski +Description: The pf.conf(5) format as of OpenBSD 5.6 +*/ + +function(hljs) { + var MACRO = { + className: 'variable', + begin: /\$[\w\d#@][\w\d_]*/ + }; + var TABLE = { + className: 'variable', + begin: // + }; + var QUOTE_STRING = { + className: 'string', + begin: /"/, end: /"/ + }; + + return { + aliases: ['pf.conf'], + lexemes: /[a-z0-9_<>-]+/, + keywords: { + built_in: /* block match pass are "actions" in pf.conf(5), the rest are + * lexically similar top-level commands. + */ + 'block match pass load anchor|5 antispoof|10 set table', + keyword: + 'in out log quick on rdomain inet inet6 proto from port os to route' + + 'allow-opts divert-packet divert-reply divert-to flags group icmp-type' + + 'icmp6-type label once probability recieved-on rtable prio queue' + + 'tos tag tagged user keep fragment for os drop' + + 'af-to|10 binat-to|10 nat-to|10 rdr-to|10 bitmask least-stats random round-robin' + + 'source-hash static-port' + + 'dup-to reply-to route-to' + + 'parent bandwidth default min max qlimit' + + 'block-policy debug fingerprints hostid limit loginterface optimization' + + 'reassemble ruleset-optimization basic none profile skip state-defaults' + + 'state-policy timeout' + + 'const counters persist' + + 'no modulate synproxy state|5 floating if-bound no-sync pflow|10 sloppy' + + 'source-track global rule max-src-nodes max-src-states max-src-conn' + + 'max-src-conn-rate overload flush' + + 'scrub|5 max-mss min-ttl no-df|10 random-id', + literal: + 'all any no-route self urpf-failed egress|5 unknown', + }, + contains: [ + hljs.HASH_COMMENT_MODE, + hljs.NUMBER_MODE, + hljs.QUOTE_STRING_MODE, + MACRO, + TABLE, + ] + }; +} diff --git a/src/styles/default.css b/src/styles/default.css index fbc5328ee9..b47cbe5726 100644 --- a/src/styles/default.css +++ b/src/styles/default.css @@ -37,6 +37,7 @@ Original style from softwaremaniacs.org (c) Ivan Sagalaev