# make sure that they correspond to your installation and setup!
# Server name in the IRC network, must contain at least one dot
- # (".") and be unique in the IRC network. Required!
- Name = irc.example.net
+ # (".") and be unique in the IRC network. When not set, ngIRCd tries
+ # to build a valid IRC server name from the local host name.
+ ;Name = irc.example.net
# Information about the server and the administrator, used by the
# ADMIN command. Not required by server but by RFC!
These settings depend on your personal preferences, so you should make sure
that they correspond to your installation and setup!
.TP
-\fBName\fR (string; required)
+\fBName\fR (string)
Server name in the IRC network. This is an individual name of the IRC
server, it is not related to the DNS host name. It must be unique in the
-IRC network and must contain at least one dot (".") character.
+IRC network and must contain at least one dot (".") character. When not set,
+ngIRCd tries to build a valid IRC server name from the local host name.
.TP
\fBAdminInfo1\fR, \fBAdminInfo2\fR, \fBAdminEMail\fR (string)
Information about the server and the administrator, used by the ADMIN
#include <grp.h>
#include <sys/types.h>
#include <dirent.h>
+#include <netdb.h>
#include "ngircd.h"
#include "conn.h"
#ifdef DEBUG
int i, servers, servers_once;
#endif
+ struct hostent *h;
bool config_valid = true;
char *ptr;
break;
} while (*(++ptr));
- if (!Conf_ServerName[0] || !strchr(Conf_ServerName, '.'))
- {
- /* No server name configured! */
+ if (!Conf_ServerName[0]) {
+ /* No server name configured, try to get a sane name from the
+ * host name. Note: the IRC server name MUST contain
+ * at least one dot, so the "node name" is not sufficient! */
+ gethostname(Conf_ServerName, sizeof(Conf_ServerName));
+ h = gethostbyname(Conf_ServerName);
+ if (h && strchr(h->h_name, '.')) {
+ /* Now we have a valid name! */
+ strlcpy(Conf_ServerName, h->h_name,
+ sizeof(Conf_ServerName));
+ Config_Error(LOG_WARNING,
+ "No server name configured, using host name \"%s\".",
+ Conf_ServerName);
+ } else {
+ /* No or no valid name, no dot! Show error message and
+ * reset the server name, so the regular error handler
+ * below will be triggered ... */
+ Config_Error(LOG_ALERT,
+ "Failed to get a valid server name from node name \"%s\"!",
+ Conf_ServerName);
+ Conf_ServerName[0] = '\0';
+ }
+ }
+ if (!Conf_ServerName[0] || !strchr(Conf_ServerName, '.')) {
config_valid = false;
Config_Error(LOG_ALERT,
"No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",