-
Notifications
You must be signed in to change notification settings - Fork 5k
Add BIRD2 language #7513
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
Open
Alice39s
wants to merge
22
commits into
github-linguist:main
Choose a base branch
from
Alice39s:add-bird2-language
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+672
−0
Open
Add BIRD2 language #7513
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d0df1e1
Add BIRD2 language
Alice39s 82213e9
Add BIRD2 language support
Alice39s 42f5a62
refactor(linguist): refine BIRD2 language detection by removing .conf…
Alice39s 3507ecd
Add `BIRD2` syntax highlighting grammar and fix alias conflict
Alice39s 0dbf240
Add BIRD2 syntax highlighting grammar and fix alias conflict
Alice39s e3de737
chore: restore removed grammar licenses for sublime-nginx and sublime…
Alice39s 6351e7e
chore: remove low-usage extensions (.bird2.conf, .bird3.conf, .birdconf)
Alice39s 4dff43d
fix: remove trailing blank line accidentally added
Alice39s c7159ce
Fix incorrect license
Alice39s 808e74a
fix: remove unused extensions and adjusting filenames
Alice39s e6e0fa1
chore: add new advanced BGP configuration
Alice39s 2e950df
feat: add basic BIRD2 configuration with routing protocols and filters
Alice39s 3df047d
fix: Adjust the structure of BIRD2 sample files
Alice39s 93b9cd5
fix: remove unused BIRD2 configuration files and clean up language de…
Alice39s 7de2063
Fix incorrect sorting
Alice39s e8c966b
Fix incorrect sorting
Alice39s 485166f
Merge branch 'main' into add-bird2-language
Alice39s 103f4f8
Merge branch 'main' into add-bird2-language
Alice39s f9b103d
Merge branch 'main' into add-bird2-language
Alice39s 916b53d
fix: move sample BIRD2 config to correct path
Alice39s 117b28c
Merge branch 'main' into add-bird2-language
Alice39s 1b253d0
Merge branch 'main' into add-bird2-language
Alice39s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule BIRD-tm-language-grammar
added at
da3222
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.