diff --git a/src/Display.py b/src/Display.py index 3352560..7f1e8ce 100644 --- a/src/Display.py +++ b/src/Display.py @@ -1,9 +1,19 @@ #!/usr/bin/env python +############################################################################### +## Display.py +## +## Display data structure for GeoXPlanet +## +## Author: rocket357 AT users DOT sourceforge DOT net +## +############################################################################### + +# CHANGELOG # -# Display data structure for GeoXPlanet -# -# Author: rocket357 AT users DOT sourceforge DOT net +# Version 0.4.4-r2 +# Added projection radius value adjustment to GUI - FraGGod +# Added more choice to Marker Title combobox - FraGGod # import pygtk @@ -17,6 +27,7 @@ class Display(gtk.ScrolledWindow): template = None resolution = None projection = None + radius = None latitude = None longitude = None trace = None @@ -107,6 +118,13 @@ class Display(gtk.ScrolledWindow): self.projection.connect("changed", self.callback) self.projection.show() + radiusLbl = gtk.Label("Projection radius, %") + radiusLbl.show() + self.radius = gtk.Entry() + self.radius.set_text("45") + self.radius.connect("activate", self.callback) + self.radius.show() + latitudeLbl = gtk.Label("Viewpoint Latitude") latitudeLbl.show() self.latitude = gtk.Entry() @@ -138,6 +156,8 @@ class Display(gtk.ScrolledWindow): self.titleType = gtk.combo_box_entry_new_text() self.titleType.set_sensitive(False) self.titleType.append_text("port") + self.titleType.append_text("ip") + self.titleType.append_text("host") self.titleType.set_active(0) self.titleType.connect("changed", self.callback) self.titleType.show() @@ -205,6 +225,7 @@ class Display(gtk.ScrolledWindow): self.showClouds.show() self.configDict[self.index + "projection"] = "%s" % (self.projection.get_active_text()) + self.configDict[self.index + "radius"] = "%s" % (self.radius.get_text()) self.configDict[self.index + "latitude"] = "%s" % (self.latitude.get_text()) self.configDict[self.index + "longitude"] = "%s" % (self.longitude.get_text()) self.configDict[self.index + "trace"] = "%s" % (self.trace.get_active()) @@ -227,36 +248,38 @@ class Display(gtk.ScrolledWindow): tbl.attach(self.resolution, 1,2,1,2) tbl.attach(projectionLbl, 0,1,2,3) tbl.attach(self.projection, 1,2,2,3) - tbl.attach(showCloudsLbl, 0,1,4,5) - tbl.attach(self.showClouds, 1,2,4,5) - tbl.attach(arcsLbl, 0,1,5,6) - tbl.attach(self.arcs, 1,2,5,6) - tbl.attach(traceLbl, 0,1,6,7) - tbl.attach(self.trace, 1,2,6,7) - tbl.attach(titlesLbl, 0,1,7,8) - tbl.attach(self.titles, 1,2,7,8) - tbl.attach(titleTypeLbl, 0,1,8,9) - tbl.attach(self.titleType, 1,2,8,9) - tbl.attach(colorsLbl, 0,1,9,10) - tbl.attach(self.colors, 1,2,9,10) - tbl.attach(symbolsizeLbl, 0,1,10,11) - tbl.attach(symbolScale, 1,2,10,11) - tbl.attach(showNationsLbl, 0,1,11,12) - tbl.attach(self.showNations, 1,2,11,12) - tbl.attach(nationColorLbl, 0,1,12,13) - tbl.attach(self.nationColor, 1,2,12,13) - tbl.attach(showCoastLbl, 0,1,13,14) - tbl.attach(self.showCoast, 1,2,13,14) - tbl.attach(coastColorLbl, 0,1,14,15) - tbl.attach(self.coastColor, 1,2,14,15) - tbl.attach(showStatesLbl, 0,1,15,16) - tbl.attach(self.showStates, 1,2,15,16) - tbl.attach(stateColorLbl, 0,1,16,17) - tbl.attach(self.stateColor, 1,2,16,17) - tbl.attach(latitudeLbl, 0,1,17,18) - tbl.attach(self.latitude, 1,2,17,18) - tbl.attach(longitudeLbl, 0,1,18,19) - tbl.attach(self.longitude, 1,2,18,19) + tbl.attach(radiusLbl, 0,1,4,5) + tbl.attach(self.radius, 1,2,4,5) + tbl.attach(showCloudsLbl, 0,1,5,6) + tbl.attach(self.showClouds, 1,2,5,6) + tbl.attach(arcsLbl, 0,1,6,7) + tbl.attach(self.arcs, 1,2,6,7) + tbl.attach(traceLbl, 0,1,7,8) + tbl.attach(self.trace, 1,2,7,8) + tbl.attach(titlesLbl, 0,1,8,9) + tbl.attach(self.titles, 1,2,8,9) + tbl.attach(titleTypeLbl, 0,1,9,10) + tbl.attach(self.titleType, 1,2,9,10) + tbl.attach(colorsLbl, 0,1,10,11) + tbl.attach(self.colors, 1,2,10,11) + tbl.attach(symbolsizeLbl, 0,1,11,12) + tbl.attach(symbolScale, 1,2,11,12) + tbl.attach(showNationsLbl, 0,1,12,13) + tbl.attach(self.showNations, 1,2,12,13) + tbl.attach(nationColorLbl, 0,1,13,14) + tbl.attach(self.nationColor, 1,2,13,14) + tbl.attach(showCoastLbl, 0,1,14,15) + tbl.attach(self.showCoast, 1,2,14,15) + tbl.attach(coastColorLbl, 0,1,15,16) + tbl.attach(self.coastColor, 1,2,15,16) + tbl.attach(showStatesLbl, 0,1,16,17) + tbl.attach(self.showStates, 1,2,16,17) + tbl.attach(stateColorLbl, 0,1,17,18) + tbl.attach(self.stateColor, 1,2,17,18) + tbl.attach(latitudeLbl, 0,1,18,19) + tbl.attach(self.latitude, 1,2,18,19) + tbl.attach(longitudeLbl, 0,1,19,20) + tbl.attach(self.longitude, 1,2,19,20) tbl.show() self.add_with_viewport(tbl) @@ -280,6 +303,7 @@ class Display(gtk.ScrolledWindow): # then build out the data structure to hold the config... self.configDict[self.index + "geometry"] = "%s" % self.resolution.get_active_text().split(' ')[0] self.configDict[self.index + "projection"] = "%s" % (self.projection.get_active_text()) + self.configDict[self.index + "radius"] = "%s" % (self.radius.get_text()) self.configDict[self.index + "latitude"] = "%s" % (self.latitude.get_text()) self.configDict[self.index + "longitude"] = "%s" % (self.longitude.get_text()) self.configDict[self.index + "trace"] = "%s" % (self.trace.get_active()) diff --git a/src/configGUI.py b/src/configGUI.py index 1a85037..21d6503 100755 --- a/src/configGUI.py +++ b/src/configGUI.py @@ -1,9 +1,18 @@ #!/usr/bin/env python +############################################################################### +## configGUI.py +## +## Stupid config ui? +## +## Author: rocket357 AT users DOT sourceforge DOT net +## +############################################################################### + +# CHANGELOG # -# Stupid config ui? -# -# Author: rocket357 AT users DOT sourceforge DOT net +# Version 0.4.4-r2 +# Added projection radius value adjustment to GUI - FraGGod # import sys, time, os, re, urllib, traceback @@ -123,6 +132,7 @@ str(self.data["Display"]["numMonitors"]) Monitor_%i_trace=%s Monitor_%i_arcs=%s Monitor_%i_projection=%s +Monitor_%i_radius=%s Monitor_%i_titles=%s Monitor_%i_titleType=%s Monitor_%i_colors=%s @@ -141,6 +151,7 @@ display, self.data["Display"]["%sgeometry" % index], display, self.data["Display"]["%strace" % index], display, self.data["Display"]["%sarcs" % index], display, self.data["Display"]["%sprojection" % index], +display, self.data["Display"]["%sradius" % index], display, self.data["Display"]["%stitles" % index], display, self.data["Display"]["%stitleType" % index], display, self.data["Display"]["%scolors" % index], diff --git a/src/controller.py b/src/controller.py index 2dcf789..efadbba 100644 --- a/src/controller.py +++ b/src/controller.py @@ -14,6 +14,11 @@ # CHANGELOG # +# Version 0.4.4-r2 +# Added reverse DNS lookups for hostname titles - FraGGod +# Added projection radius value adjustment - FraGGod +# Added more colors for some common ports - FraGGod +# # Version 0.3.8 # Added options to show nations, coasts, and states - rocket357 # Added options to auto-generate the xplanet.conf file - rocket357 @@ -85,6 +90,7 @@ from ipRecord import ipRecord # keeps track of connections! from GeoXPlanetDB import Database # DB access module import ConfigParser # For reading the config file import traceback +import socket # For reverse DNS lookups from onlineLookup import onlineLookup from clouds import clouds as cloudClass if sys.platform == 'win32' or sys.platform == 'Mic': @@ -121,6 +127,7 @@ class GeoXPlanet: latitude = 0 longitude = 0 symbolsize = 0 + radius = 45 numConnections = 0 numDisplays = 0 @@ -282,6 +289,7 @@ class GeoXPlanet: arcComment = '#' self.displayDict["Monitor_%i_trace" % index] = (config.get("Display", "Monitor_%i_trace" % index) == "True") self.displayDict["Monitor_%i_projection" % index] = config.get("Display", "Monitor_%i_projection" % index) + self.displayDict["Monitor_%i_radius" % index] = config.get("Display", "Monitor_%i_radius" % index) self.displayDict["Monitor_%i_titles" % index] = (config.get("Display", "Monitor_%i_titles" % index) == "True") self.displayDict["Monitor_%i_titleType" % index] = config.get("Display", "Monitor_%i_titleType" % index) self.displayDict["Monitor_%i_colors" % index] = (config.get("Display", "Monitor_%i_colors" % index) == "True") @@ -338,34 +346,52 @@ cloudComment, self.GeoXPlanetDir, os.sep, os.sep, os.sep)) break # colorList: Interesting port numbers...Add or remove them as you need. - #Taken from http://www.iana.org/assignments/port-numbers + # Taken from http://www.iana.org/assignments/port-numbers, revised in 0.4.4-r2 self.colorList = { '21':'0xffffff', # ftp + '115':'0xffffff', # sftp + '990':'0xffffff', # ftps '22':'0xffff00', # ssh '23':'0x00ffff', # telnet + '992':'0x00ffff', # telnets '53':'0x99ff00', # dns '79':'0x0099ff', # finger # web surfing '80':'0x9900ff', # http + '8080':'0x9900ff', # http alternate '443':'0x9900ff', # https + '1080':'0x9900ff', # socks proxy + '3128':'0x9900ff', # http proxy # mail stuff '25':'0xff00ff', # smtp '110':'0xff9900', # pop3 - '995':'0xff9900', # pop3 over SSL/TLS - # Samba stuff + '995':'0xff9900', # pop3s + '143':'0xff9900', # imap + '993':'0xff9900', # imaps + # Samba / NFS stuff '137':'0x00ff99', # NetBIOS name '138':'0x00ff99', # NetBIOS Datagram '139':'0x00ff99', # NetBIOS Session '445':'0x00ff99', # Microsoft-DS + '2049':'0x00ff99', # NFS # instant messenger port nums: add as needed! '1863':'0x009999', # MSN '5050':'0x009999', # Yahoo - NOT from iana! '5190':'0x009999', # AIM - '5222':'0x009999', # XMPP (GMail chat, for instance) + '5222':'0x009999', # XMPP (Jabber, GMail chat) + '5223':'0x009999', # XMPP with old-fashioned SSL (GMail XMPP, for instance) + # SCMs + '2401':'0x559955', # CVS pserver + '3690':'0x559955', # SVN svnserve + '9418':'0x559955', # GIT daemon + '8000':'0x559955', # Mercurial + '4155':'0x559955', # Bazaar # others - '161':'0xff0099', # SNMP + '161':'0xff0099', # snmp + '123':'0x993300', # ntp '873':'0x999900', # rsync - '6667':'0x990099' # IRC + '6667':'0x990099', # irc + '994':'0x990099' # ircs } @@ -485,13 +511,20 @@ cloudComment, self.GeoXPlanetDir, os.sep, os.sep, os.sep)) color = self.colorList[ipPort] else: color = self.defaultColor + + try: + ipHost = socket.gethostbyaddr(ipStr)[0] + except: # catch "socket.herror: (1, 'Unknown host')" - not every ip has a hostname + ipHost = ipStr + # let's create a new record for this ip and location... # the record will have the location (ip addy) as the key, # and a list of lat/long for the value. Cache it as well... - self.locationDict[ipStr] = ipRecord(ipStr, color, ipPort) - self.locationDict[ipStr].addIP(lat, long, color, ipPort) - self.locationCache[ipStr] = ipRecord(ipStr, color, ipPort) - self.locationCache[ipStr].addIP(lat,long, color, ipPort) + # ...as well as port and DNS name :P + self.locationDict[ipStr] = ipRecord(ipStr, color, ipPort,ipHost) + self.locationDict[ipStr].addIP(lat, long, color, ipPort,ipHost) + self.locationCache[ipStr] = ipRecord(ipStr, color, ipPort,ipHost) + self.locationCache[ipStr].addIP(lat,long, color, ipPort,ipHost) def processList(self, ipList): for ip in ipList[:]: @@ -509,7 +542,7 @@ cloudComment, self.GeoXPlanetDir, os.sep, os.sep, os.sep)) self.dirtyList = True # let's check the cache first... if ip not in self.locationCache.keys(): - print "Performing lookup on %s" % ip + print "Performing GEO/rDNS lookup on %s" % ip self.lookupIP(ip, port) # it's already in the cache...pull the info else: @@ -595,19 +628,20 @@ cloudComment, self.GeoXPlanetDir, os.sep, os.sep, os.sep)) long = thisIP[1] color = thisIP[2] port = thisIP[3] + host = thisIP[4] # if the lat and long both = 0.0, that means we didn't get a match (or find a record in the db) if lat != 0.0 or long != 0.0: # now generate the marker file based on our settings... if self.displayDict["Monitor_%i_titles" % index]: - if self.displayDict["Monitor_%i_titleType" % index] == 'ip': - markerFile.write("%s %s \"%s\" color=%s symbolsize=%s\n" % (lat, long, name, color, self.displayDict["Monitor_%i_symbolsize" % index])) - else: - markerFile.write("%s %s \"%s\" color=%s symbolsize=%s\n" % (lat, long, port, color, self.displayDict["Monitor_%i_symbolsize" % index])) + if self.displayDict["Monitor_%i_titleType" % index] == 'ip': mark = name + elif self.displayDict["Monitor_%i_titleType" % index] == 'host': mark = host + else: mark = port # blank titles here... - else: - markerFile.write("%s %s \" \" color=%s symbolsize=%s\n" % (lat, long, color, self.displayDict["Monitor_%i_symbolsize" % index])) + else: mark = ' ' + + markerFile.write("%s %s \"%s\" color=%s symbolsize=%s\n" % (lat, long, mark,color, self.displayDict["Monitor_%i_symbolsize" % index])) if self.displayDict["Monitor_%i_trace" % index]: #print "TRACE: target = %s" % name @@ -675,6 +709,8 @@ cloudComment, self.GeoXPlanetDir, os.sep, os.sep, os.sep)) if self.displayDict["Monitor_%i_projection" % index] != 'None': xplanetCommand = xplanetCommand + "-projection %s " % self.displayDict["Monitor_%i_projection" % index] + if self.displayDict["Monitor_%i_radius" % index] != 45: + xplanetCommand = xplanetCommand + "-radius %s " % self.displayDict["Monitor_%i_radius" % index] if self.displayDict["Monitor_%i_arcs" % index] != '': xplanetCommand = xplanetCommand + "-arc_file %s " % self.displayDict["Monitor_%i_arcFile" % index] if self.displayDict["Monitor_%i_latitude" % index] != '' and self.displayDict["Monitor_%i_longitude" % index] != '': diff --git a/src/ipRecord.py b/src/ipRecord.py index de28cd0..de98b84 100644 --- a/src/ipRecord.py +++ b/src/ipRecord.py @@ -14,6 +14,9 @@ # CHANGELOG # +# Version 0.4.4-r2 +# Added host recording for reverse DNS lookups - FraGGod +# # Version 0.3.7 # Massive restructure to accomodate threaded lookups - rocket357 # @@ -33,12 +36,13 @@ class ipRecord(Thread): color = '' port = '' - def __init__(self, ipStr, color, port): + def __init__(self, ipStr, color, port,host): Thread.__init__(self) self.ipStr = ipStr self.latRegex = re.compile("Latitude:([ 0-9\.\-]*)") self.lonRegex = re.compile("Longitude:([ 0-9\.\-]*)") self.port = port + self.host = host self.color = color def run(self): @@ -63,8 +67,8 @@ class ipRecord(Thread): else: self.record = None - def addIP(self, lat, long, color, port): - self.record = [lat, long, color, port] + def addIP(self, lat, long, color, port,host): + self.record = [lat, long, color, port,host] return self.record def getIP(self):