return "";
}
break;
+ case BINDADDR6:
+ setting = config_lookup(&configuration, "bindaddr6");
+ if (!setting)
+ return "";
+ else {
+ if ((strsetting = config_setting_get_string(setting)) != NULL)
+ return strsetting;
+ else
+ return "";
+ }
+ break;
case WELCOMETEXT:
setting = config_lookup(&configuration, "welcometext");
if (!setting)
return config_setting_get_int(setting);
}
break;
+ case BINDPORT6:
+ setting = config_lookup(&configuration, "bindport6");
+ if (!setting)
+ return DEFAULT_BINDPORT;
+ else {
+ return config_setting_get_int(setting);
+ }
+ break;
case BAN_LENGTH:
setting = config_lookup(&configuration, "ban_length");
if (!setting)
char system_string[64], version_string[64];
int bindport;
+int bindport6;
char *bindaddr;
+char *bindaddr6;
void lockfile(const char *pidfile)
{
/* Arguments */
#ifdef POSIX_PRIORITY_SCHEDULING
- while ((c = getopt(argc, argv, "drp:c:a:b:ht")) != EOF) {
+ while ((c = getopt(argc, argv, "drp:c:a:A:b:B:ht")) != EOF) {
#else
- while ((c = getopt(argc, argv, "dp:c:a:b:ht")) != EOF) {
+ while ((c = getopt(argc, argv, "dp:c:a:A:b:B:ht")) != EOF) {
#endif
switch(c) {
case 'c':
case 'a':
bindaddr = optarg;
break;
+ case 'A':
+ bindaddr6 = optarg;
+ break;
case 'b':
bindport = atoi(optarg);
break;
+ case 'B':
+ bindport6 = atoi(optarg);
+ break;
case 'd':
nodaemon = true;
break;
#define TCP_SOCK 0
#define UDP_SOCK 1
+#define TCP6_SOCK 2
+#define UDP6_SOCK 3
+
/* globals */
int udpsock;
bool_t shutdown_server;
extern char *bindaddr;
+extern char *bindaddr6;
extern int bindport;
+extern int bindport6;
+
+struct sockaddr_storage** Server_setupAddressesAndPorts()
+{
+ struct sockaddr_storage** addresses;
+
+ struct sockaddr_storage* v4address = calloc(1, sizeof(struct sockaddr_storage));
+ v4address->ss_family = AF_INET;
+ v4address->ss_len = sizeof(struct sockaddr_storage);
+ struct sockaddr_storage* v6address = calloc(1, sizeof(struct sockaddr_storage));
+ v6address->ss_family = AF_INET;
+ v6address->ss_len = sizeof(struct sockaddr_storage);
+
+ int error = 0;
+
+ error = inet_pton(AF_INET, (!bindaddr) ? ((getStrConf(BINDADDR)) ? getStrConf(BINDADDR) : "0.0.0.0")
+ : bindaddr, &(((struct sockaddr_in*)v4address)->sin_addr));
+ if (error == 0) Log_fatal("Invalid IPv4 address supplied!");
+
+ error = inet_pton(AF_INET, (!bindaddr6) ? ((getStrConf(BINDADDR6)) ? getStrConf(BINDADDR6) : "::")
+ : bindaddr6, &(((struct sockaddr_in6*)v6address)->sin6_addr));
+ if (error == 0) Log_fatal("Invalid IPv6 address supplied!");
+
+ ((struct sockaddr_in*)v4address)->sin_port = htons((bindport) ? bindport : getIntConf(BINDPORT));
+ ((struct sockaddr_in6*)v6address)->sin6_port = htons((bindport) ? bindport : getIntConf(BINDPORT));
+
+ addresses[0] = v4address;
+ addresses[1] = v6address;
+
+ return addresses;
+}
void Server_run()
{