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