make sure that dns flows are not live by default
This commit is contained in:
parent
f253a65a46
commit
4f6da5180e
|
@ -110,6 +110,11 @@ async def resolve_message(message: dns.Message, loop: asyncio.AbstractEventLoop)
|
|||
|
||||
class DnsResolver:
|
||||
async def dns_request(self, flow: dns.DNSFlow) -> None:
|
||||
# handle regular mode requests here to not block the layer
|
||||
if ctx.options.dns_mode == "regular":
|
||||
should_resolve = (
|
||||
flow.live
|
||||
and not flow.response
|
||||
and not flow.error
|
||||
and ctx.options.dns_mode == "regular"
|
||||
)
|
||||
if should_resolve:
|
||||
flow.response = await resolve_message(flow.request, asyncio.get_running_loop())
|
||||
|
|
|
@ -425,8 +425,8 @@ class DNSFlow(flow.Flow):
|
|||
_stateobject_attributes["request"] = Message
|
||||
_stateobject_attributes["response"] = Message
|
||||
|
||||
def __init__(self, client_conn: connection.Client, server_conn: connection.Server):
|
||||
super().__init__("dns", client_conn, server_conn, True)
|
||||
def __init__(self, client_conn: connection.Client, server_conn: connection.Server, live: bool = False):
|
||||
super().__init__("dns", client_conn, server_conn, live)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<DNSFlow\r\n request={repr(self.request)}\r\n response={repr(self.response)}\r\n>"
|
||||
|
|
|
@ -40,7 +40,7 @@ class DNSLayer(layer.Layer):
|
|||
|
||||
def __init__(self, context: Context):
|
||||
super().__init__(context)
|
||||
self.flow = dns.DNSFlow(self.context.client, self.context.server)
|
||||
self.flow = dns.DNSFlow(self.context.client, self.context.server, live=True)
|
||||
|
||||
def handle_request(self, msg: dns.Message) -> layer.CommandGenerator[None]:
|
||||
self.flow.request = msg # if already set, continue and query upstream again
|
||||
|
|
Loading…
Reference in New Issue