diff options
| author | Greg Stupp | 2026-03-15 20:15:40 +0000 |
|---|---|---|
| committer | Greg Stupp | 2026-03-15 20:15:40 +0000 |
| commit | 9f85ce5e1937c3815a556ea26dd29d2204fa1074 (patch) | |
| tree | a7852700c138ba9532e675049e54834b752aa929 /generalresearch/models/network/rdns/command.py | |
| parent | 459a8638924a6bc4c98eddee317e2dca59ed054b (diff) | |
| parent | 2ca391c7b38c448cc9cd3fff3da5a06d5c2ce3a1 (diff) | |
| download | generalresearch-9f85ce5e1937c3815a556ea26dd29d2204fa1074.tar.gz generalresearch-9f85ce5e1937c3815a556ea26dd29d2204fa1074.zip | |
Merges pull request #1
Feature network
Diffstat (limited to 'generalresearch/models/network/rdns/command.py')
| -rw-r--r-- | generalresearch/models/network/rdns/command.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/generalresearch/models/network/rdns/command.py b/generalresearch/models/network/rdns/command.py new file mode 100644 index 0000000..aa48f2a --- /dev/null +++ b/generalresearch/models/network/rdns/command.py @@ -0,0 +1,35 @@ +import subprocess + +from generalresearch.models.network.rdns.parser import parse_rdns_output +from generalresearch.models.network.rdns.result import RDNSResult +from generalresearch.models.network.tool_run_command import RDNSRunCommand + + +def run_rdns(config: RDNSRunCommand) -> RDNSResult: + cmd = config.to_command_str() + args = cmd.split(" ") + proc = subprocess.run( + args, + capture_output=True, + text=True, + check=False, + ) + raw = proc.stdout.strip() + return parse_rdns_output(ip=config.options.ip, raw=raw) + + +def build_rdns_command(ip: str) -> str: + # e.g. dig +noall +answer -x 1.2.3.4 + return " ".join(["dig", "+noall", "+answer", "-x", ip]) + + +def get_dig_version() -> str: + proc = subprocess.run( + ["dig", "-v"], + capture_output=True, + text=True, + check=False, + ) + # e.g. DiG 9.18.39-0ubuntu0.22.04.2-Ubuntu + ver_str = proc.stderr.strip() + return ver_str.split("-", 1)[0].split(" ", 1)[1] |
