17 lines
635 B
Java
17 lines
635 B
Java
import java.net.*;
|
|
public class EgressProbe {
|
|
public static void main(String[] args) throws Exception {
|
|
String[] hosts = {"db", "10.5.34.202", "1.1.1.1"};
|
|
int[] ports = {3306, 3306, 443};
|
|
for (int i=0;i<hosts.length;i++) {
|
|
boolean connected=false;
|
|
try (Socket socket=new Socket()) {
|
|
socket.connect(new InetSocketAddress(hosts[i],ports[i]),1500);
|
|
connected=true;
|
|
} catch(Exception expected) {}
|
|
System.out.println(hosts[i]+":"+ports[i]+"="+(connected?"connected":"blocked"));
|
|
if ((i==0)!=connected) throw new IllegalStateException("Unexpected UAT network policy");
|
|
}
|
|
}
|
|
}
|