#!/usr/bin/env python3
"""
This script will search your server log file and find any proxy servers that are
connecting to the server. The server log file needs to be set to a debug level 1 or
higher in order to record all the commands coming into the server.
Just pass the log file in as parameter to this script and it will print out a list
of the proxy servers.
"""
import re
import sys
def main():
if len(sys.argv) <= 1:
print("Read the usage section at the top of the script for required parameters.")
sys.exit(1)
try:
infile = open(sys.argv[1], "r")
except FileNotFoundError:
print("Unable to open file %s." % sys.argv[1])
sys.exit(2)
proxylist = []
for line in infile.readlines():
if re.search(r'\d+\.\d+\.\d+\.\d+\/\d+\.\d+\.\d+\.\d+', line):
match = re.sub(r'.* (\d+\.\d+\.\d+\.\d+)\/\d+\.\d+\.\d+\.\d+ .*', r'\1', line)
if match not in proxylist:
proxylist.append(match)
infile.close()
for proxy in proxylist:
print(proxy)
if __name__ == "__main__":
main()
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #4 | 32423 | Russell C. Jackson (Rusty) |
Modernize SDP maintenance scripts: security, correctness, and Python 3 - Replace all os.system() and os.popen() calls with subprocess.run() using argument lists to eliminate shell injection vulnerabilities - Fix critical bugs: broken indentation in convert_label_to_autoreload.py, malformed print() in p4lock/p4unlock, wrong variable in isitalabel, format string typo in maintain_user_from_groups - Add p4 property alias and shared SKIP_USERS constant to sdputils.py - Add try/finally with p4.disconnect() to all P4Python scripts - Replace bare except: with specific exception types throughout - Update all shebangs to python3, remove unnecessary __future__ imports - Use context managers for all file handle operations - Replace from subprocess import * with explicit imports |
||
| #3 | 32388 | Russell C. Jackson (Rusty) | Updates using Claude.ai to clean up the code, reduce duplication, enhanace security, and use current standards. | ||
| #2 | 24675 | Russell C. Jackson (Rusty) |
Fixed bugs in sdputils.py and scripts using it. Converted to standard 2 space spacing, removed copyright stuff. |
||
| #1 | 22693 | Russell C. Jackson (Rusty) |
Branched a Unix only version of the SDP. Removed extra items to create a cleaner tree. Moved a few items around to make more sense without Windows in the mix. |
||
| //guest/perforce_software/sdp/dev/Maintenance/proxysearch.py | |||||
| #6 | 16638 | C. Thomas Tyler |
Routine merge down to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
| #5 | 16029 | C. Thomas Tyler |
Routine merge to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
| #4 | 15375 | adrian_waters | Routine merge-down from main->dev | ||
| #3 | 11477 | Russell C. Jackson (Rusty) |
Updated to use /usr/bin/env python Added workshop header. Changed cfg to config. |
||
| #2 | 11464 | Russell C. Jackson (Rusty) | Current maintenance scripts. | ||
| #1 | 10638 | C. Thomas Tyler | Populate perforce_software-sdp-dev. | ||
| //guest/perforce_software/sdp/main/Maintenance/proxysearch.py | |||||
| #1 | 10148 | C. Thomas Tyler | Promoted the Perforce Server Deployment Package to The Workshop. | ||