« Previous - Version 4/5 (diff) - Next » - Current version
Alan McGovern, 10/24/2010 08:22 PM


BanningFiltering IPs

This example shows how to prevent a connection being made to the IPAddress '192.168.0.5'

 1 private void BanPeer (ClientEngine engine)
 2 {
 3     // Hook up a handler to the 'BanPeer' event. This is raised
 4     // every time a connection is received or an outgoing connection
 5     // is about to be created. If you wish to close/abort the connection
 6     // just set "BanPeer" to true.
 7     engine.ConnectionManager.BanPeer += delegate(object sender, AttemptConnectionEventArgs e) {
 8         if (e.Peer.ConnectionUri.Host == "192.168.0.5")
 9             e.BanPeer = true;
10     };
11 }

Also available in: HTML TXT