commit: fewer blank lines in generated code

pull/29/head
Alec Muffett 2017-12-02 13:35:24 +00:00
rodzic 06f04766f6
commit 64240b69a8
4 zmienionych plików z 5 dodań i 59 usunięć

Wyświetl plik

@ -41,7 +41,6 @@ sub blackwhite {
push(@black, "%%ELSE\n");
push(@black, "# no $lc_bl $warning\n");
push(@black, "%%ENDIF\n");
push(@black, "\n");
push(@white, "%%IF %$uc_wl%\n");
push(@white, "# check $lc_wl $warning\n");
@ -52,7 +51,6 @@ sub blackwhite {
push(@white, "%%ELSE\n");
push(@white, "# no $lc_wl $warning\n");
push(@white, "%%ENDIF\n");
push(@white, "\n");
push(@tail, "%%IF %$uc_wl%\n");
push(@tail, "# check success of $lc_wl $warning\n");
@ -60,7 +58,6 @@ sub blackwhite {
push(@tail, "%%ELSE\n");
push(@tail, "# no check for success of $lc_wl $warning\n");
push(@tail, "%%ENDIF\n");
push(@tail, "\n");
}
@ -86,7 +83,6 @@ while (<DATA>) {
push(@polite, "%%ELSE\n");
push(@polite, "# no polite block for $lc_what $warning\n");
push(@polite, "%%ENDIF\n");
push(@polite, "\n");
}
elsif ($how eq "redirect") {
my $uc_what = uc($lc_what);
@ -98,7 +94,6 @@ while (<DATA>) {
push(@redirect, "%%ELSE\n");
push(@redirect, "# no redirect $lc_what $warning\n");
push(@redirect, "%%ENDIF\n");
push(@redirect, "\n");
}
else {
die "bad config line at line $.: $_\n";
@ -107,28 +102,28 @@ while (<DATA>) {
open(OUT, ">nginx-generated-blocks.conf") || die;
print OUT $indent x 2, $begin;
print OUT $indent x 2, "# polite blocks $warning\n\n";
print OUT $indent x 2, "# polite blocks $warning\n";
foreach $x (@polite) {
print OUT $indent x 2 if ($x !~ /^\s*$/);
print OUT $x;
}
print OUT "\n";
print OUT $indent x 2, "# blacklists $warning\n\n";
print OUT $indent x 2, "# blacklists $warning\n";
foreach $x (@black) {
print OUT $indent x 2 if ($x !~ /^\s*$/);
print OUT $x;
}
print OUT "\n";
print OUT $indent x 2, "# redirects $warning\n\n";
print OUT $indent x 2, "# redirects $warning\n";
foreach $x (@redirect) {
print OUT $indent x 2 if ($x !~ /^\s*$/);
print OUT $x;
}
print OUT "\n";
print OUT $indent x 2, "# whitelists $warning\n\n";
print OUT $indent x 2, "# whitelists $warning\n";
foreach $x (@white) {
print OUT $indent x 2 if ($x !~ /^\s*$/);
print OUT $x;
@ -139,7 +134,7 @@ close(OUT);
open(OUT, ">nginx-generated-checks.conf") || die;
print OUT $indent x 3, $begin;
print OUT $indent x 3, "# whitelist checks $warning\n\n";
print OUT $indent x 3, "# whitelist checks $warning\n";
foreach $x (@tail) {
print OUT $indent x 3 if ($x !~ /^\s*$/);
print OUT $x;

Wyświetl plik

@ -1,7 +1,6 @@
# ---- BEGIN GENERATED CODE ---- -*- awk -*-
# polite blocks (generated)
%%IF %SUPPRESS_TOR2WEB%
# polite block for suppress_tor2web (generated)
%%CSV %SUPPRESS_TOR2WEB%
@ -10,7 +9,6 @@
%%ELSE
# no polite block for suppress_tor2web (generated)
%%ENDIF
%%IF %BLOCK_HOST%
# polite block for block_host (generated)
%%CSV %BLOCK_HOST%
@ -19,7 +17,6 @@
%%ELSE
# no polite block for block_host (generated)
%%ENDIF
%%IF %BLOCK_HOST_RE%
# polite block for block_host_re (generated)
%%CSV %BLOCK_HOST_RE%
@ -28,7 +25,6 @@
%%ELSE
# no polite block for block_host_re (generated)
%%ENDIF
%%IF %BLOCK_PATH%
# polite block for block_path (generated)
%%CSV %BLOCK_PATH%
@ -37,7 +33,6 @@
%%ELSE
# no polite block for block_path (generated)
%%ENDIF
%%IF %BLOCK_PATH_RE%
# polite block for block_path_re (generated)
%%CSV %BLOCK_PATH_RE%
@ -46,7 +41,6 @@
%%ELSE
# no polite block for block_path_re (generated)
%%ENDIF
%%IF %BLOCK_LOCATION%
# polite block for block_location (generated)
%%CSV %BLOCK_LOCATION%
@ -55,7 +49,6 @@
%%ELSE
# no polite block for block_location (generated)
%%ENDIF
%%IF %BLOCK_LOCATION_RE%
# polite block for block_location_re (generated)
%%CSV %BLOCK_LOCATION_RE%
@ -64,7 +57,6 @@
%%ELSE
# no polite block for block_location_re (generated)
%%ENDIF
%%IF %BLOCK_PARAM%
# polite block for block_param (generated)
%%CSV %BLOCK_PARAM%
@ -73,7 +65,6 @@
%%ELSE
# no polite block for block_param (generated)
%%ENDIF
%%IF %BLOCK_PARAM_RE%
# polite block for block_param_re (generated)
%%CSV %BLOCK_PARAM_RE%
@ -83,9 +74,7 @@
# no polite block for block_param_re (generated)
%%ENDIF
# blacklists (generated)
%%IF %USER_AGENT_BLACKLIST%
# check user_agent_blacklist (generated)
%%CSV %USER_AGENT_BLACKLIST%
@ -94,7 +83,6 @@
%%ELSE
# no user_agent_blacklist (generated)
%%ENDIF
%%IF %USER_AGENT_BLACKLIST_RE%
# check user_agent_blacklist_re (generated)
%%CSV %USER_AGENT_BLACKLIST_RE%
@ -103,7 +91,6 @@
%%ELSE
# no user_agent_blacklist_re (generated)
%%ENDIF
%%IF %REFERER_BLACKLIST%
# check referer_blacklist (generated)
%%CSV %REFERER_BLACKLIST%
@ -112,7 +99,6 @@
%%ELSE
# no referer_blacklist (generated)
%%ENDIF
%%IF %REFERER_BLACKLIST_RE%
# check referer_blacklist_re (generated)
%%CSV %REFERER_BLACKLIST_RE%
@ -121,7 +107,6 @@
%%ELSE
# no referer_blacklist_re (generated)
%%ENDIF
%%IF %HOST_BLACKLIST%
# check host_blacklist (generated)
%%CSV %HOST_BLACKLIST%
@ -130,7 +115,6 @@
%%ELSE
# no host_blacklist (generated)
%%ENDIF
%%IF %HOST_BLACKLIST_RE%
# check host_blacklist_re (generated)
%%CSV %HOST_BLACKLIST_RE%
@ -139,7 +123,6 @@
%%ELSE
# no host_blacklist_re (generated)
%%ENDIF
%%IF %PATH_BLACKLIST%
# check path_blacklist (generated)
%%CSV %PATH_BLACKLIST%
@ -148,7 +131,6 @@
%%ELSE
# no path_blacklist (generated)
%%ENDIF
%%IF %PATH_BLACKLIST_RE%
# check path_blacklist_re (generated)
%%CSV %PATH_BLACKLIST_RE%
@ -157,7 +139,6 @@
%%ELSE
# no path_blacklist_re (generated)
%%ENDIF
%%IF %PARAM_BLACKLIST%
# check param_blacklist (generated)
%%CSV %PARAM_BLACKLIST%
@ -166,7 +147,6 @@
%%ELSE
# no param_blacklist (generated)
%%ENDIF
%%IF %PARAM_BLACKLIST_RE%
# check param_blacklist_re (generated)
%%CSV %PARAM_BLACKLIST_RE%
@ -176,9 +156,7 @@
# no param_blacklist_re (generated)
%%ENDIF
# redirects (generated)
%%IF %REDIRECT_HOST_CSV%
# redirect redirect_host_csv: 1=regexp,2=dest,3=code (generated)
%%CSV %REDIRECT_HOST_CSV%
@ -187,7 +165,6 @@
%%ELSE
# no redirect redirect_host_csv (generated)
%%ENDIF
%%IF %REDIRECT_PATH_CSV%
# redirect redirect_path_csv: 1=regexp,2=dest,3=code (generated)
%%CSV %REDIRECT_PATH_CSV%
@ -196,7 +173,6 @@
%%ELSE
# no redirect redirect_path_csv (generated)
%%ENDIF
%%IF %REDIRECT_LOCATION_CSV%
# redirect redirect_location_csv: 1=regexp,2=dest,3=code (generated)
%%CSV %REDIRECT_LOCATION_CSV%
@ -206,9 +182,7 @@
# no redirect redirect_location_csv (generated)
%%ENDIF
# whitelists (generated)
%%IF %USER_AGENT_WHITELIST%
# check user_agent_whitelist (generated)
set $non_whitelist_user_agent 1;
@ -218,7 +192,6 @@
%%ELSE
# no user_agent_whitelist (generated)
%%ENDIF
%%IF %USER_AGENT_WHITELIST_RE%
# check user_agent_whitelist_re (generated)
set $non_whitelist_user_agent 1;
@ -228,7 +201,6 @@
%%ELSE
# no user_agent_whitelist_re (generated)
%%ENDIF
%%IF %REFERER_WHITELIST%
# check referer_whitelist (generated)
set $non_whitelist_referer 1;
@ -238,7 +210,6 @@
%%ELSE
# no referer_whitelist (generated)
%%ENDIF
%%IF %REFERER_WHITELIST_RE%
# check referer_whitelist_re (generated)
set $non_whitelist_referer 1;
@ -248,7 +219,6 @@
%%ELSE
# no referer_whitelist_re (generated)
%%ENDIF
%%IF %HOST_WHITELIST%
# check host_whitelist (generated)
set $non_whitelist_host 1;
@ -258,7 +228,6 @@
%%ELSE
# no host_whitelist (generated)
%%ENDIF
%%IF %HOST_WHITELIST_RE%
# check host_whitelist_re (generated)
set $non_whitelist_host 1;
@ -268,7 +237,6 @@
%%ELSE
# no host_whitelist_re (generated)
%%ENDIF
%%IF %PATH_WHITELIST%
# check path_whitelist (generated)
set $non_whitelist_path 1;
@ -278,7 +246,6 @@
%%ELSE
# no path_whitelist (generated)
%%ENDIF
%%IF %PATH_WHITELIST_RE%
# check path_whitelist_re (generated)
set $non_whitelist_path 1;
@ -288,7 +255,6 @@
%%ELSE
# no path_whitelist_re (generated)
%%ENDIF
%%IF %PARAM_WHITELIST%
# check param_whitelist (generated)
set $non_whitelist_param 1;
@ -298,7 +264,6 @@
%%ELSE
# no param_whitelist (generated)
%%ENDIF
%%IF %PARAM_WHITELIST_RE%
# check param_whitelist_re (generated)
set $non_whitelist_param 1;
@ -309,5 +274,4 @@
# no param_whitelist_re (generated)
%%ENDIF
# ---- END GENERATED CODE ----

Wyświetl plik

@ -1,70 +1,60 @@
# ---- BEGIN GENERATED CODE ---- -*- awk -*-
# whitelist checks (generated)
%%IF %USER_AGENT_WHITELIST%
# check success of user_agent_whitelist (generated)
if ( $non_whitelist_user_agent ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of user_agent_whitelist (generated)
%%ENDIF
%%IF %USER_AGENT_WHITELIST_RE%
# check success of user_agent_whitelist_re (generated)
if ( $non_whitelist_user_agent ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of user_agent_whitelist_re (generated)
%%ENDIF
%%IF %REFERER_WHITELIST%
# check success of referer_whitelist (generated)
if ( $non_whitelist_referer ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of referer_whitelist (generated)
%%ENDIF
%%IF %REFERER_WHITELIST_RE%
# check success of referer_whitelist_re (generated)
if ( $non_whitelist_referer ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of referer_whitelist_re (generated)
%%ENDIF
%%IF %HOST_WHITELIST%
# check success of host_whitelist (generated)
if ( $non_whitelist_host ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of host_whitelist (generated)
%%ENDIF
%%IF %HOST_WHITELIST_RE%
# check success of host_whitelist_re (generated)
if ( $non_whitelist_host ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of host_whitelist_re (generated)
%%ENDIF
%%IF %PATH_WHITELIST%
# check success of path_whitelist (generated)
if ( $non_whitelist_path ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of path_whitelist (generated)
%%ENDIF
%%IF %PATH_WHITELIST_RE%
# check success of path_whitelist_re (generated)
if ( $non_whitelist_path ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of path_whitelist_re (generated)
%%ENDIF
%%IF %PARAM_WHITELIST%
# check success of param_whitelist (generated)
if ( $non_whitelist_param ) { %NGINX_ACTION_ABORT%; }
%%ELSE
# no check for success of param_whitelist (generated)
%%ENDIF
%%IF %PARAM_WHITELIST_RE%
# check success of param_whitelist_re (generated)
if ( $non_whitelist_param ) { %NGINX_ACTION_ABORT%; }
@ -72,5 +62,4 @@
# no check for success of param_whitelist_re (generated)
%%ENDIF
# ---- END GENERATED CODE ----

Wyświetl plik

@ -566,7 +566,6 @@ http {
# no cookie_lock cookie setting
%%ENDIF
# include generated blocks
%%INCLUDE templates.d/nginx-generated-blocks.conf
%%IF %NGINX_HELLO_ONION%
@ -641,7 +640,6 @@ http {
# for traffic
location / {
# include generated whitelist checks
%%INCLUDE templates.d/nginx-generated-checks.conf
%%IF %COOKIE_LOCK%