BanningFiltering IPs
Version 3 (Alan McGovern, 10/24/2010 08:21 PM) → Version 4/5 (Alan McGovern, 10/24/2010 08:22 PM)
h1. BanningFiltering IPs
h2. This example shows how to prevent a connection being made to the IPAddress '192.168.0.5'
<pre><code class="java">
private void BanPeer (ClientEngine engine)
{
// Hook up a handler to the 'BanPeer' event. This is raised
// every time a connection is received or an outgoing connection
// is about to be created. If you wish to close/abort the connection
// just set "BanPeer" to true.
engine.ConnectionManager.BanPeer += delegate(object sender, AttemptConnectionEventArgs e) {
if (e.Peer.ConnectionUri.Host == "192.168.0.5")
e.BanPeer = true;
};
}
</code></pre>