110 | - # Check that with invalid rpcallowip, we are denied
111 | - self.run_allowip_test([non_loopback_ip], non_loopback_ip, defaultport)
112 | - assert_raises_rpc_error(-342, "non-JSON HTTP response with '403 Forbidden' from server", self.run_allowip_test, ['1.1.1.1'], non_loopback_ip, defaultport)
113 | + # Check that with invalid rpcallowip, we are denied
114 | + self.run_allowip_test([non_loopback_ip], non_loopback_ip, defaultport)
115 | + assert_raises_rpc_error(-342, "non-JSON HTTP response with '403 Forbidden' from server", self.run_allowip_test, ['1.1.1.1'], non_loopback_ip, defaultport)
The allowip test could also be done by connecting from a second loopback IP, say, 127.0.0.2. This would obliterate the need for a non loopback IP, but would need support in the test framework at the RPC/HTTP level for binding to a different address before outgoing connection (connecting to a different interface IP does that part automatically...)
Ughh, I tried this but it doesn't work. Apparently the entire IPv4 subnet is unconditionally allowed.
rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet
(It works when removing the , 8 - the full changes are here: https://github.com/laanwj/bitcoin/commit/0dad20fe2f9ef3c053b007704f46fd1f0e26fc5f)
(It would also work for IPv6, as it only binds on a single localhost IP there. But that won't help for Travis)
@laanwj It depends on the IP stack implementation. Some only allow the use of only 127.0.0.1 while others seem to effectively bind 127/8. I think it would be best to rely only on 127.0.0.1 and ::1 for loopback-based IPv4/IPv6 compatibility checks.
This is a linux-specific test though, so in this test we can asume /8 and don't care about other IP stack implementations.