Пример #1
0
	def acceptHost(self,daemon,conn):
		(ip, port)=conn.addr
		try:
			hostname=getHostname(ip)
		except:
			hostname='<unknown>'
		print '\nNew connection from',ip,hostname
		a=raw_input('Do you want to accept this? y/n: ')
		if a=='y':
			# user accepts, but pass it on to the default validator,
			# which will check the max. number of connections...
			return Pyro.protocol.DefaultConnValidator.acceptHost(self,daemon, conn)
		else:
			Pyro.util.Log.msg('ConnValidator','User denied connection from',ip,hostname)
			return (0,Pyro.constants.DENIED_HOSTBLOCKED)	# not ok
Пример #2
0
	def connect(self, sysCmd=None):
		host = self.Args.getOpt('h',None)
		bcaddr = self.Args.getOpt('c',None)
		port = int(self.Args.getOpt('p', 0))
		ident = self.Args.getOpt('i',None)
		if port==0:
			port=None

		locator = NameServerLocator(identification=ident)
		if not sysCmd:
			self.NS = locator.getNS(host,port,1,bcaddr=bcaddr)
			print 'NS is at',self.NS.URI.address,'('+(getHostname(self.NS.URI.address) or '??')+') port',self.NS.URI.port
			self.NS._setIdentification(ident)
		else:
			result = locator.sendSysCommand(sysCmd,host,port,1,bcaddr=bcaddr)
			print 'Result from system command',sysCmd,':',result
Пример #3
0
 def acceptHost(self, daemon, conn):
     (ip, port) = conn.addr
     try:
         hostname = getHostname(ip)
     except:
         hostname = '<unknown>'
     print '\nNew connection from', ip, hostname
     a = raw_input('Do you want to accept this? y/n: ')
     if a == 'y':
         # user accepts, but pass it on to the default validator,
         # which will check the max. number of connections...
         return Pyro.protocol.DefaultConnValidator.acceptHost(
             self, daemon, conn)
     else:
         Pyro.util.Log.msg('ConnValidator', 'User denied connection from',
                           ip, hostname)
         return (0, Pyro.constants.DENIED_HOSTBLOCKED)  # not ok