ci: cram: packetinterception: update PacketInterception test
Signed-off-by: Marten Barrett <marten.barrett@softathome.com>
This commit is contained in:
parent
a49a1afa0c
commit
a07d59a63b
@ -2,47 +2,74 @@ Create R alias:
|
|||||||
|
|
||||||
$ alias R="${CRAM_REMOTE_COMMAND:-}"
|
$ alias R="${CRAM_REMOTE_COMMAND:-}"
|
||||||
|
|
||||||
Check PacketInterception root datamodel:
|
Check PacketInterception root datamodel and Status:
|
||||||
|
|
||||||
$ R "ubus -S call PacketInterception _get"
|
$ R "ba-cli -l PacketInterception.Status?" | awk NF
|
||||||
{"PacketInterception.":{"InterceptionNumberOfEntries":3,"Enable":false,"PacketHandlerNumberOfEntries":1,"ConditionNumberOfEntries":5,"Status":"Disabled"}}
|
Disabled
|
||||||
{}
|
|
||||||
{"amxd-error-code":0}
|
|
||||||
|
|
||||||
Check that no interception is being configured:
|
Check that no iptables rules are being configured:
|
||||||
|
|
||||||
$ R "iptables -t mangle -L INTERCEPT_Forward"
|
$ R "iptables -t mangle -L INTERCEPT_Forward"
|
||||||
Chain INTERCEPT_Forward (0 references)
|
Chain INTERCEPT_Forward (0 references)
|
||||||
target prot opt source destination
|
target prot opt source destination
|
||||||
|
|
||||||
Enable interception of packets:
|
Enable interception of packets and check Status:
|
||||||
|
|
||||||
$ R "ubus -S call PacketInterception _set '{\"parameters\":{\"Enable\":True}}'" ; sleep 2
|
$ R "ba-cli -l PacketInterception.Enable=True" | awk NF
|
||||||
{"PacketInterception.":{"Enable":true}}
|
1
|
||||||
|
|
||||||
|
$ R "ba-cli -l PacketInterception.Status?" | awk NF
|
||||||
|
Enabled
|
||||||
|
|
||||||
|
Add a new CommunicationConfig
|
||||||
|
|
||||||
|
$ R "ubus -S call PacketInterception.CommunicationConfig.Socket _add '{\"parameters\":{\"Alias\":\"test_socket\",\"Enable\":True,\"URI\":\"/var/run/packetinterception/test_sock\"}}'" ; sleep 2
|
||||||
|
{"object":"PacketInterception.CommunicationConfig.Socket.test_socket.","index":1,"name":"test_socket","parameters":{"Alias":"test_socket"},"path":"PacketInterception.CommunicationConfig.Socket.1."}
|
||||||
{}
|
{}
|
||||||
{"amxd-error-code":0}
|
{"amxd-error-code":0}
|
||||||
|
|
||||||
Check that interception is configured properly:
|
Add a new Intercept
|
||||||
|
|
||||||
$ R "iptables -t mangle -L INTERCEPT_Forward"
|
$ R "ubus -S call PacketInterception.Interception.3.Intercept _add '{\"parameters\":{\"Alias\":\"test\",\"Enable\":True,\"Condition\":\"DNS\", \"NumberOfPackets\":1, \"PacketHandler\":\"default_handler\"}}'" ; sleep 2
|
||||||
Chain INTERCEPT_Forward (1 references)
|
{"object":"PacketInterception.Interception.Output.Intercept.test.","index":2,"name":"test","parameters":{"Alias":"test"},"path":"PacketInterception.Interception.3.Intercept.2."}
|
||||||
|
{}
|
||||||
|
{"amxd-error-code":0}
|
||||||
|
|
||||||
|
Add the new CommunicationConfig to the Intercept
|
||||||
|
|
||||||
|
$ R "ubus -S call PacketInterception.Interception.3.Intercept.2.CommunicationConfig _add '{\"parameters\":{\"Alias\":\"test_socket\",\"Priority\":1,\"CommunicationConfig\":\"test_socket\"}}'" ; sleep 2
|
||||||
|
{"object":"PacketInterception.Interception.Output.Intercept.test.CommunicationConfig.test_socket.","index":1,"name":"test_socket","parameters":{"Alias":"test_socket"},"path":"PacketInterception.Interception.3.Intercept.2.CommunicationConfig.1."}
|
||||||
|
{}
|
||||||
|
{"amxd-error-code":0}
|
||||||
|
|
||||||
|
Check that iptables rule are correct
|
||||||
|
|
||||||
|
$ R "iptables -t mangle -L INTERCEPT_Output"
|
||||||
|
Chain INTERCEPT_Output (1 references)
|
||||||
target prot opt source destination
|
target prot opt source destination
|
||||||
|
RETURN all -- anywhere prplOS.lan
|
||||||
NFQUEUE udp -- anywhere anywhere connbytes 0:1 connbytes mode packets connbytes direction original udp dpt:domain NFQUEUE num 2
|
NFQUEUE udp -- anywhere anywhere connbytes 0:1 connbytes mode packets connbytes direction original udp dpt:domain NFQUEUE num 2
|
||||||
NFQUEUE tcp -- anywhere anywhere connbytes 0:4 connbytes mode packets connbytes direction both tcp dpt:www NFQUEUE num 3
|
|
||||||
NFQUEUE tcp -- anywhere anywhere connbytes 0:4 connbytes mode packets connbytes direction both tcp spt:www NFQUEUE num 3
|
Send out one DNS packet
|
||||||
NFQUEUE tcp -- anywhere anywhere connbytes 0:6 connbytes mode packets connbytes direction both tcp dpt:https NFQUEUE num 4
|
|
||||||
NFQUEUE tcp -- anywhere anywhere connbytes 0:6 connbytes mode packets connbytes direction both tcp spt:https NFQUEUE num 4
|
$ R nslookup -type=A example.com. 8.8.8.8 | grep Server
|
||||||
NFQUEUE udp -- anywhere anywhere connbytes 0:1 connbytes mode packets connbytes direction original udp dpt:https NFQUEUE num 5
|
Server: 8.8.8.8
|
||||||
|
|
||||||
|
Check that packet was intercepted using the Stats
|
||||||
|
|
||||||
|
$ R "ba-cli -l PacketInterception.PacketHandler.1.Stats.NrOfPacketsReceived?" | awk NF
|
||||||
|
1
|
||||||
|
|
||||||
|
$ R "ba-cli -l PacketInterception.PacketHandler.1.Stats.NrOfPacketsAccepted?" | awk NF
|
||||||
|
1
|
||||||
|
|
||||||
Disable interception of packets:
|
Disable interception of packets:
|
||||||
|
|
||||||
$ R "ubus -S call PacketInterception _set '{\"parameters\":{\"Enable\":False}}'" ; sleep 2
|
$ R "ba-cli -l PacketInterception.Enable=False" | awk NF
|
||||||
{"PacketInterception.":{"Enable":false}}
|
0
|
||||||
{}
|
|
||||||
{"amxd-error-code":0}
|
|
||||||
|
|
||||||
Check that no interception is being configured:
|
Check that no interception is being configured:
|
||||||
|
|
||||||
$ R "iptables -t mangle -L INTERCEPT_Forward"
|
$ R "iptables -t mangle -L INTERCEPT_Output"
|
||||||
Chain INTERCEPT_Forward (0 references)
|
Chain INTERCEPT_Output (0 references)
|
||||||
target prot opt source destination
|
target prot opt source destination
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user