-
This works, but maybe there is a more efficient way to handle large updates? Perhaps something like:
I'm using dnspython version 1.16.0. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you knew a max size bound for your updates, the easiest thing would be to just assume every update added the max bound and then stop before you got to 64K, but if your updates are not easily bounded, that won't work. If the message hitting 64K is rare, then splitting (perhaps repeatedly) your dns_update list until you got N right-size messages would work, but you don't want to be sending things multiple times, so you'd need to call message.to_wire() yourself to check the sizes, and then you could save the generated wire format on a list, and once you got a complete list, send them all with multiple calls to dns.query.send_tcp(), which can take a wire format message. The most efficient way would be look at how the Message.to_wire() code uses the dns.renderer.Renderer, and then directly call into the renderer until you either get to the end of your list or get TooBig. When the renderer raises TooBig, it rolls back the partial write so the output is still good. If you also set the max size to a bit less than 64K to leave room for the TSIG, then you could render until you got to big, manually set max_size to 64K on the renderer object, and then render your TSIG. Then you'd send the renderer output with tcp_send() and then start over until you'd processed all your updates. |
Beta Was this translation helpful? Give feedback.
If you knew a max size bound for your updates, the easiest thing would be to just assume every update added the max bound and then stop before you got to 64K, but if your updates are not easily bounded, that won't work.
If the message hitting 64K is rare, then splitting (perhaps repeatedly) your dns_update list until you got N right-size messages would work, but you don't want to be sending things multiple times, so you'd need to call message.to_wire() yourself to check the sizes, and then you could save the generated wire format on a list, and once you got a complete list, send them all with multiple calls to dns.query.send_tcp(), which can take a wire format message.
The most efficient …