+ rb_dlinkDestroy(ptr, &yy_dnsbl_entry_filters);
+ }
+
+ yy_dnsbl_entry_filters = (rb_dlink_list){ NULL, NULL, 0 };
+
+ rb_free(yy_dnsbl_entry_host);
+ rb_free(yy_dnsbl_entry_reason);
+ yy_dnsbl_entry_host = NULL;
+ yy_dnsbl_entry_reason = NULL;
+ yy_dnsbl_entry_iptype = 0;
+}
+
+
+struct opm_scanner
+{
+ const char *type;
+ uint16_t port;
+
+ rb_dlink_node node;
+};
+
+static int
+conf_begin_opm(struct TopConf *tc)
+{
+ yy_opm_address_ipv4 = yy_opm_address_ipv6 = NULL;
+ yy_opm_port_ipv4 = yy_opm_port_ipv6 = yy_opm_timeout = 0;
+ delete_opm_proxy_scanner_all();
+ delete_opm_listener_all();
+ return 0;
+}
+
+static int
+conf_end_opm(struct TopConf *tc)
+{
+ rb_dlink_node *ptr, *nptr;
+ bool fail = false;
+
+ if(rb_dlink_list_length(&yy_opm_scanner_list) == 0)
+ {
+ conf_report_error("No opm scanners configured -- disabling opm.");
+ fail = true;
+ goto end;
+ }
+
+ if(yy_opm_port_ipv4 > 0)
+ {
+ if(yy_opm_address_ipv4 != NULL)
+ conf_create_opm_listener(yy_opm_address_ipv4, yy_opm_port_ipv4);
+ else
+ {
+ char ip[HOSTIPLEN];
+ if(!rb_inet_ntop_sock((struct sockaddr *)&ServerInfo.bind4, ip, sizeof(ip)))
+ conf_report_error("No opm::listen_ipv4 nor serverinfo::vhost directive; cannot listen on IPv4");
+ else
+ conf_create_opm_listener(ip, yy_opm_port_ipv4);
+ }
+ }
+
+ if(yy_opm_port_ipv6 > 0)
+ {
+ if(yy_opm_address_ipv6 != NULL)
+ conf_create_opm_listener(yy_opm_address_ipv6, yy_opm_port_ipv6);
+ else
+ {
+ char ip[HOSTIPLEN];
+ if(!rb_inet_ntop_sock((struct sockaddr *)&ServerInfo.bind6, ip, sizeof(ip)))
+ conf_report_error("No opm::listen_ipv6 nor serverinfo::vhost directive; cannot listen on IPv6");
+ else
+ conf_create_opm_listener(ip, yy_opm_port_ipv6);
+ }
+ }
+
+ /* If there's no listeners... */
+ fail = (yy_opm_port_ipv4 == 0 || yy_opm_port_ipv6 == 0);
+ if(!fail && yy_opm_timeout > 0 && yy_opm_timeout < 60)
+ /* Send timeout */
+ set_authd_timeout("opm_timeout", yy_opm_timeout);
+ else if(fail)
+ conf_report_error("No opm listeners -- disabling");
+ else if(yy_opm_timeout <= 0 || yy_opm_timeout >= 60)
+ conf_report_error("opm::timeout value is invalid -- ignoring");
+
+end:
+ RB_DLINK_FOREACH_SAFE(ptr, nptr, yy_opm_scanner_list.head)
+ {
+ struct opm_scanner *scanner = ptr->data;
+
+ if(!fail)
+ create_opm_proxy_scanner(scanner->type, scanner->port);
+
+ rb_dlinkDelete(&scanner->node, &yy_opm_scanner_list);
+ rb_free(scanner);
+ }
+
+ if(!fail)
+ opm_check_enable(true);
+
+ rb_free(yy_opm_address_ipv4);
+ rb_free(yy_opm_address_ipv6);
+ return 0;
+}
+
+static void
+conf_set_opm_timeout(void *data)
+{
+ int timeout = *((int *)data);
+
+ if(timeout <= 0 || timeout > 60)
+ {
+ conf_report_error("opm::timeout value %d is bogus, ignoring", timeout);
+ return;
+ }
+
+ yy_opm_timeout = timeout;
+}
+
+static void
+conf_set_opm_listen_address_both(void *data, bool ipv6)
+{
+ struct rb_sockaddr_storage addr;
+ const char *confstr = (ipv6 ? "opm::listen_ipv6" : "opm::listen_ipv4");
+ char *ip = data;
+
+ if(!rb_inet_pton_sock(ip, &addr))
+ {
+ conf_report_error("%s is an invalid address: %s", confstr, ip);
+ return;
+ }
+
+ if(ipv6)
+ {
+ if(GET_SS_FAMILY(&addr) != AF_INET6)
+ {
+ conf_report_error("%s is of the wrong address type: %s", confstr, ip);
+ return;
+ }
+
+ if(yy_opm_address_ipv6 != NULL)
+ {
+ conf_report_error("%s overwrites previous address %s", confstr, ip);
+ return;
+ }
+
+ yy_opm_address_ipv6 = rb_strdup(ip);
+ }
+ else
+ {
+ if(GET_SS_FAMILY(&addr) != AF_INET)
+ {
+ conf_report_error("%s is of the wrong address type: %s", confstr, ip);
+ return;
+ }
+
+ if(yy_opm_address_ipv4 != NULL)
+ {
+ conf_report_error("%s overwrites previous address %s", confstr, ip);
+ return;
+ }
+
+ yy_opm_address_ipv4 = rb_strdup(ip);