<div dir="ltr"><div><br></div><div>Oh and it looks like I should be using these for my proxy classes:</div><div><br></div><div><a href="http://twistedmatrix.com/documents/current/api/twisted.protocols.pcp.BasicProducerConsumerProxy.html">http://twistedmatrix.com/documents/current/api/twisted.protocols.pcp.BasicProducerConsumerProxy.html</a><br>
</div><div><a href="http://twistedmatrix.com/documents/current/api/twisted.protocols.pcp.ProducerConsumerProxy.html">http://twistedmatrix.com/documents/current/api/twisted.protocols.pcp.ProducerConsumerProxy.html</a><br></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Oct 5, 2013 at 9:22 PM, David Stainton <span dir="ltr"><<a href="mailto:dstainton415@gmail.com" target="_blank">dstainton415@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I'm glad I found the doc about producers/consumers... I should actually finish a transport so I can see this thing churn data.</div>
<div>Thanks for pointing out that decorator.</div><div>
<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Oct 5, 2013 at 8:46 PM, Glyph <span dir="ltr"><<a href="mailto:glyph@twistedmatrix.com" target="_blank">glyph@twistedmatrix.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div>On Oct 5, 2013, at 10:50 AM, David Stainton <<a href="mailto:dstainton415@gmail.com" target="_blank">dstainton415@gmail.com</a>> wrote:</div>

<br><blockquote type="cite"><div dir="ltr"><div><br></div><div>Right. I gave my class one of these: implements(interfaces.IPushProducer, interfaces.IReadDescriptor)</div><div>Which means that I can easily write a class that implements IConsumer</div>


<div>to do something with the packets.</div><div><br></div><div><a href="https://github.com/david415/hushVPN/blob/master/nflog_reader.py" target="_blank">https://github.com/david415/hushVPN/blob/master/nflog_reader.py</a></div>

</div></blockquote><div><br></div></div><div>After a brief glance, this stuff looks pretty cool.  Very much in the spirit that these interfaces were developed in.  (And you chose the correct producer interface; the other I*Producer interfaces are pretty much just legacy junk, sorry about that :-))</div>

<div><br></div><div>One thing to note, though: you should switch to this style:</div><div><br></div><div>@implementer(IPushProducer, IReadDescriptor)</div><div>class NFLogPacket...</div><div><br></div><div>because the implements() style won't work in future versions of Python.  (Plus, the implementation of @implementer is much cleaner on older versions too.)</div>

<span><font color="#888888"><div><br></div><div>-glyph</div></font></span><div><div><br><blockquote type="cite"><div dir="ltr"><div>This is basically a packet sniffer which receives packets based on iptables rules.</div>

<div><br></div><div>After that I wrote proxy consumer/producers too; classes that implement both IConsumer and IPushProducer;</div>
<div>this allows me to transform the packets before sending them to a transport.</div><div><br></div><div>I was inspired by this doc:</div><div><a href="http://twistedmatrix.com/documents/12.2.0/core/howto/producers.html" target="_blank">http://twistedmatrix.com/documents/12.2.0/core/howto/producers.html</a><br>


</div><div><br></div><div>So far I really love Twisted!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 2, 2013 at 3:14 AM, Phil Mayers <span dir="ltr"><<a href="mailto:p.mayers@imperial.ac.uk" target="_blank">p.mayers@imperial.ac.uk</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 02/10/13 09:25, David Stainton wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
In examples of Twisted UDP clients they all do this:<br>
<br>
reactor.listenUDP(3000,<u></u>MyProtocol())<br>
<br>
What would I do instead?<br>
reactor.addReader makes sense to me since what I have is a file descriptor,<br>
and the reactor loop and use select or epoll find out when there is data<br>
to read...<br>
and call our doRead() method of the Reader.<br>
<br>
I don't know about implementing this as a Protocol because I do not have any<br>
equivalent to ReactorUDP. ReactorUDP's listenUDP returns a ListeningPort.<br>
And I'm not sure how a Transport is related to my Reader... but it seems<br>
to me<br>
that there is some abstraction which sets callbacks for io and also<br>
calls buildProtocol...<br>
</blockquote>
<br></div>
Sorry, maybe I was unclear: you were asking about protocols, so I was merely pointing out that *if* you were to use a protocol, you should copy the approach DatagramProtocol and udp.Port take.<br>
<br>
However as I noted, it *might not* make sense to do this, if there's only ever going to be one socket listening on this "thing", your current approach might be fine.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If I am going to be using a Twisted Service to drop privileges after<br>
gaining access to the fd...<br>
How would I do this? Would I have startService() instantiate a Protocol<br>
instance?<br>
</blockquote>
<br></div>
As above, it depends. If you're using Protocol instances, then yes. If not, then no.<br>
<br>
Services are just things which start and stop; they may or may not use objects implementing the transport/factory/protocol pattern.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I don't know about the nflog file descriptor...<br>
but the nflog generator interface is non-blocking if used like this:<br>
</blockquote>
<br></div>
Ok. Weird API, but if it works...<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
My nflog reader seems to work great.<br>
</blockquote>
<br></div>
If it works for you, and you're using documented Twisted interfaces, then there's probably no need to fiddle with it.<div><div><br>
<br>
______________________________<u></u>_________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.<u></u>com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-<u></u>bin/mailman/listinfo/twisted-<u></u>python</a><br>
</div></div></blockquote></div><br></div>
_______________________________________________<br>Twisted-Python mailing list<br><a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>

</blockquote></div></div></div><br></div><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>