While abusing
Twisted, I needed to seek out some experts on the #twisted IRC channel.
Unfortunately, the freenode IRC network requires clients to support the
ident protocol. I didn't want to install a "real" identd, so I faked one
using Twisted. Here it is:
#!/usr/bin/python
from twisted.internet import reactor
from twisted.internet.protocol import Protocol, Factory
class FakeIdent(Protocol):
def dataReceived(self, data):
"""Send fake ident on any data received"""
data = data.strip().replace(' ,',',')
out = data + ' : USERID : UNIX : ircuser\r\n'
self.transport.write(out)
def main():
f = Factory()
f.protocol = FakeIdent
reactor.listenTCP(8000, f)
reactor.run()
if __name__ == '__main__':
main()
I had my firewall redirect the standard ident port of 113 to port 8000 on
my iBook. Once this program was running, I was able to join the freenode IRC
network and talk to some of the Twisted developers.
If you want a much better fake ident server written in python, use fauxident.
|