Skip to content

Commit

Permalink
Factor out function to get default server param
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Sep 10, 2021
1 parent 8aaba1d commit 7077a90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
13 changes: 1 addition & 12 deletions save_server.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ else {
&nginx_text_parse("server_name", $server, undef, '^\S+$', undef, 1);
$name = $in{'server_name'};

# Get param for default server
my $ver = &get_nginx_version();
my $defserv;
if ($ver > 0.8 ||
$ver =~ /^0\.8\.(\d+)/ && $1 >= 21) {
$defserv = "default_server";
}
else {
$defserv = "default";
}

# Addresses to accept connections on
# XXX preserve existing args
my $i = 0;
Expand Down Expand Up @@ -129,7 +118,7 @@ else {
# Other random options
my @words = ( $ip );
if ($in{"default_$i"}) {
push(@words, $defserv);
push(@words, &get_default_server_param());
}
if ($in{"ssl_$i"}) {
push(@words, "ssl");
Expand Down
7 changes: 7 additions & 0 deletions virtualmin-nginx-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,13 @@ sub get_default
return $dir ? $dir->{'default'} : undef;
}

sub get_default_server_param
{
my $ver = &get_nginx_version();
return &compare_version_numbers($ver, "0.8.21") >= 0 ?
"default_server" : "default";
}

# list_nginx_modules()
# Returns a list of enabled modules. Includes those compiled in by default
# unless disabled, plus extra compiled in at build time.
Expand Down

0 comments on commit 7077a90

Please sign in to comment.