Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d0df1e1
Add BIRD2 language
Alice39s Aug 2, 2025
82213e9
Add BIRD2 language support
Alice39s Aug 2, 2025
42f5a62
refactor(linguist): refine BIRD2 language detection by removing .conf…
Alice39s Aug 3, 2025
3507ecd
Add `BIRD2` syntax highlighting grammar and fix alias conflict
Alice39s Aug 3, 2025
0dbf240
Add BIRD2 syntax highlighting grammar and fix alias conflict
Alice39s Aug 3, 2025
e3de737
chore: restore removed grammar licenses for sublime-nginx and sublime…
Alice39s Aug 4, 2025
6351e7e
chore: remove low-usage extensions (.bird2.conf, .bird3.conf, .birdconf)
Alice39s Aug 4, 2025
4dff43d
fix: remove trailing blank line accidentally added
Alice39s Aug 4, 2025
c7159ce
Fix incorrect license
Alice39s Aug 12, 2025
808e74a
fix: remove unused extensions and adjusting filenames
Alice39s Aug 12, 2025
e6e0fa1
chore: add new advanced BGP configuration
Alice39s Aug 12, 2025
2e950df
feat: add basic BIRD2 configuration with routing protocols and filters
Alice39s Aug 12, 2025
3df047d
fix: Adjust the structure of BIRD2 sample files
Alice39s Aug 15, 2025
93b9cd5
fix: remove unused BIRD2 configuration files and clean up language de…
Alice39s Aug 19, 2025
7de2063
Fix incorrect sorting
Alice39s Aug 19, 2025
e8c966b
Fix incorrect sorting
Alice39s Aug 19, 2025
485166f
Merge branch 'main' into add-bird2-language
Alice39s Aug 19, 2025
103f4f8
Merge branch 'main' into add-bird2-language
Alice39s Sep 6, 2025
f9b103d
Merge branch 'main' into add-bird2-language
Alice39s Sep 8, 2025
916b53d
fix: move sample BIRD2 config to correct path
Alice39s Sep 9, 2025
117b28c
Merge branch 'main' into add-bird2-language
Alice39s Sep 11, 2025
1b253d0
Merge branch 'main' into add-bird2-language
Alice39s Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
[submodule "vendor/grammars/AutoHotkey"]
path = vendor/grammars/AutoHotkey
url = https://github.com/ahkscript/SublimeAutoHotkey
[submodule "vendor/grammars/BIRD-tm-language-grammar"]
path = vendor/grammars/BIRD-tm-language-grammar
url = https://github.com/bird-chinese-community/BIRD-tm-language-grammar.git
[submodule "vendor/grammars/CUE-Sheet_sublime"]
path = vendor/grammars/CUE-Sheet_sublime
url = https://github.com/relikd/CUE-Sheet_sublime
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ vendor/grammars/AtomLanguageVelocity:
- source.velocity.html
vendor/grammars/AutoHotkey:
- source.ahk
vendor/grammars/BIRD-tm-language-grammar:
- source.bird2
vendor/grammars/CUE-Sheet_sublime:
- source.cuesheet
vendor/grammars/Clue-for-VSCode:
Expand Down
20 changes: 20 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,26 @@ Bikeshed:
codemirror_mode: htmlmixed
codemirror_mime_type: text/html
language_id: 1055528081
BIRD2:
type: data
color: "#b6d7e4"
extensions:
- ".bird"
- ".bird2"
- ".bird3"
- ".bird.conf"
filenames:
- BIRD.conf
- BIRD2.conf
- BIRD3.conf
- bird.conf
- bird2.conf
- bird3.conf
aliases:
- bird
- bird3
tm_scope: source.bird2
language_id: 584191811
Bison:
type: programming
color: "#6A463F"
Expand Down
107 changes: 107 additions & 0 deletions samples/BIRD2/basic.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Basic BIRD2 configuration file
router id 192.168.1.1;
log syslog all;
debug protocols all;

# Community list definition
define LOCAL_PREF_HIGH = [(65001,100), (65001,200)];
define AS_PATH_FILTER = [= 65001 65002 * =];
define MY_ASN = 65001;
define TEST_STR = "test";
define PREFIX_LIST = [
10.0.0.0/8+,
172.16.0.0/12+,
192.168.0.0/16+,
2001::/32{33,128}
];

# Define a protocol
protocol static static_routes {
ipv4 {
table master4;
export all;
import none;
}

route 10.0.0.0/8 via 192.168.1.254;
route 172.16.0.0/12 blackhole;
}

# BGP protocol with AS path filtering
protocol bgp peer1 {
local as 65001;
neighbor 192.168.1.2 as 65002;

ipv4 {
export filter {
if bgp_path ~ [= * 65003 * =] then reject;
accept;
}

import all;
}
}

# OSPF protocol
protocol ospf v2 ospf1 {
ipv4 {
export all;
}

area 0 {
interface "eth0" {
hello 10;
}
}
}

protocol bgp Upstream {
local as 65001;
neighbor 203.0.113.1 as 174;

ipv4 {
import filter {
if bgp_path ~ AS_PATH_FILTER then reject;
accept;
}

export filter export_filter;
}
}

protocol kernel Kernel {
ipv4;
scan time 10;
}

# Filter and function definitions
function is_private_network() -> bool {
if net ~ [ 10.0.0.0/8+, 172.16.0.0/12+, 192.168.0.0/16+ ] then return true;
return false;
}

filter export_filter {
if is_private_network() then reject;
if bgp_path.len > 10 then reject;

if bgp_community ~ [(65001,100)] then {
bgp_local_pref = 200;
accept;
}

accept;
}

protocol bgp uplink {
local as 65001;
neighbor 203.0.113.1 as 174;

ipv4 {
import filter {
if bgp_path ~ AS_PATH_FILTER then reject;
accept;
}

export filter export_filter;
}
}
97 changes: 97 additions & 0 deletions samples/BIRD2/bogon.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
define BOGON_ASNS = [
0, # RFC 7607
23456, # RFC 4893 AS_TRANS
64496..64511, # RFC 5398 and documentation/example ASNs
64512..65534, # RFC 6996 Private ASNs
65535, # RFC 7300 Last 16 bit ASN
65536..65551, # RFC 5398 and documentation/example ASNs
65552..131071, # RFC IANA reserved ASNs
4200000000..4294967294, # Private ASNs
4294967295 # RFC 7300 Last 32 bit ASN
];
define TIER_1_ASNS = [
174, # Cogent
701, # Verizon
1299, # Telia
2914, # NTT
3257, # GTT
3356, # Level3 (CenturyLink), Lumen
3320, # DTAG
3491, # PCCW Global
5511, # Orange
6453, # Tata
6461, # Zayo
6762, # Sparkle
6830, # Liberty Global
6939, # Hurricane Electric (IPv6 only)
7018, # AT&T
7922, # Comcast
12956 # Telefonica
];
define BOGON_PREFIXES_V4 = [
0.0.0.0/8+, # RFC 1122 'this' network
10.0.0.0/8+, # RFC 1918 private space
100.64.0.0/10+, # RFC 6598 Carrier grade nat space
127.0.0.0/8+, # RFC 1122 localhost
169.254.0.0/16+, # RFC 3927 link local
172.16.0.0/12+, # RFC 1918 private space
192.0.2.0/24, # RFC 5737 TEST-NET-1
192.88.99.0/24, # RFC 7526 deprecated 6to4 relay anycast.
192.168.0.0/16+, # RFC 1918 private space
198.18.0.0/15+, # RFC 2544 benchmarking
198.51.100.0/24, # RFC 5737 TEST-NET-2
203.0.113.0/24, # RFC 5737 TEST-NET-3
224.0.0.0/4+, # multicast
240.0.0.0/4+ # reserved
];
define BOGON_PREFIXES_V6 = [
::/8+, # RFC 4291 IPv4-compatible, loopback, et al
0064:ff9b::/96+, # RFC 6052 IPv4/IPv6 Translation
0064:ff9b:1::/48+, # RFC 8215 Local-Use IPv4/IPv6 Translation
0100::/64+, # RFC 6666 Discard-Only
2001::/32{33,12},
2001:2::/48+, # RFC 5180 BMWG
2001:10::/28+, # RFC 4843 ORCHID
2001:db8::/32+, # RFC 3849 documentation
2002::/16+, # RFC 7526 deprecated 6to4 relay anycast.
3ffe::/16+,
5f00::/8+, # RFC 3701 old 6bone
fc00::/7+, # RFC 4193 unique local unicast
fe80::/10+, # RFC 4291 link local unicast
fec0::/10+, # RFC 3879 old site local unicast
ff00::/8+ # RFC 4291 multicast
];

function is_bogon_prefix() -> bool {
case net.type {
NET_IP4: return net ~ BOGON_PREFIXES_V4;
NET_IP6: return net ~ BOGON_PREFIXES_V6;
else: print "is_bogon_prefix: unexpected net.type ", net.type, " ", net;
return false;
}
}

function net_len_too_long() -> bool {
case net.type {
NET_IP4: return net.len > 24;
NET_IP6: return net.len > 48;
else: print "net_len_too_long: unexpected net.type ", net.type, " ", net;
return false;
}
}

function is_bogon_asn() -> bool {
if bgp_path ~ BOGON_ASNS then return true;
return false;
}

function is_no_tier1_asn() -> bool {
if bgp_path ~ TIER_1_ASNS then return false;
return true;
}

function is_bogon() -> bool {
if net_len_too_long() then return true;
if is_bogon_prefix() then return true;
if source = RTS_BGP && is_bogon_asn() then return true;
}
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Awk:** [github-linguist/awk-sublime](https://github.com/github-linguist/awk-sublime)
- **B4X:** [serkonda7/vscode-vba](https://github.com/serkonda7/vscode-vba)
- **BASIC:** [telnet23/language-basic](https://github.com/telnet23/language-basic)
- **BIRD2:** [bird-chinese-community/BIRD-tm-language-grammar](https://github.com/bird-chinese-community/BIRD-tm-language-grammar)
- **BQN:** [razetime/bqn-vscode](https://github.com/razetime/bqn-vscode)
- **Ballerina:** [ballerina-platform/ballerina-grammar](https://github.com/ballerina-platform/ballerina-grammar)
- **Batchfile:** [mmims/language-batchfile](https://github.com/mmims/language-batchfile)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/BIRD-tm-language-grammar
Loading