如果有人试图不通过代理加入到“我的世界”服务器上,我试图暂时禁止ip接入。
String st = e.getRealAddress() + "";
if(!st.startsWith("/x.x.x.x")) {
Runtime runtime = Runtime.getRuntime();
runtime.exec("iptables -A INPUT -s " + st.replace("/","") + " -j DROP");
runtime.exec("sleep 180 ; iptables -D INPUT -s " + st.replace("/","") + " -j DROP");
}但出于某种原因,只执行-A命令,在等待了三分钟之后,我无法连接。我做错了什么?
发布于 2015-12-13 09:58:52
你可以:
使用waitFor:
Process p = Runtime.getRuntime().exec("your command iptables");
p.waitFor();https://stackoverflow.com/questions/34249804
复制相似问题