fy"> @ OverrideChannelPipeline getPipeline () throws Exception {filter=new ConnectionFilter ();
/ / todo configresult=Channels.pipeline (new Decoder (), new Encoder (), new DataReader ()); result;
}
}com.gmail.dosofredriver.ajax.serviceserver.server.handlers;org.jbossty.channel.ChannelEvent;org.jbossty.channel.ChannelHandlerContext;org.jbossty.channel.SimpleChannelUpstreamHandler;java.io.BufferedReader;java.io.FileReader;java.io.IOException;java.util.HashSet;java.util.Set;
/ **
* Date: 26.02.13
* Time: 14:49
*
* @ author DoSOfRR
* / class ConnectionFilter extends SimpleChannelUpstreamHandler {static final String DEFAULT_WHITELIST_PATH=«config / whitelist.txt»; static final String DEFAULT_BLACKLIST_PATH=«config / blacklist.txt»; static final int WHITELIST_ON=0; static final int BLACKLIST_ON=1; static final int WHITELIST_OFF=3; static final int BLACKLIST_OFF=4; final Set whiteList=new HashSet <> (); final Set blackList=new HashSet <> (); String whiteListPath; String blackListPath; boolean isWhiteListOn; boolean isBlackListOn; ConnectionFilter () {= false;=false;=DEFAULT_WHITELIST_PATH;=DEFAULT_BLACKLIST_PATH;
} void setOption (int list, String listPath) throws IllegalArgumentException, IOException {(list) {BLACKLIST_ON: {= listPath;=true;
} break; WHITELIST_ON: {= listPath;=true;
} break;: throw new IllegalArgumentException ();
} ();
} void setOption (int list) throws IllegalArgumentException, IOException {(list) {BLACKLIST_ON: isBlackListOn=true; break; WHITELIST_ON: isWhiteListOn=true; break; BLACKLIST_OFF: isBlackListOn=false; break; WHITELIST_OFF: isWhiteListOn=false; break;: throw new IllegalArgumentException ();
} ();
} boolean reloadLists () throws IOException {(); true;
}
@ Overridevoid handleUpstream (ChannelHandlerContext ctx, ChannelEvent e) throws Exception {addr;=ctx.getChannel (). getRemoteAddress (). toString ();=addrbstring (1, addr.indexOf (« ;: »)); (isBlackListOn) {(blackList.contains (addr)) {. getChannel (). close ();// Rejects incoming connection
}
} (isWhiteListOn) {(! whiteList.contains (addr)) {. getChannel (). close ();// Rejects incoming connection
}
}
} void loadList () throws IOException {br; line; (isBlackListOn) {= new BufferedReader (new FileReader (blackListPath)); ((line=br.readLine ())!=null) { . add (line);
}
} (isWhiteListOn) {= new BufferedReader (new FileReader (whiteListPath)); ((line=br.readLine ())!=null) {. add (line);
}
}
}
}com.gmail.dosofredriver.ajax.serviceserver.server.handlers;com.gmail.dosofredriver.ajax.serviceserver.server.session.Session;com.gmail.dosofredriver.ajax.serviceserver.server.session.SessionController;org.jbossty.channel.ChannelHandlerContext;org.jbossty.channel.ExceptionEvent;org.jbossty.channel.MessageEvent;org.jbossty.channel.S...