Skip to content

Commit

Permalink
feat: add tproxy json test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoruk committed Jul 3, 2024
1 parent a557c49 commit a13a06d
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
144 changes: 144 additions & 0 deletions resources/test/json/tproxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"nftables": [
{
"metainfo": {
"version": "1.0.9",
"release_name": "Old Doc Yak #3",
"json_schema_version": 1
}
},
{
"table": {
"family": "inet",
"name": "filter",
"handle": 1
}
},
{
"chain": {
"family": "inet",
"table": "filter",
"name": "tproxy_ipv4",
"handle": 1
}
},
{
"chain": {
"family": "inet",
"table": "filter",
"name": "tproxy_ipv6",
"handle": 2
}
},
{
"rule": {
"family": "inet",
"table": "filter",
"chain": "tproxy_ipv4",
"handle": 3,
"expr": [
{
"match": {
"op": "==",
"left": {
"meta": {
"key": "l4proto"
}
},
"right": "tcp"
}
},
{
"tproxy": {
"family": "ip",
"addr": "127.0.0.1",
"port": 12345
}
}
]
}
},
{
"rule": {
"family": "inet",
"table": "filter",
"chain": "tproxy_ipv4",
"handle": 4,
"expr": [
{
"match": {
"op": "==",
"left": {
"meta": {
"key": "l4proto"
}
},
"right": "tcp"
}
},
{
"tproxy": {
"family": "ip",
"port": 12345
}
}
]
}
},
{
"rule": {
"family": "inet",
"table": "filter",
"chain": "tproxy_ipv6",
"handle": 5,
"expr": [
{
"match": {
"op": "==",
"left": {
"meta": {
"key": "l4proto"
}
},
"right": "tcp"
}
},
{
"tproxy": {
"family": "ip6",
"addr": "::1",
"port": 12345
}
}
]
}
},
{
"rule": {
"family": "inet",
"table": "filter",
"chain": "tproxy_ipv6",
"handle": 6,
"expr": [
{
"match": {
"op": "==",
"left": {
"meta": {
"key": "l4proto"
}
},
"right": "tcp"
}
},
{
"tproxy": {
"family": "ip6",
"port": 12345
}
}
]
}
}
]
}
16 changes: 16 additions & 0 deletions resources/test/nft/tproxy.nft
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/sbin/nft -f

flush ruleset

table inet filter {

chain tproxy_ipv4 {
meta l4proto tcp tproxy ip to 127.0.0.1:12345
meta l4proto tcp tproxy ip to :12345
}

chain tproxy_ipv6 {
meta l4proto tcp tproxy ip6 to [::1]:12345
meta l4proto tcp tproxy ip6 to :12345
}
}

0 comments on commit a13a06d

Please sign in to comment.