예제 #1
0
파일: server.py 프로젝트: irmen/Pyro3
	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
파일: nsc.py 프로젝트: aacevedor/dbs
	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