mirror of https://github.com/omar-polo/gmid.git
move hosts into the config struct
This commit is contained in:
parent
d273c0648d
commit
e45334e6ae
29
config.c
29
config.c
|
@ -30,9 +30,8 @@ config_init(void)
|
|||
{
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
|
||||
TAILQ_INIT(&hosts);
|
||||
|
||||
TAILQ_INIT(&conf.fcgi);
|
||||
TAILQ_INIT(&conf.hosts);
|
||||
|
||||
conf.port = 1965;
|
||||
conf.ipv6 = 0;
|
||||
|
@ -74,15 +73,8 @@ config_free(void)
|
|||
TAILQ_REMOVE(&conf.fcgi, f, fcgi);
|
||||
free(f);
|
||||
}
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
|
||||
conf.ps = ps;
|
||||
conf.sock4 = conf.sock6 = -1;
|
||||
conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
|
||||
init_mime(&conf.mime);
|
||||
TAILQ_INIT(&conf.fcgi);
|
||||
|
||||
TAILQ_FOREACH_SAFE(h, &hosts, vhosts, th) {
|
||||
TAILQ_FOREACH_SAFE(h, &conf.hosts, vhosts, th) {
|
||||
free(h->cert_path);
|
||||
free(h->key_path);
|
||||
free(h->ocsp_path);
|
||||
|
@ -122,9 +114,18 @@ config_free(void)
|
|||
free(p);
|
||||
}
|
||||
|
||||
TAILQ_REMOVE(&hosts, h, vhosts);
|
||||
TAILQ_REMOVE(&conf.hosts, h, vhosts);
|
||||
free(h);
|
||||
}
|
||||
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
|
||||
conf.ps = ps;
|
||||
conf.sock4 = conf.sock6 = -1;
|
||||
conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
|
||||
init_mime(&conf.mime);
|
||||
TAILQ_INIT(&conf.fcgi);
|
||||
TAILQ_INIT(&conf.hosts);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -242,7 +243,7 @@ config_send_socks(struct conf *conf)
|
|||
}
|
||||
|
||||
int
|
||||
config_send(struct conf *conf, struct vhosthead *hosts)
|
||||
config_send(struct conf *conf)
|
||||
{
|
||||
struct privsep *ps = conf->ps;
|
||||
struct etm *m;
|
||||
|
@ -286,7 +287,7 @@ config_send(struct conf *conf, struct vhosthead *hosts)
|
|||
return -1;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(h, hosts, vhosts) {
|
||||
TAILQ_FOREACH(h, &conf->hosts, vhosts) {
|
||||
struct vhost vcopy;
|
||||
|
||||
memcpy(&vcopy, h, sizeof(vcopy));
|
||||
|
@ -520,7 +521,7 @@ config_recv(struct conf *conf, struct imsg *imsg)
|
|||
vh = new_vhost();
|
||||
strlcpy(vh->domain, vht.domain, sizeof(vh->domain));
|
||||
h = vh;
|
||||
TAILQ_INSERT_TAIL(&hosts, h, vhosts);
|
||||
TAILQ_INSERT_TAIL(&conf->hosts, h, vhosts);
|
||||
|
||||
/* reset proxy */
|
||||
p = NULL;
|
||||
|
|
4
ge.c
4
ge.c
|
@ -34,8 +34,6 @@
|
|||
struct conf conf;
|
||||
int privsep_process;
|
||||
|
||||
struct vhosthead hosts = TAILQ_HEAD_INITIALIZER(hosts);
|
||||
|
||||
static const struct option opts[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
|
@ -290,7 +288,7 @@ main(int argc, char **argv)
|
|||
|
||||
/* set up the implicit vhost and location */
|
||||
host = xcalloc(1, sizeof(*host));
|
||||
TAILQ_INSERT_HEAD(&hosts, host, vhosts);
|
||||
TAILQ_INSERT_HEAD(&conf.hosts, host, vhosts);
|
||||
|
||||
loc = xcalloc(1, sizeof(*loc));
|
||||
loc->fcgi = -1;
|
||||
|
|
4
gmid.c
4
gmid.c
|
@ -58,8 +58,6 @@ static const struct option longopts[] = {
|
|||
{NULL, 0, NULL, 0},
|
||||
};
|
||||
|
||||
struct vhosthead hosts;
|
||||
|
||||
int sock4, sock6;
|
||||
int privsep_process;
|
||||
int pidfd = -1;
|
||||
|
@ -314,7 +312,7 @@ main_configure(struct conf *conf)
|
|||
if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_START, NULL, 0) == -1)
|
||||
return -1;
|
||||
|
||||
if (config_send(conf, &hosts) == -1)
|
||||
if (config_send(conf) == -1)
|
||||
return -1;
|
||||
|
||||
if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_END, NULL, 0) == -1)
|
||||
|
|
5
gmid.h
5
gmid.h
|
@ -168,7 +168,7 @@ struct alist {
|
|||
TAILQ_ENTRY(alist) aliases;
|
||||
};
|
||||
|
||||
extern TAILQ_HEAD(vhosthead, vhost) hosts;
|
||||
TAILQ_HEAD(vhosthead, vhost);
|
||||
struct vhost {
|
||||
char domain[HOST_NAME_MAX + 1];
|
||||
char *cert_path;
|
||||
|
@ -226,6 +226,7 @@ struct conf {
|
|||
struct event evsock6;
|
||||
|
||||
struct fcgihead fcgi;
|
||||
struct vhosthead hosts;
|
||||
};
|
||||
|
||||
extern const char *config_path;
|
||||
|
@ -340,7 +341,7 @@ void log_request(struct client *, char *, size_t);
|
|||
/* config.c */
|
||||
void config_init(void);
|
||||
void config_free(void);
|
||||
int config_send(struct conf *, struct vhosthead *);
|
||||
int config_send(struct conf *);
|
||||
int config_recv(struct conf *, struct imsg *);
|
||||
|
||||
/* parse.y */
|
||||
|
|
4
parse.y
4
parse.y
|
@ -237,7 +237,7 @@ option : CHROOT string {
|
|||
|
||||
vhost : SERVER string {
|
||||
host = new_vhost();
|
||||
TAILQ_INSERT_HEAD(&hosts, host, vhosts);
|
||||
TAILQ_INSERT_HEAD(&conf.hosts, host, vhosts);
|
||||
|
||||
loc = new_location();
|
||||
TAILQ_INSERT_HEAD(&host->locations, loc, locations);
|
||||
|
@ -953,7 +953,7 @@ print_conf(void)
|
|||
if (*conf.user != '\0')
|
||||
printf("user \"%s\"\n", conf.user);
|
||||
|
||||
TAILQ_FOREACH(h, &hosts, vhosts) {
|
||||
TAILQ_FOREACH(h, &conf.hosts, vhosts) {
|
||||
printf("\nserver \"%s\" {\n", h->domain);
|
||||
printf(" cert \"%s\"\n", h->cert);
|
||||
printf(" key \"%s\"\n", h->key);
|
||||
|
|
6
server.c
6
server.c
|
@ -433,7 +433,7 @@ handle_handshake(int fd, short ev, void *d)
|
|||
goto err;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(h, &hosts, vhosts) {
|
||||
TAILQ_FOREACH(h, &conf.hosts, vhosts) {
|
||||
if (matches(h->domain, c->domain))
|
||||
goto found;
|
||||
TAILQ_FOREACH(a, &h->aliases, aliases) {
|
||||
|
@ -1390,7 +1390,7 @@ setup_tls(void)
|
|||
fatalx("tls_config_set_protocols: %s",
|
||||
tls_config_error(tlsconf));
|
||||
|
||||
h = TAILQ_FIRST(&hosts);
|
||||
h = TAILQ_FIRST(&conf.hosts);
|
||||
|
||||
/* we need to set something, then we can add how many key we want */
|
||||
if (tls_config_set_keypair_mem(tlsconf, h->cert, h->certlen,
|
||||
|
@ -1421,7 +1421,7 @@ load_vhosts(void)
|
|||
struct vhost *h;
|
||||
struct location *l;
|
||||
|
||||
TAILQ_FOREACH(h, &hosts, vhosts) {
|
||||
TAILQ_FOREACH(h, &conf.hosts, vhosts) {
|
||||
TAILQ_FOREACH(l, &h->locations, locations) {
|
||||
if (*l->dir == '\0')
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue