Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 7b47f44bd0ef4aa3d37f439cd7eac250f1649192 @bsiegel committed Jun 22, 2010
@@ -0,0 +1,7 @@
+syntax: regexp
+(?i)\/bin\/
+(?i)\/obj\/
+(?i)\/clientbin\/
+(?i)\.suo$
+(?i)\.user$
+(?i)\.userprefs$
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,33 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mDNSBrowser", "mDNSBrowser\mDNSBrowser.csproj", "{30979C2C-22E6-4DC0-BAD8-B56FD92AC2FA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {30979C2C-22E6-4DC0-BAD8-B56FD92AC2FA}.Debug|x86.ActiveCfg = Debug|x86
+ {30979C2C-22E6-4DC0-BAD8-B56FD92AC2FA}.Debug|x86.Build.0 = Debug|x86
+ {30979C2C-22E6-4DC0-BAD8-B56FD92AC2FA}.Release|x86.ActiveCfg = Release|x86
+ {30979C2C-22E6-4DC0-BAD8-B56FD92AC2FA}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = mDNSBrowser\mDNSBrowser.csproj
+ Policies = $0
+ $0.TextStylePolicy = $1
+ $1.inheritsSet = Mono
+ $1.inheritsScope = text/plain
+ $1.scope = text/plain
+ $0.TextStylePolicy = $2
+ $2.inheritsSet = Mono
+ $2.inheritsScope = text/plain
+ $2.scope = text/x-csharp
+ $0.CSharpFormattingPolicy = $3
+ $3.inheritsSet = Mono
+ $3.inheritsScope = text/x-csharp
+ $3.scope = text/x-csharp
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("mDNSBrowser")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
@@ -0,0 +1,31 @@
+using System;
+using Gtk;
+
+namespace mDNSBrowser
+{
+ public class ClientNode : TreeNode
+ {
+ string desc;
+ string host;
+
+
+ public ClientNode (string desc, string host)
+ {
+ this.desc = desc;
+ this.host = host;
+ }
+
+ [TreeNodeValue(Column=0)]
+ public string Description {
+
+ get { return desc; }
+
+ }
+
+ [TreeNodeValue(Column=1)]
+ public string Host {
+ get { return host; }
+ }
+ }
+}
+
@@ -0,0 +1,17 @@
+using System;
+using Gtk;
+
+namespace mDNSBrowser
+{
+ class MainClass
+ {
+ public static void Main (string[] args)
+ {
+ Application.Init ();
+ MainWindow win = new MainWindow ();
+ win.Show ();
+ Application.Run ();
+ }
+ }
+}
+
@@ -0,0 +1,142 @@
+using System;
+using Gtk;
+using Mono.Zeroconf;
+using mDNSBrowser;
+
+public partial class MainWindow : Gtk.Window
+{
+ private ServiceBrowser serviceBrowser;
+ private ServiceBrowser clientBrowser;
+ private NodeStore serviceNodes;
+ private NodeStore clientNodes;
+
+ public MainWindow () : base(Gtk.WindowType.Toplevel)
+ {
+ Build ();
+ PopulateServices ();
+
+ }
+
+ protected void OnDeleteEvent (object sender, DeleteEventArgs a)
+ {
+ Application.Quit ();
+ a.RetVal = true;
+ }
+
+ private void PopulateServices ()
+ {
+ this.serviceNodes = new NodeStore (typeof(ServiceNode));
+ this.clientNodes = new NodeStore (typeof(ClientNode));
+ this.nvServices.NodeStore = this.serviceNodes;
+ this.nvServices.AppendColumn ("Service", new Gtk.CellRendererText (), "text", 0);
+ this.nvServices.NodeSelection.Changed += new EventHandler(HandleNodeSelectionChanged);
+ this.nvClients.NodeStore = this.clientNodes;
+ this.nvClients.AppendColumn ("Description", new CellRendererText(), "text", 0);
+ this.nvClients.AppendColumn ("Host", new CellRendererText (), "text", 1);
+ try {
+ serviceBrowser = new ServiceBrowser ();
+ } catch (Exception e) {
+ Console.WriteLine (e.ToString ());
+ }
+ serviceBrowser.ServiceAdded += new ServiceBrowseEventHandler (HandleDiscoverServiceTypes);
+ serviceBrowser.Browse ("_services._dns-sd._udp", "local");
+ }
+
+ private void PopulateClients(ServiceNode serviceNode)
+ {
+ if (clientBrowser != null)
+ {
+ clientBrowser.ServiceAdded -= new ServiceBrowseEventHandler (HandleServiceAdded);
+ clientBrowser.ServiceRemoved -= new ServiceBrowseEventHandler (HandleServiceRemoved);
+ clientBrowser.Dispose();
+ clientBrowser = null;
+ }
+
+ try {
+ clientBrowser = new ServiceBrowser ();
+ } catch (Exception e) {
+ Console.WriteLine (e.ToString ());
+ return;
+ }
+
+ clientNodes.Clear();
+
+ clientBrowser.ServiceAdded += new ServiceBrowseEventHandler (HandleServiceAdded);
+ clientBrowser.ServiceRemoved += new ServiceBrowseEventHandler (HandleServiceRemoved);
+
+ clientBrowser.Browse (serviceNode.Type, "local");
+ }
+
+ void HandleNodeSelectionChanged (object sender, EventArgs e)
+ {
+ NodeSelection selection = (NodeSelection) sender;
+ ServiceNode serviceNode =((ServiceNode)selection.SelectedNode);
+ PopulateClients(serviceNode);
+ }
+
+ void HandleDiscoverServiceTypes (object o, ServiceBrowseEventArgs args)
+ {
+ IResolvableService svc = args.Service;
+ string svcType = svc.Name + "." + svc.RegType.Substring (0, svc.RegType.Length - 7);
+ string svcName = ServiceNode.GetNameFromType(svcType);
+ int insertPos = 0;
+ foreach (ServiceNode node in serviceNodes)
+ {
+ if (node.Type == svcType)
+ return;
+ }
+ foreach (ServiceNode node in serviceNodes)
+ {
+ if (node.Name.CompareTo(svcName) > 0)
+ break;
+ insertPos++;
+ }
+
+ serviceNodes.AddNode (new ServiceNode (svcType, svcName), insertPos);
+ this.nvServices.QueueDraw ();
+ }
+
+ void HandleServiceAdded (object o, ServiceBrowseEventArgs args)
+ {
+ IResolvableService svc = args.Service;
+ svc.Resolved += new ServiceResolvedEventHandler(HandleServiceAddResolved);
+ svc.Resolve();
+ }
+
+ void HandleServiceAddResolved (object o, ServiceResolvedEventArgs args)
+ {
+ IResolvableService svc = o as IResolvableService;
+ string desc = svc.Name;
+ string host = svc.HostEntry.AddressList[0].ToString();
+ foreach (ClientNode node in nvClients.NodeStore)
+ {
+ if (node.Description == desc && node.Host == host)
+ return;
+ }
+ clientNodes.AddNode(new ClientNode(desc, host));
+ this.nvClients.QueueDraw ();
+ }
+
+ void HandleServiceRemoveResolved (object o, ServiceResolvedEventArgs args)
+ {
+ IResolvableService svc = o as IResolvableService;
+
+ string desc = svc.Name;
+ string host = svc.HostEntry.AddressList[0].ToString ();
+ foreach (ClientNode node in nvClients.NodeStore) {
+ if (node.Description == desc && node.Host == host) {
+ clientNodes.RemoveNode(node);
+ this.nvClients.QueueDraw ();
+ return;
+ }
+ }
+ }
+
+ void HandleServiceRemoved (object o, ServiceBrowseEventArgs args)
+ {
+ IResolvableService svc = args.Service;
+ svc.Resolved += new ServiceResolvedEventHandler (HandleServiceRemoveResolved);
+ svc.Resolve ();
+ }
+}
+
@@ -0,0 +1,111 @@
+using System;
+using Gtk;
+using System.Collections.Generic;
+
+namespace mDNSBrowser
+{
+
+ public class ServiceNode : TreeNode
+ {
+ private static Dictionary<string, string> serviceNames = new Dictionary<string, string> {
+ { "_afpovertcp._tcp", "AppleTalk Filing Protocol (AFP)" },
+ { "_nfs._tcp", "Network File System (NFS)" },
+ { "_webdav._tcp", "WebDAV File System (WEBDAV)" },
+ { "_ftp._tcp", "File Transfer Protocol (FTP)" },
+ { "_ssh._tcp", "Secure Shell (SSH)" },
+ { "_eppc._tcp", "Remote AppleEvents" },
+ { "_http._tcp", "Web Server (HTTP)" },
+ { "_telnet._tcp", "Remote Login (Telnet)" },
+ { "_printer._tcp", "Line Printer Daemon (LPD/LPR)" },
+ { "_ipp._tcp", "Internet Printing Protocol (IPP)" },
+ { "_pdl-datastream._tcp", "PDL Data Stream (Port 9100)" },
+ { "_riousbprint._tcp", "Remote I/O USB Printer Protocol" },
+ { "_daap._tcp", "Digital Audio Access Protocol (DAAP)" },
+ { "_dpap._tcp", "Digital Photo Access Protocol (DPAP)" },
+ { "_ichat._tcp", "iChat Instant Messaging" },
+ { "_presence._tcp", "iChat Instant Messaging Presence" },
+ { "_ica-networking._tcp", "Image Capture Sharing" },
+ { "_airport._tcp", "Apple AirPort Base Station" },
+ { "_xserveraid._tcp", "Apple Xserve RAID" },
+ { "_distcc._tcp", "Distributed Compiler" },
+ { "_apple-sasl._tcp", "Apple Password Server" },
+ { "_workstation._tcp", "Workstation" },
+ { "_servermgr._tcp", "Apple Server Administration" },
+ { "_raop._tcp", "Remote Audio Output Protocol (RAOP)" },
+ { "_iTouch._tcp", "Logitech Touch Mouse Service" },
+ { "_pulse-server._tcp", "PulseAudio Sound Server" },
+ { "_pulse-sink._tcp", "PulseAudio Sound Sink" },
+ { "_pulse-source._tcp", "PulseAudio Sound Source" },
+ { "_rfb._tcp", "VNC Remote Access" },
+ { "_sftp-ssh._tcp", "Secure File Transfer over SSH (SFTP)" },
+ { "_smb._tcp", "Windows File Sharing (SMB)" },
+ { "_https._tcp", "Web Server (HTTPS)" },
+ { "_rss._tcp", "RSS Web Syndication" },
+ { "_domain._udp", "Domain Name System (DNS)" },
+ { "_ntp._udp", "Network Time Protocol (NTP)" },
+ { "_tftp._udp", "Trivial File Transfer Protocol (TFTP)" },
+ { "_webdavs._tcp", "Secure WebDAV File System (WEBDAVS)" },
+ { "_apt._tcp", "APT Package Repository" },
+ { "_timbuktu._tcp", "Timbuktu Remote Desktop" },
+ { "_net-assistant._udp", "Apple Net Assistant" },
+ { "_dacp._tcp", "Digital Audio Control Protocol (DACP)" },
+ { "_realplayfavs._tcp", "RealPlayer Shared Favorites" },
+ { "_rtsp._tcp", "RTSP Realtime Streaming Server" },
+ { "_rtp._udp", "RTP Realtime Streaming Server" },
+ { "_mpd._tcp", "Music Player Daemon" },
+ { "_touch-able._tcp", "iPod Touch Music Library" },
+ { "_vlc-http._tcp", "VLC Streaming" },
+ { "_sip._udp", "SIP Telephony" },
+ { "_h323._tcp", "H.323 Telephony" },
+ { "_presence_olpc._tcp", "OLPC Presence" },
+ { "_iax._udp", "Asterisk Exchange" },
+ { "_skype._tcp", "Skype VOIP" },
+ { "_see._tcp", "SubEthaEdit Collaborative Text Editor" },
+ { "_lobby._tcp", "Gobby Collaborative Editor Session" },
+ { "_postgresql._tcp", "PostgreSQL Server" },
+ { "_svn._tcp", "Subversion Revision Control" },
+ { "_adobe-vc._tcp", "Adobe Version Cue" },
+ { "_acrobatSRV._tcp", "Adobe Acrobat" },
+ { "_omni-bookmark._tcp", "OmniWeb Bookmark Sharing" },
+ { "_ksysguard._tcp", "KDE System Guard" },
+ { "_MacOSXDupSuppress._tcp", "Mac OS X Duplicate Machine Suppression" },
+ { "_pgpkey-hkp._tcp", "GnuPG/PGP HKP Key Server" },
+ { "_ldap._tcp", "LDAP Directory Server" },
+ { "_tp._tcp", "Thousand Parsec Server" },
+ { "_tps._tcp", "Thousand Parsec Server (Secure)" },
+ { "_tp-http._tcp", "Thousand Parsec Server (HTTP Tunnel)" },
+ { "_tp-https._tcp", "Thousand Parsec Server (Secure HTTP Tunnel)" }
+ };
+
+
+ string name;
+ string type;
+
+ public ServiceNode (string type, string name)
+ {
+ this.type = type;
+ this.name = name;
+ }
+
+ [TreeNodeValue(Column = 0)]
+ public string Name {
+
+
+ get { return name; }
+
+ }
+
+ public string Type {
+ get { return type;}
+ }
+
+ public static string GetNameFromType (string type)
+ {
+ if (serviceNames.ContainsKey(type))
+ return serviceNames[type];
+
+ return type;
+ }
+ }
+}
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 7b47f44

Please sign in to comment.