Commit d742b765 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

wip(frontend): debug_ports setting

issue #1505
parent cfa19e30
......@@ -1467,6 +1467,11 @@ sub _sql_insert_defaults($self){
,name => 'display_password'
,value => 1
}
,{
id_parent => $id_backend
,name => "debug_ports"
,value => 0
}
]
);
my %field = ( settings => 'name' );
......@@ -4019,6 +4024,7 @@ sub _refresh_down_nodes($self, $request = undef ) {
}
sub _check_duplicated_prerouting($self, $request = undef ) {
my $debug_ports = $self->setting('/backend/debug_ports');
my $sth = $CONNECTOR->dbh->prepare(
"SELECT id FROM vms WHERE is_active=1 "
);
......@@ -4030,16 +4036,23 @@ sub _check_duplicated_prerouting($self, $request = undef ) {
if ($vm) {
my $iptables = $vm->iptables_list();
my %prerouting;
my %already_open;
for my $line (@{$iptables->{'nat'}}) {
my %args = @$line;
next if $args{A} ne 'PREROUTING' || !$args{dport};
my $port = $args{dport};
if ($prerouting{$port}) {
$self->_reopen_ports($port);
$self->_delete_iptables_rule($vm,'nat', \%args);
$self->_delete_iptables_rule($vm,'nat', $prerouting{$port});
for my $item ( 'dport' , 'to-destination') {
my $value = $args{$item} or next;
if ($prerouting{$value}) {
warn "".localtime(time)." clean duplicated prerouting "
.Dumper($prerouting{$value}, \%args) if $debug_ports;
$self->_reopen_ports($port) unless $already_open{$port}++;
$self->_delete_iptables_rule($vm,'nat', \%args);
$self->_delete_iptables_rule($vm,'nat', $prerouting{$port});
}
$prerouting{$value} = \%args;
}
$prerouting{$port} = \%args;
}
}
}
......
......@@ -117,6 +117,19 @@
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-2">
<label for="debug">Debug Ports</label>
</div>
<div class="col-md-6">
<input name="debug" ng-model="settings.backend.debug_ports.value"
ng-true-value="1" ng-false-value="0"
type="checkbox">
<%= l 'Debug Ports Exposed' %>
</div>
</div>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-2">
<label for="debug">Display Password</label>
</div>
<div class="col-md-6">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment