MCPcopy Create free account
hub / github.com/secdev/scapy / _DNSPacketListField

Class _DNSPacketListField

scapy/layers/dns.py:1236–1269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234
1235
1236class _DNSPacketListField(PacketListField):
1237 # A normal PacketListField with backward-compatible hacks
1238 def any2i(self, pkt, x):
1239 # type: (Optional[Packet], List[Any]) -> List[Any]
1240 if x is None:
1241 warnings.warn(
1242 ("The DNS fields 'qd', 'an', 'ns' and 'ar' are now "
1243 "PacketListField(s) ! "
1244 "Setting a null default should be [] instead of None"),
1245 DeprecationWarning
1246 )
1247 x = []
1248 return super(_DNSPacketListField, self).any2i(pkt, x)
1249
1250 def i2h(self, pkt, x):
1251 # type: (Optional[Packet], List[Packet]) -> Any
1252 class _list(list):
1253 """
1254 Fake list object to provide compatibility with older DNS fields
1255 """
1256 def __getattr__(self, attr):
1257 try:
1258 ret = getattr(self[0], attr)
1259 warnings.warn(
1260 ("The DNS fields 'qd', 'an', 'ns' and 'ar' are now "
1261 "PacketListField(s) ! "
1262 "To access the first element, use pkt.an[0] instead of "
1263 "pkt.an"),
1264 DeprecationWarning
1265 )
1266 return ret
1267 except AttributeError:
1268 raise
1269 return _list(x)
1270
1271
1272class DNS(DNSCompressedPacket):

Callers 1

DNSClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…