Esempio n. 1
0
def ban(cn, seconds, reason, banner_cn):
	ip = sbserver.playerIpLong(cn)
	expiration = time.time() + seconds
	nick = sbserver.playerName(cn)
	if banner_cn != -1:
		banner_ip = sbserver.playerIpLong(banner_cn)
		banner_nick = sbserver.playerName(banner_cn)
	else:
		banner_ip = 0
		banner_nick = ''
	newban = Ban(ip, expiration, reason, nick, banner_ip, banner_nick, time.time())
	session.add(newban)
	session.commit()
	addTimer(200, sbserver.playerKick, (cn,))
	logging.info('Player %s (%s) banned for %s by %s (%s)',
		nick,
		ipLongToString(ip),
		reason,
		banner_nick,
		ipLongToString(banner_ip))
	sbserver.message(info(ban_message.substitute(colordict, name=nick, seconds=seconds, reason=reason)))
Esempio n. 2
0
def onInsertBan(cn, args):
	'''@description Intert ban for ip address
	   @usage <ip> <seconds> (reason)'''
	p = player(cn)
	args = args.split(' ')
	if len(args) < 2:
		raise UsageError('ip length (reason)')
	else:
		ip = ipStringToLong(args[0])
		length = int(args[1])
		try:
			reason = args[2]
		except IndexError:
		 	reason = 'Unspecified reason'
		expiration = time.time() + length
		newban = Ban(ip, expiration, reason, 'Unnamed', 0, 'Unnamed', time.time())
		session.add(newban)
		session.commit()
		p.message(info('Inserted ban for %s for %i seconds for %s.' % (ipLongToString(ip), length, reason)))
Esempio n. 3
0
File: bans.py Progetto: pguenth/xsbs
def onInsertBan(cn, args):
    '''@description Intert ban for ip address
	   @usage <ip> <seconds> (reason)'''
    p = player(cn)
    args = args.split(' ')
    if len(args) < 2:
        raise UsageError('ip length (reason)')
    else:
        ip = ipStringToLong(args[0])
        length = int(args[1])
        try:
            reason = args[2]
        except IndexError:
            reason = 'Unspecified reason'
        expiration = time.time() + length
        newban = Ban(ip, expiration, reason, 'Unnamed', 0, 'Unnamed',
                     time.time())
        session.add(newban)
        session.commit()
        p.message(
            info('Inserted ban for %s for %i seconds for %s.' %
                 (ipLongToString(ip), length, reason)))
Esempio n. 4
0
def getCountry(ip):
	country = db.country_name_by_addr(ipLongToString(ip))
	if country == '':
		country = 'Unknown'
	return country
Esempio n. 5
0
def getCountry(ip):
    country = db.country_name_by_addr(ipLongToString(ip))
    if country == '':
        country = 'Unknown'
    return country
Esempio n. 6
0
	def ipString(self):
		'''Ip of client as decimal octet string'''
		return ipLongToString(self.ipLong())
Esempio n. 7
0
 def ipString(self):
     '''Ip of client as decimal octet string'''
     return ipLongToString(self.ipLong())