Skip to content

Commit

Permalink
Removed messagebox
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasFurster committed Dec 14, 2018
1 parent 4b838ed commit c243113
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
21 changes: 8 additions & 13 deletions DnsWatcher.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using System.Net;
using System.Threading;
using System.Runtime.InteropServices;
using System.Collections.Generic;

namespace DnsWatcher.ConsoleApp
Expand All @@ -14,8 +13,13 @@ class Program

public static void Main(string[] args)
{
ServicePointManager.DnsRefreshTimeout = 0;
if(!args.Any())
{
Console.WriteLine("You should provide parameters");
return;
}

ServicePointManager.DnsRefreshTimeout = 0;
CheckHostnameAsync(args);
}

Expand Down Expand Up @@ -45,20 +49,11 @@ private static void PrintIp(string hostname)
ip = e.Message;
}

Console.WriteLine($"{DateTime.Now} | {hostname.PadRight(_padLength)} -> {ip}");

if (!_currentIps.ContainsKey(hostname))
{
_currentIps.Add(hostname, ip);
}
else if (_currentIps[hostname] != ip)
if (!_currentIps.ContainsKey(hostname) || _currentIps[hostname] != ip)
{
MessageBox((IntPtr)0, ip, $"Ip of {hostname} changed...", 0);
Console.WriteLine($"{DateTime.Now} | {hostname.PadRight(_padLength)} -> {ip}");
_currentIps[hostname] = ip;
}
}

[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr h, string m, string c, int type);
}
}
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ This project is developed and build with Visual Studio 2019 Preview 1.1 and .net
.\DnsWatcher.exe google.com bing.com

12/11/2018 5:23:23 PM | google.com --> 172.217.17.110
12/11/2018 5:23:23 PM | bing.com --> 13.107.21.200
12/11/2018 5:23:23 PM | google.com --> 172.217.17.110
12/11/2018 5:23:23 PM | bing.com --> 13.107.21.200
12/11/2018 5:23:26 PM | google.com --> 172.217.17.110
12/11/2018 5:23:26 PM | bing.com --> 13.107.21.200
12/11/2018 5:23:26 PM | google.com --> 172.217.17.110
12/11/2018 5:30:22 PM | bing.com --> 204.79.197.200

![Notification](https://user-images.githubusercontent.com/7996369/49814741-956b5480-fd6a-11e8-848d-9ec124093dc7.png)

## OS limitiation
Because an MessageBox is used this project can only run on Windows... Should be easy to change though.
![Notification](https://user-images.githubusercontent.com/7996369/49814741-956b5480-fd6a-11e8-848d-9ec124093dc7.png)

0 comments on commit c243113

Please sign in to comment.