Re: IPv6 in tmda-ofmipd
Kevin Goodsell <[email protected]> Thu, 3 Feb 2011 22:42:23 -0800
| Newsgroups | gmane.mail.spam.tmda.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Feb 3, 2011 at 3:59 PM, Sabahattin Gucukoglu <[email protected]> wrote: > Hi all, > > Anybody know if there's a hack to get tmda-ofmipd listening on an IPv6 socket? It's just ... it is time. > There's a bit of hard-coding for IPv4, but it's not too hard to fix in tmda-ofmipd itself. Fixing up the tests is a bit harder. And for all I know there may be additional incompatibilities lurking somewhere. I'm not really very up on IPv6 myself. Anyway, here's a quick patch. It seems to work (at least I can hack the tests into IPv6-mode and they pass). I suppose I'll have to get around to another update "soon". You'll need to use -p with a ":" in the address for this to work. I don't know if that's really sufficient to detect IPv6. I tested with ::1. -Kevin diff --git a/tmda/bin/tmda-ofmipd b/tmda/bin/tmda-ofmipd index 90594b1..b3a5a68 100755 --- a/tmda/bin/tmda-ofmipd +++ b/tmda/bin/tmda-ofmipd @@ -1118,7 +1118,14 @@ class SMTPServer(asyncore.dispatcher): self._localaddr = localaddr self._session_factory = session_factory asyncore.dispatcher.__init__(self) - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + + (host, port) = localaddr + if ':' in host: + family = socket.AF_INET6 + else: + family = socket.AF_INET + self.create_socket(family, socket.SOCK_STREAM) + # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) @@ -1607,7 +1614,7 @@ def main(): create_smtp_session_from_stdin(session_factory) else: # try binding to the specified host:port - host, port = opts.proxyport.split(':', 1) + host, port = opts.proxyport.rsplit(':', 1) server = SMTPServer((host, int(port)), session_factory) # Switch user/group ID, etc. ------------------------------------------------------------------------------ The modern datacenter depends on network connectivity to access resources and provide services. The best practices for maximizing a physical server's connectivity to a physical network are well understood - see how these rules translate into the virtual world? http://p.sf.net/sfu/oracle-sfdevnlfb _______________________________________________ tmda-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tmda-users