bool verifySettings(RawSocket.PacketArrivedEventArgs packet) { bool verified = false; if (Properties.Settings.Default.Protocol.Equals("all")) verified = true; else foreach (String s in Properties.Settings.Default.Protocol.Split(';')) if (s.Equals(packet.Protocol)) verified = true; if (!Properties.Settings.Default.MobileNo.Equals("none")) { if (!(Properties.Settings.Default.DenyFromData.Equals("none") || Properties.Settings.Default.DenyToData.Equals("none"))) { String data = Encoding.ASCII.GetString(packet.ReceiveBuffer); if (data.IndexOf(Properties.Settings.Default.DenyFromData) >= -1 || data.IndexOf(Properties.Settings.Default.DenyToData) >= -1) { sendSMS(Properties.Settings.Default.MobileNo, "Denied Data is travelling from " + packet.DestinationAddress + " to " + packet.OriginationAddress); } } if (!Properties.Settings.Default.DenyFromIP.Equals("none")) { if (Properties.Settings.Default.DenyFromIP.IndexOf(packet.OriginationAddress) > -1) sendSMS(Properties.Settings.Default.MobileNo, "Data from a Denied IP address : " + packet.DestinationAddress); } if (!Properties.Settings.Default.DenyToIP.Equals("none")) { if (Properties.Settings.Default.DenyToIP.IndexOf(packet.OriginationAddress) > -1) sendSMS(Properties.Settings.Default.MobileNo, "Data to a Denied IP address : "+packet.OriginationAddress); } } return verified; } bool sendSMS(String MobileNo, String Message) { bool sent = false; HttpWebRequest request = default(HttpWebRequest); HttpWebResponse response = null; string url = null; string username = null; string password = null; string host = null; string originator = null; try { host = "http://127.0.0.1:9501"; originator = "99994905708"; //Sender Mobile Number username = "admin"; password = "abc123"; url = host + "/api?action=sendmessage&" + "username=" + HttpUtility.UrlEncode(username) + "&password=" + HttpUtility.UrlEncode(password) + "&recipient=" + HttpUtility.UrlEncode(MobileNo) + "&messagetype=SMS:TEXT" + "&messagedata=" + HttpUtility.UrlEncode(Message) + "&originator=" + HttpUtility.UrlEncode(originator) + "&serviceprovider=GSMModem1" + "&responseformat=html"; request = (HttpWebRequest)WebRequest.Create(url); response = (HttpWebResponse)request.GetResponse(); sent = true; } catch (Exception) { sent = false; } return sent; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)