MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / process_input

Method process_input

scripts/obfi/mktable.py:87–109  ·  view source on GitHub ↗

Read input from STDIN. When an IP is hidden, the original and obfuscated IPs are printed to STDOUT. If an IP is already obfuscated for the day, it is not printed to STDOUT.

(self)

Source from the content-addressed store, hash-verified

85 return "0.%d.%d.%d" % struct.unpack_from("BBB", bin_md5)
86
87 def process_input(self) -> None:
88 """
89 Read input from STDIN. When an IP is hidden, the original and
90 obfuscated IPs are printed to STDOUT. If an IP is already
91 obfuscated for the day, it is not printed to STDOUT.
92 """
93 count = 0
94 line = sys.stdin.readline()
95 try:
96 while line:
97 ips = re.findall(r"[^\d]?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[^\d]?", line)
98 for ip in ips:
99 if (hidden := self.hide(ip)) not in self.real_ips: # type: ignore [operator]
100 count += 1
101 self.real_ips[hidden] = ip
102 # Every 10th IP, flush the DB to disk
103 if count % 10 == 0:
104 self.real_ips.close()
105 self.set_db()
106 print(ip, hidden)
107 line = sys.stdin.readline()
108 except KeyboardInterrupt:
109 self.real_ips.close()
110
111
112def main():

Callers 2

mainFunction · 0.95

Calls 3

hideMethod · 0.95
set_dbMethod · 0.95
closeMethod · 0.45