Added zone field too better querying on specific tlds/zones
This commit is contained in:
parent
78d7556f09
commit
a53541c328
@ -29,6 +29,7 @@ def construct_map() -> dict:
|
|||||||
'mappings': {
|
'mappings': {
|
||||||
'properties': {
|
'properties': {
|
||||||
'domain' : keyword_mapping,
|
'domain' : keyword_mapping,
|
||||||
|
'zone' : { 'type': 'keyword' },
|
||||||
'records' : { 'type': 'nested', 'properties': {} },
|
'records' : { 'type': 'nested', 'properties': {} },
|
||||||
'source' : { 'type': 'keyword' },
|
'source' : { 'type': 'keyword' },
|
||||||
'seen' : { 'type': 'date' }
|
'seen' : { 'type': 'date' }
|
||||||
@ -62,6 +63,9 @@ async def process_data(file_path: str):
|
|||||||
# Initialize the cache
|
# Initialize the cache
|
||||||
last = None
|
last = None
|
||||||
|
|
||||||
|
# Determine the zone name from the file path (e.g., /path/to/zones/com.eu.txt -> com.eu zone)
|
||||||
|
zone = '.'.join(file_path.split('/')[-1].split('.')[:-1])
|
||||||
|
|
||||||
# Read the input file line by line
|
# Read the input file line by line
|
||||||
async for line in input_file:
|
async for line in input_file:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
@ -129,6 +133,7 @@ async def process_data(file_path: str):
|
|||||||
'_index' : default_index,
|
'_index' : default_index,
|
||||||
'_doc' : {
|
'_doc' : {
|
||||||
'domain' : domain,
|
'domain' : domain,
|
||||||
|
'zone' : zone,
|
||||||
'records' : {record_type: [{'data': data, 'ttl': ttl}]},
|
'records' : {record_type: [{'data': data, 'ttl': ttl}]},
|
||||||
'source' : 'czds',
|
'source' : 'czds',
|
||||||
'seen' : time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()) # Zone files do not contain a timestamp, so we use the current time
|
'seen' : time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()) # Zone files do not contain a timestamp, so we use the current time
|
||||||
|
Loading…
Reference in New Issue
Block a user