From e70a3c21600305be9e710dfd43035de56aa346d8 Mon Sep 17 00:00:00 2001 From: Florian Paul Azim Hoberg Date: Thu, 9 May 2024 14:40:22 +0200 Subject: [PATCH] feature(http): Add feature to return just the raw IP for shell scripts --- checkmyip.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/checkmyip.py b/checkmyip.py index c7d7a1c..bbbd0f9 100644 --- a/checkmyip.py +++ b/checkmyip.py @@ -17,6 +17,7 @@ import os import sys import time import socket +import json import jinja2 import paramiko import threading @@ -240,6 +241,9 @@ def http_talker(client, valdict, proto="http"): valdict.update({"proto": proto}) log(j2format(j2log, valdict)) response_body_raw = j2format(j2send, valdict)+"\n" + if request_lines[0].split()[1] == "/raw": + json_content = json.loads(response_body_raw) + response_body_raw = json_content['ip'] response_headers_raw = """HTTP/1.1 200 OK Content-Length: %s Content-Type: application/json; encoding=utf8