File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -295,18 +295,41 @@ private void ShareDiscovery(string[] computerTargets)
295295 // skip any that are in the exclusion list
296296 continue ;
297297 }
298+ // Perform reverse lookup if the computer is an IP address
299+ var computerName = "" ;
300+ if ( isIP ( computer ) )
301+ {
302+ try
303+ {
304+ Mq . Trace ( "Performing reverse lookup for " + computer ) ;
305+ IPHostEntry result = Dns . GetHostEntry ( computer ) ;
306+ computerName = result . HostName ;
307+ Mq . Trace ( "Got DNSName " + computerName + " for " + computer ) ;
308+ }
309+ catch ( Exception e )
310+ {
311+ Mq . Degub ( e . Message ) ;
312+ // Keep IP if Reverse Lookup fails
313+ computerName = computer ;
314+ }
315+ }
316+ else
317+ {
318+ // Use the provided computer name if it's not an IP address
319+ computerName = computer ;
320+ }
298321 // ShareFinder Task Creation - this kicks off the rest of the flow
299- Mq . Trace ( "Creating a ShareFinder task for " + computer ) ;
322+ Mq . Trace ( "Creating a ShareFinder task for " + computerName ) ;
300323 ShareTaskScheduler . New ( ( ) =>
301324 {
302325 try
303326 {
304327 ShareFinder shareFinder = new ShareFinder ( ) ;
305- shareFinder . GetComputerShares ( computer ) ;
328+ shareFinder . GetComputerShares ( computerName ) ;
306329 }
307330 catch ( Exception e )
308331 {
309- Mq . Error ( "Exception in ShareFinder task for host " + computer ) ;
332+ Mq . Error ( "Exception in ShareFinder task for host " + computerName ) ;
310333 Mq . Error ( e . ToString ( ) ) ;
311334 }
312335 } ) ;
You can’t perform that action at this time.
0 commit comments