@@ -129,22 +129,72 @@ ServerConfig::ServerConfig(int argc, char* argv[])
129129 return v.empty () ? " /etc/fptn/users.list" : v;
130130 });
131131 // Packet filters
132+ args_.add_argument (" --enable-domain-blacklist-filter" )
133+ .help (
134+ " Block the blacklisted domains: a TLS handshake whose SNI is a "
135+ " listed domain (or a subdomain of one) is dropped, and so are the "
136+ " QUIC and ICMP packets addressed to an IP such a domain resolves "
137+ " to. Enabled by default, set to 'false' to let this traffic "
138+ " through." )
139+ .default_value (" true" )
140+ .action ([](const std::string& v) -> std::string {
141+ return v.empty () ? " true" : v;
142+ });
143+ args_.add_argument (" --domain-blacklist-urls" )
144+ .help (
145+ " Comma-separated URLs of the domain lists to block, one domain per "
146+ " line ('#' starts a comment). Every list is cached in --data-dir and "
147+ " downloaded again once it is older than an hour. The lists extend "
148+ " the built-in one." )
149+ .default_value (FPTN_SERVER_DEFAULT_DOMAIN_BLACKLIST_URLS )
150+ .action ([](const std::string& v) -> std::string {
151+ return v.empty () ? FPTN_SERVER_DEFAULT_DOMAIN_BLACKLIST_URLS : v;
152+ });
132153 args_.add_argument (" --domain-blacklist-file" )
133154 .help (
134155 " Path to a file with domains to block, one per line ('#' starts a "
135156 " comment). Traffic to the addresses a listed domain or any of its "
136157 " subdomains resolves to is dropped. The list extends the built-in "
137158 " one. Empty (default) uses only the built-in list." )
138159 .default_value (" " );
139- args_.add_argument (" --disable-torrent-filter" )
160+ args_.add_argument (" --enable-ads-filter" )
161+ .help (
162+ " Block ads and trackers using the domain lists downloaded from "
163+ " --ads-blocklist-urls. A TLS handshake whose SNI is a listed domain "
164+ " (or a subdomain of one) is dropped, and every packet addressed to "
165+ " an IP such a domain resolves to is dropped as well. Enabled by "
166+ " default, set to 'false' to let this traffic through." )
167+ .default_value (" true" )
168+ .action ([](const std::string& v) -> std::string {
169+ return v.empty () ? " true" : v;
170+ });
171+ args_.add_argument (" --ads-blocklist-urls" )
172+ .help (
173+ " Comma-separated URLs of the ad/tracker domain lists (the hosts "
174+ " format and a bare domain per line are both accepted). Every list is "
175+ " cached in --data-dir and downloaded again once it is older than an "
176+ " hour." )
177+ .default_value (FPTN_SERVER_DEFAULT_ADS_BLOCKLIST_URLS )
178+ .action ([](const std::string& v) -> std::string {
179+ return v.empty () ? FPTN_SERVER_DEFAULT_ADS_BLOCKLIST_URLS : v;
180+ });
181+ args_.add_argument (" --data-dir" )
182+ .help (
183+ " Directory for the files the server downloads at runtime, such as "
184+ " the ad/tracker domain lists (default: /etc/fptn/data)" )
185+ .default_value (" /etc/fptn/data" )
186+ .action ([](const std::string& v) -> std::string {
187+ return v.empty () ? " /etc/fptn/data" : v;
188+ });
189+ args_.add_argument (" --enable-torrent-filter" )
140190 .help (
141191 " Block BitTorrent traffic. Enabled by default, set to 'false' to let "
142192 " BitTorrent packets through." )
143193 .default_value (" true" )
144194 .action ([](const std::string& v) -> std::string {
145195 return v.empty () ? " true" : v;
146196 });
147- args_.add_argument (" --disable -spam-filter" )
197+ args_.add_argument (" --enable -spam-filter" )
148198 .help (
149199 " Block the client traffic that gets this server blacklisted: "
150200 " outgoing mail (the SMTP ports, any TCP stream that starts with an "
@@ -279,12 +329,35 @@ std::string ServerConfig::UserFile() const {
279329 return args_.get <std::string>(" --userfile" );
280330}
281331
282- bool ServerConfig::DisableTorrentFilter () const {
283- return ParseBoolean (args_.get <std::string>(" --disable-torrent-filter" ));
332+ bool ServerConfig::EnableAdsFilter () const {
333+ return ParseBoolean (args_.get <std::string>(" --enable-ads-filter" ));
334+ }
335+
336+ std::vector<std::string> ServerConfig::AdsBlocklistUrls () const {
337+ return fptn::common::utils::SplitCommaSeparated (
338+ args_.get <std::string>(" --ads-blocklist-urls" ));
339+ }
340+
341+ std::string ServerConfig::DataDir () const {
342+ return args_.get <std::string>(" --data-dir" );
343+ }
344+
345+ bool ServerConfig::EnableTorrentFilter () const {
346+ return ParseBoolean (args_.get <std::string>(" --enable-torrent-filter" ));
347+ }
348+
349+ bool ServerConfig::EnableSpamFilter () const {
350+ return ParseBoolean (args_.get <std::string>(" --enable-spam-filter" ));
351+ }
352+
353+ bool ServerConfig::EnableDomainBlacklistFilter () const {
354+ return ParseBoolean (
355+ args_.get <std::string>(" --enable-domain-blacklist-filter" ));
284356}
285357
286- bool ServerConfig::DisableSpamFilter () const {
287- return ParseBoolean (args_.get <std::string>(" --disable-spam-filter" ));
358+ std::vector<std::string> ServerConfig::DomainBlacklistUrls () const {
359+ return fptn::common::utils::SplitCommaSeparated (
360+ args_.get <std::string>(" --domain-blacklist-urls" ));
288361}
289362
290363std::string ServerConfig::DomainBlacklistFile () const {
0 commit comments