```
Some things are configurable via compile-time flags. In particular, `-DHAS_TLS`
-and some constants defined in `src/config.h`.
+and some constants defined in `src/config.h`. See the section on paths for
+additional flags.
## Config files
These have to go in datadir (see below).
With `--autojoin \#ircmoment` clients will automatically join the `#ircmoment`
channel. This option can be specified multiple times.
+The server hostname can be set via `--hostname`. The default is the machine's
+actual hostname
+
+## Paths
Data directory can be configured with `--datadir` argument. The default can be
configured at compile time via `IRCDDATADIR` define. Otherwise it deafults to
`LOCALSTATEDIR/lib/patchyircd` if `LOCALSTATEDIR` is defined. Otherwise it's
#ifndef ADMINEMAIL
#define ADMINEMAIL "admin@example.com"
#endif
-#ifndef IRCDHOSTNAME
-#define IRCDHOSTNAME "example.com"
-#endif
channelmap channel_map = {};
stringset autojoin = {};
-const char *hostname = IRCDHOSTNAME;
+const char *hostname = 0;
void sendbuf(struct client_data *client) {
fprintf(stderr, "SERVER %" PRISocket ": %.*s", client->FD, (int)databuf.len, (char*)databuf.buf);
sendClient(client, databuf.buf, databuf.len);
}
}
+static void determine_hostname(void)
+{
+ static char buf[256];
+ if (!hostname) {
+ if (gethostname(buf, 255) == -1) {
+ net_perror("gethostname");
+ hostname = "localhost";
+ } else {
+ hostname = buf;
+ }
+ }
+}
+
int main(int argc, char *argv[])
{
#define MAX_LISTENERS 16
return fprintf(stderr, "not enough parameters\n"), 1;
luadir = argv[i+1];
i += 1;
+ } else if(!strcmp(argv[i], "--hostname")) {
+ if (i + 1 >= argc)
+ return fprintf(stderr, "not enough parameters\n"), 1;
+ hostname = argv[i+1];
+ i += 1;
} else {
return fprintf(stderr, "unknown flag '%s'\n", argv[i]), 1;
}
}
+ determine_hostname();
+
if (!listener_count) {
listeners[listener_count].ctx = NULL;
listeners[listener_count++].sock = create_listen_sock("0", "6667");