[Twisted-Python] How to get the client ip when it ask a resolution with twisted.names

contact at benoit-laviale.fr contact at benoit-laviale.fr
Sat May 1 00:43:06 MDT 2021


Dear all,

I am working on twisted names since some days to make kind of filtering system (with domains blacklists).
So I made my own resolver that can reply defer.fail(error.DomainError()) to send the query to the next resolver (and in this case, it will be resolve) or defer.fail(dns.AuthoritativeDomainError(query.name.name)) to reply NXDOMAIN that can "block" the domain to the final client.    

That part is working well.

Next, i would like to "block" the resolution regarding the device (Mac address/IP/???).

I would like something like that :

if self.query.meta.client.ip == b"192.168.0.5" or self.query.meta.client.mac == "XX:YY:ZZ:....":
         self.do_something()

My use case is that device of Kelly, (Kelly is a teenager of 12 years) cant use youtube.com at all, but other devices are allowed to get the resolution.
How can I get the IP/Name/mac (an identifier) of the device that's querying my custom dns?
I read something about datagrams, but in my case i think i must get this information in my resolver...

Thx and cheers.

Benoît
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20210501/49179482/attachment.htm>


More information about the Twisted-Python mailing list