MCPcopy Index your code
hub / github.com/Jason2605/PyFilter / insert

Method insert

pyFilter/database.py:36–54  ·  view source on GitHub ↗

Inserts IP addresses into Redis Args: ip: IP address as a string to be inserted into redis log_msg: Reason as to why the IP is banned

(self, ip, log_msg)

Source from the content-addressed store, hash-verified

34 self.pub_sub.subscribe("PyFilter")
35
36 def insert(self, ip, log_msg):
37 """
38 Inserts IP addresses into Redis
39
40 Args:
41 ip: IP address as a string to be inserted into redis
42 log_msg: Reason as to why the IP is banned
43 """
44
45 self.redis_connection.lpush("latest_10_keys", "{} {}".format(ip, self.name))
46 self.redis_connection.ltrim("latest_10_keys", 0, 9)
47
48 self.redis_connection.hmset(ip, {
49 self.name: datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
50 "reason": log_msg,
51 "banned_server": self.name
52 })
53
54 self.redis_connection.publish("PyFilter", "{} {}".format(ip, self.name))
55
56 def select(self, ip):
57 """

Callers 1

blacklistMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected