⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 np_tscreen.py

📁 该软件根据网络数据生成NetFlow记录。NetFlow可用于网络规划、负载均衡、安全监控等
💻 PY
📖 第 1 页 / 共 3 页
字号:
#! /usr/bin/env python################################################################################                                                                             ##   Copyright 2005 University of Cambridge Computer Laboratory.               ##                                                                             ##   This file is part of Nprobe.                                              ##                                                                             ##   Nprobe is free software; you can redistribute it and/or modify            ##   it under the terms of the GNU General Public License as published by      ##   the Free Software Foundation; either version 2 of the License, or         ##   (at your option) any later version.                                       ##                                                                             ##   Nprobe is distributed in the hope that it will be useful,                 ##   but WITHOUT ANY WARRANTY; without even the implied warranty of            ##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             ##   GNU General Public License for more details.                              ##                                                                             ##   You should have received a copy of the GNU General Public License         ##   along with Nprobe; if not, write to the Free Software                     ##   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA ##                                                                             ################################################################################################################################################################ #### ## #### ########################################################################################################################################################from Tkinter import *from copy import copy#from np_obnode import *#import np_obnodeimport np_filerecimport np_WebHostimport np_TCPConnimport np_HTTPTransfrom np_lookups import *from np_TCP_Window import *#from np_tcp import TcpDisplay#from np_TCPDisplay import *import np_TCPDisplayfrom np_widgets import *#from np_Obtree import ObTree, G_AFTER, G_BEFOREimport np_Obtree#from np_grabrec import grabimport np_grabrecfrom bsearch import NotInRangeimport gcfrom np_bitmaps import drag, ccross############################################################################################################################################################OS_WIDTH = 1500OS_HEIGHT = 1000UFRAME_WIDTH = 300UFRAME_HEIGHT = OS_HEIGHTTOOLBAR_HEIGHT = 25DFRAME_WIDTH = OS_WIDTH - UFRAME_WIDTHDFRAME_HEIGHT = OS_HEIGHTSCALE_CANV_HEIGHT = 25TREE_CANV_HEIGHT = DFRAME_HEIGHT - SCALE_CANV_HEIGHTMAP_CANV_HEIGHT =  int(UFRAME_WIDTH*((TREE_CANV_HEIGHT*1.0)/DFRAME_WIDTH))#MAP_CANV_HEIGHT =  50INFO_CANV_HEIGHT = UFRAME_HEIGHT - MAP_CANV_HEIGHT - TOOLBAR_HEIGHTINFO_CAN_SBAR_WIDTH = 15############################################################################################################################################################class Tscreen(Frame):    def __init__(self, clist, lookup=intoa_string, standalone='no', path='',                 logfun=None, trace=0):	if not len(clist):	    print 'TScreen: empty connection list'	    return        if standalone == 'yes':            self.root = Tk()            self.quitfun = self.finish        else:            self.root = Toplevel()            self.quitfun = self._destroy        self.root.geometry('+0+0')	Frame.__init__(self, self.root) 	self.config(width=OS_WIDTH, height=OS_HEIGHT)	self.pack(fill=BOTH, expand=1)	self.clist = clist	self.indx = -1	self.ncanv = 0	self.canvlist = []	self.trees = []	self.trees_pure = []	self.started = 0        	self.path = path # where the rep file is	self.logfun = logfun # to write any logged stuff        self.trace = trace        self.lookup = lookup	self.mode = 'Time'	self.make_screens()	self.uframe_width = UFRAME_WIDTH	self.map_height = MAP_CANV_HEIGHT	self.dframe_width = DFRAME_WIDTH	self.info_can_sbar_width = INFO_CAN_SBAR_WIDTH	self.map_canv_ht = MAP_CANV_HEIGHT	#print 'mch=%d' % (MAP_CANV_HEIGHT)	self.dframe_ht = DFRAME_HEIGHT	self.tscalecanv_ysz = SCALE_CANV_HEIGHT	self.draw_next()                if standalone == 'yes':            self.root.mainloop()        else:            self.root.wait_window(self.root)	    ##############################################################################    def nullf(self, *args):        return	    ##############################################################################    def make_screens(self):	self.uframe = Frame(self, width=UFRAME_WIDTH, height=UFRAME_HEIGHT, 			    bg='blue')	self.uframe.pack(side=LEFT, fill=Y)	self.dframe = Frame(self, width=DFRAME_WIDTH, height=DFRAME_HEIGHT, 			    bg='lightblue')	self.dframe.pack(side=RIGHT, fill=Y)	self.make_toolbar()        # These are 1-offs (other canvasses etc are one set per tree)        self.pktinfo = np_TCPDisplay.ConnPktInfo(self.uframe, INFO_CANV_HEIGHT)        self.conninfo = np_TCPDisplay.ConnTransInfo(self.uframe)	    ##############################################################################    def set_titlebar(self, tree):	tstr = 'Reference Tree for %s %s' % (tree.client.Class,                                             tree.client.addr_str())	self.winfo_toplevel().title(tstr)	############################################################################    def make_canvasses(self):	# Canvases for info/keys and map  	info_canv = Can(self.uframe, UFRAME_WIDTH, INFO_CANV_HEIGHT, 0, 			     0, YSCROLL) 	info_canv.config(bg='white')	info_canv.scrollY.config(width=15)	info_canv.drawn = 0  	map_canv = Can(self.uframe, UFRAME_WIDTH, MAP_CANV_HEIGHT, 0, 0, 			    NOSCROLL) 	map_canv.config(bg='white', highlightbackground='gray44', 			highlightcolor='grey44') 	map_canv.drawn = 0	# Canvases for tree time scale - initially display for detail tree  	scale_canv = Can(self.dframe, DFRAME_WIDTH, SCALE_CANV_HEIGHT, 			      0, 0, NOSCROLL) 	scale_canv.config(bg='white', borderwidth=0, 			       highlightthickness=0)  	scale_canv.drawn = 0  	scale_vcanv = Can(self.dframe, DFRAME_WIDTH, SCALE_CANV_HEIGHT, 			       0, 0, NOSCROLL) 	scale_vcanv.config(bg='white', borderwidth=0, 				highlightthickness=0)	scale_vcanv.drawn = 0	# Main canvases for tree - initially display detail tree  	tree_canv = Can(self.dframe, DFRAME_WIDTH, TREE_CANV_HEIGHT, 0, 			     0, NOSCROLL) 	tree_canv.config(bg='white', borderwidth=0, highlightthickness=0)  	tree_canv.drawn = 0  	tree_vcanv = Can(self.dframe, DFRAME_WIDTH, TREE_CANV_HEIGHT, 0, 			      0, NOSCROLL) 	tree_vcanv.config(bg='white', borderwidth=0, highlightthickness=0) 	tree_vcanv.drawn = 0	return (info_canv, map_canv, (scale_canv, tree_canv), 		(scale_vcanv, tree_vcanv))	    ##############################################################################    def make_toolbar(self):	toolbar = self.toolbar = Menu(self.root)        toolbar.config(background='grey')	# quit entry        toolbar.add_command(label="Quit", command=self.quitfun,                            background='grey', foreground='red')        toolbar.add_separator(background='red')        toolbar.add_command(label=' ', command=None,                            background='grey', state=DISABLED) 	# draw previous tree entry        toolbar.add_command(label="Prev", command=self.draw_prev,                            background='grey', state=DISABLED) 	# draw next tree entry        toolbar.add_command(label="Next", command=self.draw_next,                            background='grey', state=DISABLED) 	# alternate view entry 	if self.mode == 'Detail': 	    txt = 'Time' 	else: 	    txt = 'Detail'        toolbar.add_command(label=txt, command=self.change_view,                            background='grey')         # show connection details entry        toolbar.add_command(label='Conns', command=self.display_conns,                            background='grey')         # grab entry        toolbar.add_command(label='Grab', command=self.grab,                            background='grey')         # redo entry        toolbar.add_command(label='Redo', command=self.redo,                            background='grey')        # reload entry        rb = self.make_reloadmenu()        toolbar.add_cascade(label='Reload', menu=rb)        self.root.config(menu=toolbar) ############################################################################    def make_reloadmenu(self):        #        # Cause reload of contributing module        #        self.reload_what = StringVar()        rb = self.rb =  Menu(self.toolbar)        rb.configure(background='grey')                for mod in ['FileRec', 'WebHost', 'TCPConn', 'HTTPTrans', 'Obtree']:            rb.add_radiobutton(label=mod, background='grey', value=mod,                               variable=self.reload_what, command=self.reload,                               indicatoron=0)        return rb############################################################################    def reload(self):        what = self.reload_what.get()                if what == 'FileRec':            reload(np_filerec)        elif what == 'WebHost':            reload(np_WebHost)        elif what == 'TCPConn':            reload(np_TCPConn)        elif what == 'HTTPTrans':            reload(np_HTTPTrans)        elif what == 'Obtree':            reload(np_Obtree)	    ##############################################################################    def make_trees_entry(self, client):        rootlist = client.rootlist        if (not rootlist) or len(rootlist) == 1:            self.tree_picked = 0            return        self.tree_picked = 1        self.treemenu = treemenu = Menu(self.toolbar,                            background='grey')        self.toolbar.add_cascade(label="Trees", menu=treemenu)        self.treevar = treevar = IntVar()        treevar.set(-1)        treemenu.add_radiobutton(label='All', variable=treevar, value=-1,                                 command=self.picktree, indicatoron=0,                                 selectcolor='blue')        treemenu.add_separator(background='grey')                i = 0        for root in client.rootlist:            treemenu.add_radiobutton(label='%d %s' % (root.order, root.absurl),                                     variable=treevar,                                     value=i, command=self.picktree,                                     indicatoron=0,                            background='grey',                                 selectcolor='blue')            i += 1                treemenu.add_separator(background='grey')        if client.unlinkedlist:            treemenu.add_radiobutton(label='Unlinked', variable=treevar,                                     value=-2,                                     command=self.picktree, indicatoron=0,                                     selectcolor='blue')	    ##############################################################################    def finish(self):        	sys.exit(0)############################################################################    def _destroy(self):        self.root.destroy()        del self.root	self.master.destroy()############################################################################    def grab(self):        #print self.clist[self.indx].FileRec        #np_grabrec.grab(self.clist[self.indx].FileRec)        np_grabrec.grab(self.clist[self.indx])	    ##############################################################################    def set_pnbuttons(self):	if self.indx + 1 == len(self.clist):	    self.toolbar.entryconfig("Next", state=DISABLED)	else:	    self.toolbar.entryconfig("Next", state=NORMAL)	if self.indx == 0:	    self.toolbar.entryconfig("Prev", state=DISABLED)	else:	    self.toolbar.entryconfig("Prev", state=NORMAL)	    ##############################################################################    def display_set(self, set):	if self.mode == 'Detail':	    mset = set[2]	else:	    mset = set[3]        self.pktinfo.pack_forget()        self.conninfo.pack_forget()        self.conninfo.transdata=None        	set[0].pack(expand=1, fill=BOTH)	set[1].pack(side=BOTTOM, fill=X)	self.bind_map_buttons(set[1])	self.display_mode(mset)	    ##############################################################################    def hide_set(self, set):	if self.mode == 'Detail':	    mset = set[2]	else:	    mset = set[3]	set[0].pack_forget()	set[1].pack_forget()	self.unbind_map_buttons(set[1])	    	self.hide_mode(mset)##############################################################################    def display_mode(self, set):	set[0].pack(side=TOP)	set[1].pack(side=BOTTOM)	set[1].draw_map_port(set[1])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -