+1
-1
@@ -7,7 +7,7 @@ steps:
|
||||
repo: git.sedletskiy.ru/kosechok/testmontools
|
||||
tags:
|
||||
- latest
|
||||
# - ${CI_COMMIT_SHA:0:8}
|
||||
- ${CI_COMMIT_SHA:0:8}
|
||||
username:
|
||||
from_secret: REGISTRY_USER
|
||||
password:
|
||||
|
||||
@@ -113,6 +113,28 @@ def run_curl(url: str, headers_only: bool = False) -> dict:
|
||||
'body': body
|
||||
}
|
||||
|
||||
def run_dns(host: str, record_types=None) -> dict:
|
||||
if record_types is None:
|
||||
record_types = ['A', 'AAAA']
|
||||
|
||||
results = {}
|
||||
all_ips = []
|
||||
|
||||
for rtype in record_types:
|
||||
result = subprocess.run(
|
||||
['dig', '+short', rtype, host],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
|
||||
)
|
||||
records = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
||||
results[rtype] = records
|
||||
if rtype in ('A', 'AAAA'):
|
||||
all_ips.extend(records)
|
||||
|
||||
return {
|
||||
'resolved_host': host,
|
||||
'records': results,
|
||||
'all_ips': all_ips
|
||||
}
|
||||
|
||||
# ── Endpoints ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -143,7 +165,19 @@ def curl():
|
||||
url = raw if raw.startswith(('http://', 'https://')) else f'https://{raw}'
|
||||
return jsonify({'input': raw, **run_curl(url, headers_only=bool(data.get('headers')))})
|
||||
|
||||
@app.route('/testmontools/dns', methods=['POST'])
|
||||
def dns():
|
||||
data = request.get_json()
|
||||
raw, host = parse_input(data or {})
|
||||
if not host:
|
||||
return jsonify({'error': 'Field "url" or "host" is required'}), 400
|
||||
|
||||
record_types = data.get('types') # optional, e.g. ["A", "AAAA", "MX", "TXT", "CNAME", "NS"]
|
||||
if record_types:
|
||||
record_types = [t.upper() for t in record_types]
|
||||
|
||||
return jsonify({'input': raw, **run_dns(host, record_types)})
|
||||
|
||||
@app.route('/testmontools/all', methods=['POST'])
|
||||
def check_all():
|
||||
data = request.get_json()
|
||||
|
||||
Reference in New Issue
Block a user