Re: [Exim] TURN support

Góra strony
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
Dla: Arne Georg Gleditsch
CC: exim-users
Temat: Re: [Exim] TURN support
On Mon, 11 Aug 2003, Arne Georg Gleditsch wrote:

> Yes, I was thinking of the initial reception of the mail, when you
> want to store it away in a different, dynamically named, queue
> directory. I thought perhaps -bs and -D could help with that.


I thought about this some more as I was walking home yesterday. One
thing that occurred to me was that I was wrong about this:

> However, since I can envisage scenarios with arbitrary many
> TURN domains, I'd like to keep things more dynamic than having to
> maintain a separate Exim instance seems to imply.


I agreed with you, but now it seems to me that there should be no
problem in keeping *one* additional Exim instance for all the TURN
domains. You wouldn't have to keep a daemon running, just a separate
configuration file (or suitable macros in the main configuration file)
and a separate spool area. In effect, this does what you originally
suggested, which was a way of delivering "in Exim spool format".

> Well, but if they're on a real Exim queue, just called /var/spool/-
> exim/passive-192.168.42.5/input (or somesuch), couldn't you just
> deliver them from there? And if your exim.conf had
>
> spool_directory = MYQUEUE
>
> shouldn't -MC -DMYQUEUE=... be all you needed to do so?


Yes, except for finding the first message (see below).

> If we can thrash out an approach you're comfortable with, I'm ready to
> take a shot at this too. The second half of my vacation is coming up,
> though, so I'll have to let the matter rest for a few weeks myself.


Here is what I now think might work:

1. Deliver addresses for a TURN domain to the "alternate Exim". There
are several ways this could be done, but one of them would be to run a
pipe (as the user "exim") to call exim with an alternate (or modified)
configuration. The batch_max command could be used to keep a single copy
for multiple recipients in the same domain. Batch SMTP and -bs is
probably the most convenient format.

2. The alternate configuration should have queue_smtp_domains set.
That will cause the alternate Exim to do the routing, but no delivery.
However, it will update its hints file that remembers which message is
waiting for which host. An alternative would be to use -odqs. No queue
runs ever happen on the alternate spool, so no retries ever happen.

3. Having all the TURN domain messages on one spool means they can
easily be inspected using -bp, exiqsumm, eximon, or whatever. (However,
you could use separate spools for each host if you wanted.)

4. So far, I don't think any modification to Exim are needed.

5. When a TURN command is accepted by the listening Exim, it runs an
external script, passing the socket and the identity of the connected
host. This requires a small amount of work to add the ACL etc. to Exim.

6. What needs to happen now?

   (a) We need to find a message that is waiting for the connected host.
   (b) Exim needs to be run in -MC mode, but must do session startup
       before sending any messages.


A small code change achieves (b), but it would need a new option to make
it happen. You could do (a) by running -bp and looking for an
appropriate domain.

However, since a new option is needed anyway, I think a better idea
would be to do it all in Exim itself. Then you wouldn't even need an
external script. So I propose:

7. A new option, like -MC, is implemented. Let's call it -MCF (f=find).

exim -MCF <transport> <hostname>

This would work like -MC, but it would search Exim's hints database for
a message that is waiting for that host. Compare

exim -MC <transport> <hostname> <sequence number> <message id>

The sequence number just puts a limit on the total number of messages
sent down one connection. -MCF would put the sequence number to 1, and
find its own message id.

When -MCF is used, the SMTP session is initialized before the first
message is sent. Any other messages that are waiting for the same host
will then be sent using -MC calls to Exim.

I think this scheme should do what you want, and it also fits in quite
well with the Exim philosophy, and doesn't need a huge amount of work in
the Exim code.

Philip

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book