/// <summary> /// Filters sender. /// </summary> /// <param name="from">Sender.</param> /// <param name="api">Reference to server API.</param> /// <param name="session">Reference to SMTP session.</param> /// <param name="errorText">Filtering error text what is returned to client. ASCII text, 100 chars maximum.</param> /// <returns>Returns true if sender is ok or false if rejected.</returns> public bool Filter(string from,IMailServerApi api,SMTP_Session session,out string errorText) { errorText = ""; string ip = session.RemoteEndPoint.Address.ToString(); Dns_Client dns = new Dns_Client(); bool ok = false; // Don't check PTR for authenticated session and LAN IP ranges if(session.Authenticated || ip.StartsWith("127.0.0.1") || ip.StartsWith("10.") || ip.StartsWith("192.168")){ return true; } DnsServerResponse reponse = dns.Query(ip,QTYPE.PTR); if(reponse.ResponseCode == RCODE.NO_ERROR){ foreach(PTR_Record rec in reponse.GetPTRRecords()){ if(rec.DomainName.ToLower() == session.EhloName.ToLower()){ ok = true; break; } } } if(!ok){ errorText = "Bad EHLO/HELO name, you must have valid DNS PTR record for your EHLO name and IP."; } return ok; }
//------------------------------------------------------------------------------------------- private string LookupA(string recordname, string sectiontext) { Dns_Client dc = new LumiSoft.Net.Dns.Client.Dns_Client(); DnsServerResponse dsr = null; try { dsr = dc.Query(recordname, LumiSoft.Net.Dns.Client.QTYPE.A); } catch (Exception ex) { throw new Exception("DNS A record query for " + recordname + " failed.", ex); } DNS_rr_A[] records = dsr.GetARecords(); string response = sectiontext; if (records.Length < 1) { fail = true; } for (int i = 0; i < records.Length; i++) { response += (i + 1) + ". "; response += records[i].IP + " with a TTL of " + records[i].TTL + "<br>"; response += CheckPort(records[i].IP.ToString(), 5222); response += CheckPort(records[i].IP.ToString(), 5223); response += CheckPort(records[i].IP.ToString(), 5269); response += CheckPort(records[i].IP.ToString(), 5270); } return(response); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_HINFO Parse(byte[] reply, ref int offset, int rdLength, int ttl) { /* RFC 1035 3.3.2. HINFO RDATA format * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * / CPU / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * / OS / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * * CPU A <character-string> which specifies the CPU type. * * OS A <character-string> which specifies the operating * system type. * * Standard values for CPU and OS can be found in [RFC-1010]. * */ // CPU string cpu = Dns_Client.ReadCharacterString(reply, ref offset); // OS string os = Dns_Client.ReadCharacterString(reply, ref offset); return(new DNS_rr_HINFO(cpu, os, ttl)); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_TXT Parse(byte[] reply, ref int offset, int rdLength, int ttl) { // TXT RR string text = Dns_Client.ReadCharacterString(reply, ref offset); return(new DNS_rr_TXT(text, ttl)); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_CNAME Parse(byte[] reply, ref int offset, int rdLength, int ttl) { string name = ""; if (Dns_Client.GetQName(reply, ref offset, ref name)) { return(new DNS_rr_CNAME(name, ttl)); } else { throw new ArgumentException("Invalid CNAME resource record data !"); } }
/// <summary> /// Cleans up any resource being used. /// </summary> public void Dispose() { m_pTimeoutTimer.Dispose(); m_pTimeoutTimer = null; m_pOwner.m_pTransactions.Remove(this.ID); m_pOwner = null; m_pQuery = null; m_pResponse = null; this.Timeout = null; this.Completed = null; }
/// <summary> /// Default constructor. /// </summary> public SIP_Stack() { m_pTransportLayer = new SIP_TransportLayer(this); m_pTransactionLayer = new SIP_TransactionLayer(this); m_pNonceManager = new Auth_HttpDigest_NonceManager(); m_pProxyServers = new List<SIP_Uri>(); m_pRegistrations = new List<SIP_UA_Registration>(); m_pCredentials = new List<NetworkCredential>(); m_RegisterCallID = SIP_t_CallID.CreateCallID(); m_pLogger = new Logger(); m_pDnsClient = new Dns_Client(); }
//------------------------------------------------------------------------------------------- private string LookupSRV(string recordname, string domain, string sectiontext) { recordname += domain; Dns_Client dc = new LumiSoft.Net.Dns.Client.Dns_Client(); DnsServerResponse dsr = null; try { dsr = dc.Query(recordname, LumiSoft.Net.Dns.Client.QTYPE.SRV); } catch (Exception ex) { return("<span style='color:red'>DNS SRV record query for " + recordname + domain + " timed out.</span>"); } DNS_rr_SRV[] records = dsr.GetSRVRecords(); string response = sectiontext; if (records.Length < 1) { fail = true; } for (int i = 0; i < records.Length; i++) { DnsServerResponse dsr2; try { dsr2 = dc.Query(records[i].Target, QTYPE.A); } catch (Exception ex) { throw new Exception("DNS sub A record query for " + domain + " failed.", ex); } DNS_rr_A[] aRecs = dsr2.GetARecords(); response += (i + 1) + ". "; response += records[i].Target + " on port " + records[i].Port + " with a TTL of " + records[i].TTL + " and a priority of " + records[i].Priority + "<br />"; for (int x = 0; x < aRecs.Length; x++) { response += " ----> Resolves to " + aRecs[x].IP + "<br />"; response += CheckPort(aRecs[x].IP, records[i].Port); response += CheckPort(aRecs[x].IP, 5223); } } return(response); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_SRV Parse(byte[] reply, ref int offset, int rdLength, int ttl) { // Priority Weight Port Target // Priority int priority = reply[offset++] << 8 | reply[offset++]; // Weight int weight = reply[offset++] << 8 | reply[offset++]; // Port int port = reply[offset++] << 8 | reply[offset++]; // Target string target = ""; Dns_Client.GetQName(reply, ref offset, ref target); return(new DNS_rr_SRV(priority, weight, port, target, ttl)); }
/// <summary> /// Resolves host name to IP addresses. /// </summary> /// <param name="host">Host name or IP address.</param> /// <returns>Return specified host IP addresses.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>host</b> is null.</exception> public static IPAddress[] Resolve(string host) { if (host == null) { throw new ArgumentNullException("host"); } // If hostName_IP is IP try{ return(new IPAddress[] { IPAddress.Parse(host) }); } catch { } // This is probably NetBios name if (host.IndexOf(".") == -1) { return(System.Net.Dns.GetHostEntry(host).AddressList); } else { // hostName_IP must be host name, try to resolve it's IP Dns_Client dns = new Dns_Client(); DnsServerResponse resp = dns.Query(host, QTYPE.A); if (resp.ResponseCode == RCODE.NO_ERROR) { DNS_rr_A[] records = resp.GetARecords(); IPAddress[] retVal = new IPAddress[records.Length]; for (int i = 0; i < records.Length; i++) { retVal[i] = records[i].IP; } return(retVal); } else { throw new Exception(resp.ResponseCode.ToString()); } } }
/// <summary> /// Default constructor. /// </summary> /// <param name="owner">Owner DNS client.</param> /// <param name="id">Transaction ID.</param> /// <param name="qname">QNAME value.</param> /// <param name="qtype">QTYPE value.</param> /// <param name="timeout">Timeout in milliseconds.</param> /// <param name="query">Raw DNS query.</param> /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> or <b>query</b> is null reference.</exception> public DnsTransaction(Dns_Client owner, int id, string qname, int qtype, int timeout, byte[] query) { if (owner == null) { throw new ArgumentNullException("owner"); } if (query == null) { throw new ArgumentNullException("query"); } m_pOwner = owner; m_ID = id; m_pQuery = query; m_QName = qname; m_QType = qtype; m_CreateTime = DateTime.Now; m_pTimeoutTimer = new TimerEx(timeout); m_pTimeoutTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_pTimeoutTimer_Elapsed); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_NAPTR Parse(byte[] reply, ref int offset, int rdLength, int ttl) { /* RFC 3403. * The packet format for the NAPTR record is as follows * 1 1 1 1 1 1 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | ORDER | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PREFERENCE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / FLAGS / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / SERVICES / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / REGEXP / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / REPLACEMENT / | / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ */ int order = reply[offset++] << 8 | reply[offset++]; int preference = reply[offset++] << 8 | reply[offset++]; string flags = Dns_Client.ReadCharacterString(reply, ref offset); string services = Dns_Client.ReadCharacterString(reply, ref offset); string regexp = Dns_Client.ReadCharacterString(reply, ref offset); string replacement = ""; Dns_Client.GetQName(reply, ref offset, ref replacement); return(new DNS_rr_NAPTR(order, preference, flags, services, regexp, replacement, ttl)); }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_MX Parse(byte[] reply, ref int offset, int rdLength, int ttl) { /* RFC 1035 3.3.9. MX RDATA format * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | PREFERENCE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | / EXCHANGE / | / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | where: | | PREFERENCE | A 16 bit integer which specifies the preference given to | this RR among others at the same owner. Lower values | are preferred. | | EXCHANGE | A <domain-name> which specifies a host willing to act as | a mail exchange for the owner name. */ int pref = reply[offset++] << 8 | reply[offset++]; string name = ""; if (Dns_Client.GetQName(reply, ref offset, ref name)) { return(new DNS_rr_MX(pref, name, ttl)); } else { throw new ArgumentException("Invalid MX resource record data !"); } }
/// <summary> /// Parses resource record from reply data. /// </summary> /// <param name="reply">DNS server reply data.</param> /// <param name="offset">Current offset in reply data.</param> /// <param name="rdLength">Resource record data length.</param> /// <param name="ttl">Time to live in seconds.</param> public static DNS_rr_SOA Parse(byte[] reply, ref int offset, int rdLength, int ttl) { /* RFC 1035 3.3.13. SOA RDATA format * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * / MNAME / * / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ * / RNAME / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | SERIAL | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | REFRESH | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RETRY | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | EXPIRE | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | MINIMUM | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | where: | | MNAME The <domain-name> of the name server that was the | original or primary source of data for this zone. | | RNAME A <domain-name> which specifies the mailbox of the | person responsible for this zone. | | SERIAL The unsigned 32 bit version number of the original copy | of the zone. Zone transfers preserve this value. This | value wraps and should be compared using sequence space | arithmetic. | | REFRESH A 32 bit time interval before the zone should be | refreshed. | | RETRY A 32 bit time interval that should elapse before a | failed refresh should be retried. | | EXPIRE A 32 bit time value that specifies the upper limit on | the time interval that can elapse before the zone is no | longer authoritative. | | MINIMUM The unsigned 32 bit minimum TTL field that should be | exported with any RR from this zone. */ //---- Parse record -------------------------------------------------------------// // MNAME string nameserver = ""; Dns_Client.GetQName(reply, ref offset, ref nameserver); // RNAME string adminMailBox = ""; Dns_Client.GetQName(reply, ref offset, ref adminMailBox); char[] adminMailBoxAr = adminMailBox.ToCharArray(); for (int i = 0; i < adminMailBoxAr.Length; i++) { if (adminMailBoxAr[i] == '.') { adminMailBoxAr[i] = '@'; break; } } adminMailBox = new string(adminMailBoxAr); // SERIAL long serial = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++]; // REFRESH long refresh = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++]; // RETRY long retry = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++]; // EXPIRE long expire = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++]; // MINIMUM long minimum = reply[offset++] << 24 | reply[offset++] << 16 | reply[offset++] << 8 | reply[offset++]; //--------------------------------------------------------------------------------// return(new DNS_rr_SOA(nameserver, adminMailBox, serial, refresh, retry, expire, minimum, ttl)); }
//------------------------------------------------------------------------------------------- private string LookupA(string recordname, string sectiontext) { Dns_Client dc = new LumiSoft.Net.Dns.Client.Dns_Client(); DnsServerResponse dsr = null; try { dsr = dc.Query(recordname, LumiSoft.Net.Dns.Client.QTYPE.A); } catch (Exception ex) { throw new Exception("DNS A record query for " + recordname + " failed.", ex); } DNS_rr_A[] records = dsr.GetARecords(); string response = sectiontext; if (records.Length < 1) fail = true; for (int i = 0; i < records.Length; i++) { response += (i + 1) + ". "; response += records[i].IP + " with a TTL of " + records[i].TTL + "<br>"; response += CheckPort(records[i].IP.ToString(), 5222); response += CheckPort(records[i].IP.ToString(), 5223); response += CheckPort(records[i].IP.ToString(), 5269); response += CheckPort(records[i].IP.ToString(), 5270); } return response; }
/// <summary> /// Resolves host name to IP addresses. /// </summary> /// <param name="host">Host name or IP address.</param> /// <returns>Return specified host IP addresses.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>host</b> is null.</exception> public static IPAddress[] Resolve(string host) { if(host == null){ throw new ArgumentNullException("host"); } // If hostName_IP is IP try{ return new IPAddress[]{IPAddress.Parse(host)}; } catch{ } // This is probably NetBios name if(host.IndexOf(".") == -1){ return System.Net.Dns.GetHostEntry(host).AddressList; } else{ // hostName_IP must be host name, try to resolve it's IP Dns_Client dns = new Dns_Client(); DnsServerResponse resp = dns.Query(host,QTYPE.A); if(resp.ResponseCode == RCODE.NO_ERROR){ DNS_rr_A[] records = resp.GetARecords(); IPAddress[] retVal = new IPAddress[records.Length]; for(int i=0;i<records.Length;i++){ retVal[i] = records[i].IP; } return retVal; } else{ throw new Exception(resp.ResponseCode.ToString()); } } }
//------------------------------------------------------------------------------------------- private string LookupSRV(string recordname, string domain, string sectiontext) { recordname += domain; Dns_Client dc = new LumiSoft.Net.Dns.Client.Dns_Client(); DnsServerResponse dsr = null; try { dsr = dc.Query(recordname, LumiSoft.Net.Dns.Client.QTYPE.SRV); } catch (Exception ex) { return "<span style='color:red'>DNS SRV record query for " + recordname + domain + " timed out.</span>"; } DNS_rr_SRV[] records = dsr.GetSRVRecords(); string response = sectiontext; if (records.Length < 1) fail = true; for (int i = 0; i < records.Length; i++) { DnsServerResponse dsr2; try { dsr2 = dc.Query(records[i].Target, QTYPE.A); } catch (Exception ex) { throw new Exception("DNS sub A record query for " + domain + " failed.", ex); } DNS_rr_A[] aRecs = dsr2.GetARecords(); response += (i + 1) + ". "; response += records[i].Target + " on port " + records[i].Port + " with a TTL of " + records[i].TTL + " and a priority of " + records[i].Priority + "<br />"; for (int x = 0; x < aRecs.Length; x++) { response += " ----> Resolves to " + aRecs[x].IP + "<br />"; response += CheckPort(aRecs[x].IP, records[i].Port); response += CheckPort(aRecs[x].IP, 5223); } } return response; }
/// <summary> /// Gets specified email domain SMTP hosts. Values are in descending priority order. /// </summary> /// <param name="domain">Domain name. This value can be email address too, then domain parsed automatically.</param> /// <returns>Returns specified email domain SMTP hosts.</returns> /// <exception cref="ArgumentNullException">Is raised when <b>domain</b> is null.</exception> /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception> /// <exception cref="DNS_ClientException">Is raised when DNS query failure.</exception> public static string[] GetDomainHosts(string domain) { if(domain == null){ throw new ArgumentNullException("domain"); } if(string.IsNullOrEmpty(domain)){ throw new ArgumentException("Invalid argument 'domain' value, you need to specify domain value."); } // We have email address, parse domain. if(domain.IndexOf("@") > -1){ domain = domain.Substring(domain.IndexOf('@') + 1); } List<string> retVal = new List<string>(); // Get MX records. Dns_Client dns = new Dns_Client(); DnsServerResponse response = dns.Query(domain,QTYPE.MX); if(response.ResponseCode == RCODE.NO_ERROR){ foreach(DNS_rr_MX mx in response.GetMXRecords()){ // Block invalid MX records. if(!string.IsNullOrEmpty(mx.Host)){ retVal.Add(mx.Host); } } } else{ throw new DNS_ClientException(response.ResponseCode); } /* RFC 2821 5. If no MX records are found, but an A RR is found, the A RR is treated as if it was associated with an implicit MX RR, with a preference of 0, pointing to that host. */ if(retVal.Count == 0){ retVal.Add(domain); } return retVal.ToArray(); }
/// <summary> /// Filters sender. /// </summary> /// <param name="from">Sender.</param> /// <param name="api">Reference to server API.</param> /// <param name="session">Reference to SMTP session.</param> /// <param name="errorText">Filtering error text what is returned to client. ASCII text, 100 chars maximum.</param> /// <returns>Returns true if sender is ok or false if rejected.</returns> public bool Filter(string from,IMailServerApi api,SMTP_Session session,out string errorText) { errorText = null; bool ok = true; // Don't check authenticated users or LAN IP if(session.Authenticated || IsPrivateIP(session.RemoteEndPoint.Address)){ return true; } try{ //--- Load data ----------------------- DataSet ds = new DataSet(); ds.Tables.Add("General"); ds.Tables["General"].Columns.Add("CheckHelo"); ds.Tables.Add("BlackListSettings"); ds.Tables["BlackListSettings"].Columns.Add("ErrorText"); ds.Tables.Add("BlackList"); ds.Tables["BlackList"].Columns.Add("IP"); ds.Tables.Add("Servers"); ds.Tables["Servers"].Columns.Add("Cost"); ds.Tables["Servers"].Columns.Add("Server"); ds.Tables["Servers"].Columns.Add("DefaultRejectionText"); ds.ReadXml(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\lsDNSBL_Filter_db.xml"); Dns_Client dns = new Dns_Client(); #region General if(ds.Tables["General"].Rows.Count == 1){ if(Convert.ToBoolean(ds.Tables["General"].Rows[0]["CheckHelo"])){ DnsServerResponse response = dns.Query(session.EhloName,QTYPE.A); // If dns server connection errors, don't block. if(response.ConnectionOk && response.ResponseCode != RCODE.SERVER_FAILURE){ bool found = false; foreach(A_Record a in response.GetARecords()){ if(session.RemoteEndPoint.Address.ToString() == a.IP){ found = true; break; } } if(!found){ errorText = "Not valid DNS EHLO/HELO name '" + session.EhloName + "' !"; return false; } } } } #endregion #region Balck List foreach (DataRow dr in ds.Tables["BlackList"].Rows){ if(IsAstericMatch(dr["IP"].ToString(),session.RemoteEndPoint.Address.ToString())){ errorText = ds.Tables["BlackListSettings"].Rows[0]["ErrorText"].ToString(); return false; } } #endregion #region DNSBL foreach(DataRow dr in ds.Tables["Servers"].Rows){ DnsServerResponse dnsResponse = dns.Query(ReverseIP(session.RemoteEndPoint.Address) + "." + dr["Server"].ToString(),QTYPE.ANY); A_Record[] recs = dnsResponse.GetARecords(); if(recs.Length > 0){ // Logging blocking WriteFilterLog("Sender:" + from + " IP:" + session.RemoteEndPoint.Address.ToString() + " blocked\r\n"); errorText = dr["DefaultRejectionText"].ToString(); // Server provided return text, use it if(dnsResponse.GetTXTRecords().Length > 0){ errorText = dnsResponse.GetTXTRecords()[0].Text; } if(errorText == ""){ errorText = "You are in '" + dr["Server"].ToString() + "' rejection list !"; } return false; } } #endregion } catch{ } return ok; }
private void m_pTestDns_Click(object sender, EventArgs e) { Dns_Client.DnsServers = new string[]{m_pDns1.Text}; Dns_Client.UseDnsCache = false; Dns_Client dns = new Dns_Client(); DnsServerResponse response = dns.Query("lumisoft.ee",QTYPE.MX); if(!response.ConnectionOk || response.ResponseCode != RCODE.NO_ERROR){ MessageBox.Show(this,"Invalid dns server(" + m_pDns1.Text + "), can't resolve lumisoft.ee","Info",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } Dns_Client.DnsServers = new string[]{m_pDns2.Text}; Dns_Client.UseDnsCache = false; Dns_Client dns2 = new Dns_Client(); response = dns2.Query("lumisoft.ee",QTYPE.MX); if(!response.ConnectionOk || response.ResponseCode != RCODE.NO_ERROR){ MessageBox.Show(this,"Invalid dns server(" + m_pDns2.Text + "), can't resolve lumisoft.ee","Info",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } MessageBox.Show(this,"Ok.","Info",MessageBoxButtons.OK,MessageBoxIcon.Information); }