Hi,

On Sat, 3 Jan 2015 14:42:18 +0100 Reyk Floeter <[email protected]> wrote:

> On Thu, Jan 01, 2015 at 11:54:46PM -0500, Geoff Steckel wrote:
> > Is there any way todo the equivalent of:
> > 
> > server "an.example.com"
> >     listen on 192.168.2.99
> >     listen on 2001.fefe.1.1::99
> 
> I used "include" directives to avoid duplications (see previous reply)
> but the following diff allows to add aliases and multiple listen
> statements.
> 
> Reyk

As I understand your diff you will duplicate the entire struct
server_config for each combination of hostname (alias), listen address
and location section. Isn't this overkill?
To me it seems like server_config is serving too much purposes here. A
clean design should split up the struct server_config into one struct
for connection settings, which will contain a TAILQ of hostnames, a
TAILQ of listen addresses and a TAILQ of structs with location settings:

TAILQ_HEAD(hostnames, char*);

struct server_config {
        char                            location[NAME_MAX];
        char                            root[MAXPATHLEN];
        [...]
}
TAILQ_HEAD(server_configs, server_config);

struct serverhost {
        struct sockaddr_storages        *srv_ss;
        char                            *tls_cert;
        int                              tcpbufsize;
        [... other connection settings ...]
        struct hostnames                *srv_names;
        struct server_configs           *srv_confs;
}


For now you could simply loop over a TAILQ of hostnames in
server_privinit() and add an inner LOOP in server_response() searching
for the hostname/aliases.


Christopher



-- 
http://gmerlin.de
OpenPGP: http://gmerlin.de/christopher.pub
F190 D013 8F01 AA53 E080  3F3C F17F B0A1 D44E 4FEE

Reply via email to