public void OnExternalMsg(IPToGeoFixMsg msg) { try { perf.IPGeocode.Increment(); if (!settings.IPGeocodeEnabled) { throw new NotAvailableException("GeoTracker: IP Geocoding is disabled."); } if (msg.Address.AddressFamily != AddressFamily.InterNetwork) { throw new NotSupportedException(string.Format("GeoTracker: [{0}] network addresses cannot be geocoded. Only IPv4 addresses are supported.", msg.Address.AddressFamily)); } var fix = ipGeocoder.MapIPAddress(msg.Address); router.ReplyTo(msg, new IPToGeoFixAck(fix)); } catch (Exception e) { SysLog.LogException(e); throw; } }
public void GeoTrackerMsgs_IPToGeoFixMsg() { EnhancedStream es = new EnhancedMemoryStream(); IPToGeoFixMsg msgIn, msgOut; Msg.ClearTypes(); LillTek.GeoTracker.Global.RegisterMsgTypes(); msgOut = new IPToGeoFixMsg(IPAddress.Parse("192.168.1.2")); Msg.Save(es, msgOut); es.Position = 0; msgIn = (IPToGeoFixMsg)Msg.Load(es); Assert.IsNotNull(msgIn); Assert.AreEqual(IPAddress.Parse("192.168.1.2"), msgIn.Address); // Test Clone() msgIn = (IPToGeoFixMsg)msgOut.Clone(); Assert.IsNotNull(msgIn); Assert.AreEqual(IPAddress.Parse("192.168.1.2"), msgIn.Address); }