Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _transmit_oack(self):
"""Method that deals with sending OACK datagrams on the wire."""
opts = []
for key, val in self._options.items():
fmt = str("%dsx%ds" % (len(key), len(val)))
opts.append(
struct.pack(
fmt, bytes(key.encode("latin-1")), bytes(val.encode("latin-1"))
)
)
opts.append(b"")
fmt = str("!H")
packet = struct.pack(fmt, constants.OPCODE_OACK) + b"\x00".join(opts)
self._get_listener().sendto(packet, self._peer)
self._stats.packets_sent += 1