Closed Teingi closed 1 month ago
def get_observer_ip_from_trace_id(content):
if content[0] == 'Y' and len(content) >= 12:
sep = content.find('-')
uval = int(content[1:sep], 16)
ip = uval & 0xFFFFFFFF
port = (uval >> 32) & 0xFFFF
return "%d.%d.%d.%d:%d" % ((ip >> 24 & 0xFF), (ip >> 16 & 0xFF), (ip >> 8 & 0xFF), (ip >> 0 & 0xFF), port)
else:
return ""
# 示例trace_id,你需要替换为实际的trace_id
trace_id = "YB42AC1E81CB-00060AF2025B8782"
# 调用函数并打印结果
result = get_observer_ip_from_trace_id(trace_id)
if result:
print(f"Parsed IP and Port: {result}")
else:
print("Invalid trace_id format")
Description
这两个场景的信息收集的时候都提供了trace_id,通过trace_id就可以反向锁定节点了,精确节点收集,没必要全部节点都搜索一遍。