diff --git a/.gitlab/tests/cram/generic/acceleration-plan-components/080-packet-interception.t b/.gitlab/tests/cram/generic/acceleration-plan-components/080-packet-interception.t index e211ab6d8d..287646da28 100644 --- a/.gitlab/tests/cram/generic/acceleration-plan-components/080-packet-interception.t +++ b/.gitlab/tests/cram/generic/acceleration-plan-components/080-packet-interception.t @@ -2,47 +2,74 @@ Create R alias: $ alias R="${CRAM_REMOTE_COMMAND:-}" -Check PacketInterception root datamodel: +Check PacketInterception root datamodel and Status: - $ R "ubus -S call PacketInterception _get" - {"PacketInterception.":{"InterceptionNumberOfEntries":3,"Enable":false,"PacketHandlerNumberOfEntries":1,"ConditionNumberOfEntries":5,"Status":"Disabled"}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l PacketInterception.Status?" | awk NF + Disabled -Check that no interception is being configured: +Check that no iptables rules are being configured: $ R "iptables -t mangle -L INTERCEPT_Forward" Chain INTERCEPT_Forward (0 references) 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 - {"PacketInterception.":{"Enable":true}} + $ R "ba-cli -l PacketInterception.Enable=True" | awk NF + 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} -Check that interception is configured properly: +Add a new Intercept - $ R "iptables -t mangle -L INTERCEPT_Forward" - Chain INTERCEPT_Forward (1 references) + $ R "ubus -S call PacketInterception.Interception.3.Intercept _add '{\"parameters\":{\"Alias\":\"test\",\"Enable\":True,\"Condition\":\"DNS\", \"NumberOfPackets\":1, \"PacketHandler\":\"default_handler\"}}'" ; sleep 2 + {"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 + 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 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 - 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 - NFQUEUE udp -- anywhere anywhere connbytes 0:1 connbytes mode packets connbytes direction original udp dpt:https NFQUEUE num 5 + +Send out one DNS packet + + $ R nslookup -type=A example.com. 8.8.8.8 | grep Server + 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: - $ R "ubus -S call PacketInterception _set '{\"parameters\":{\"Enable\":False}}'" ; sleep 2 - {"PacketInterception.":{"Enable":false}} - {} - {"amxd-error-code":0} + $ R "ba-cli -l PacketInterception.Enable=False" | awk NF + 0 Check that no interception is being configured: - $ R "iptables -t mangle -L INTERCEPT_Forward" - Chain INTERCEPT_Forward (0 references) + $ R "iptables -t mangle -L INTERCEPT_Output" + Chain INTERCEPT_Output (0 references) target prot opt source destination