formulaire ++, debug MX, securité concernant les entrées
This commit is contained in:
parent
b556491b72
commit
529130953b
@ -77,6 +77,7 @@ sub update {
|
|||||||
sub update_raw {
|
sub update_raw {
|
||||||
my ($self, $zonetext) = @_;
|
my ($self, $zonetext) = @_;
|
||||||
|
|
||||||
|
my $zonefile;
|
||||||
my $file = '/tmp/'.$self->zname;
|
my $file = '/tmp/'.$self->zname;
|
||||||
|
|
||||||
# write the updated zone file to disk
|
# write the updated zone file to disk
|
||||||
@ -85,10 +86,17 @@ sub update_raw {
|
|||||||
print $newzone $zonetext;
|
print $newzone $zonetext;
|
||||||
close $newzone;
|
close $newzone;
|
||||||
|
|
||||||
my $zonefile = DNS::ZoneParse->new($file, $self->zname);
|
eval { $zonefile = DNS::ZoneParse->new($file, $self->zname); };
|
||||||
|
|
||||||
|
if( $@ ) {
|
||||||
|
unlink($file);
|
||||||
|
0;
|
||||||
|
}
|
||||||
|
|
||||||
unlink($file);
|
unlink($file);
|
||||||
|
|
||||||
$self->update($zonefile);
|
$self->update($zonefile);
|
||||||
|
1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# sera utile plus tard, pour l'interface
|
# sera utile plus tard, pour l'interface
|
||||||
|
@ -136,14 +136,14 @@ prefix '/domain' => sub {
|
|||||||
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
|
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
|
||||||
param('password') );
|
param('password') );
|
||||||
|
|
||||||
$app->update_domain_raw(session('login')
|
my $success = $app->update_domain_raw(session('login')
|
||||||
, param('zoneupdated')
|
, param('zoneupdated')
|
||||||
, param('domain'));
|
, param('domain'));
|
||||||
|
|
||||||
redirect '/domain/details/' . param('domain');
|
redirect '/domain/details/' . param('domain');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
any ['post', 'get'] => '/update/:domain' => sub {
|
any ['post', 'get'] => '/update/:domain' => sub {
|
||||||
unless( session('login') && param('domain') )
|
unless( session('login') && param('domain') )
|
||||||
@ -152,75 +152,87 @@ prefix '/domain' => sub {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my $type = param('type');
|
my $type = param('type');
|
||||||
my $name = param('name');
|
my $name = param('name');
|
||||||
my $value = param('value');
|
my $value = param('value');
|
||||||
my $ttl = param('ttl');
|
my $ttl = param('ttl');
|
||||||
|
my $priority = param('priority');
|
||||||
|
|
||||||
my $app = initco();
|
my $app = initco();
|
||||||
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
|
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
|
||||||
param('password') );
|
param('password') );
|
||||||
my $zone = $app->get_domain( session('login') , param('domain') );
|
my $zone = $app->get_domain( session('login') , param('domain') );
|
||||||
given( $type )
|
given( $type )
|
||||||
{
|
{
|
||||||
|
|
||||||
when ('A') { my $a=$zone->a();
|
when ('A') {
|
||||||
push( @$a, {name => $name,
|
my $a = $zone->a();
|
||||||
class => "IN",
|
push( @$a, {name => $name
|
||||||
host => $value,
|
, class => "IN"
|
||||||
ttl => $ttl,
|
, host => $value
|
||||||
ORIGIN => $zone->origin} );
|
, ttl => $ttl
|
||||||
}
|
, ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
when ('AAAA') { my $aaaa=$zone->aaaa;
|
when ('AAAA') {
|
||||||
push(@$aaaa, {name => $name,
|
my $aaaa = $zone->aaaa;
|
||||||
class => "IN",
|
push(@$aaaa, {name => $name
|
||||||
host => $value,
|
, class => "IN"
|
||||||
ttl => $ttl,
|
, host => $value
|
||||||
ORIGIN => $zone->origin} );
|
, ttl => $ttl
|
||||||
}
|
, ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
when ('CNAME') { my $cname=$zone->cname;
|
when ('CNAME') {
|
||||||
push(@$cname,
|
my $cname = $zone->cname;
|
||||||
{name => $name,
|
push(@$cname,
|
||||||
class => "IN",
|
{name => $name
|
||||||
host => $value,
|
, class => "IN"
|
||||||
ttl => $ttl,
|
, host => $value
|
||||||
ORIGIN => $zone->origin} );
|
, ttl => $ttl
|
||||||
}
|
, ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
when ('MX') { my $ptr=$zone->ptr;
|
when ('MX') {
|
||||||
push(@$ptr, {name => $name,
|
my $mx = $zone->mx;
|
||||||
class => "IN",
|
push(@$mx, { name => $name
|
||||||
host => $value,
|
, class => "IN"
|
||||||
ttl => $ttl,
|
, host => $value
|
||||||
ORIGIN => $zone->origin} );
|
, priority => $priority
|
||||||
}
|
, ttl => $ttl
|
||||||
|
, ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
when ('PTR') { my $ptr=$zone->ptr;
|
when ('PTR') {
|
||||||
push(@$ptr, {name => $name,
|
my $ptr = $zone->ptr;
|
||||||
class => "IN",
|
push(@$ptr, {name => $name
|
||||||
host => $value,
|
, class => "IN"
|
||||||
ttl => $ttl,
|
, host => $value
|
||||||
ORIGIN => $zone->origin} );
|
, ttl => $ttl
|
||||||
}
|
, ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
when ('NS') { my $ns=$zone->ns;
|
when ('NS') {
|
||||||
push(@$ns, {name => $name,
|
my $ns = $zone->ns;
|
||||||
class => "IN",
|
push(@$ns, {name => $name
|
||||||
host => $value,
|
, class => "IN"
|
||||||
ttl => $ttl,
|
, host => $value
|
||||||
ORIGIN => $zone->origin} );
|
, ttl => $ttl
|
||||||
}
|
, ORIGIN => $zone->origin} );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$zone->new_serial();
|
|
||||||
my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini');
|
$zone->new_serial();
|
||||||
my $ed = app::zone::edit->new(zdir=>$cfg->param('zones_path'), zname => param('domain'));
|
my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini');
|
||||||
$ed->update($zone);
|
my $ed = app::zone::edit->new(zdir=>$cfg->param('zones_path')
|
||||||
redirect '/domain/details/'.param('domain');
|
, zname => param('domain'));
|
||||||
}
|
|
||||||
};
|
$ed->update($zone);
|
||||||
|
redirect '/domain/details/'.param('domain');
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
get '/details/:domain' => sub {
|
get '/details/:domain' => sub {
|
||||||
|
|
||||||
|
@ -87,25 +87,65 @@
|
|||||||
</table>
|
</table>
|
||||||
<a href='/domain/details/<% domain %>?expert=1'><button type="button" class="btn btn-primary">Visualisation en mode expert</button></a>
|
<a href='/domain/details/<% domain %>?expert=1'><button type="button" class="btn btn-primary">Visualisation en mode expert</button></a>
|
||||||
|
|
||||||
<br /><br />
|
|
||||||
|
|
||||||
Ajouter un enregistrement : <br />
|
<hr />
|
||||||
<form action='/domain/update/<% domain %>' method='post' >
|
<form class="form-horizontal" role="form" action='/domain/update/<% domain %>' method='post' >
|
||||||
|
|
||||||
<label for="name">Nom : </label><input type="text" name="name" />
|
<fieldset>
|
||||||
<label for="type">Type : </label><select name="type" id="type" >
|
<legend>Ajout d'un enregistrement</legend>
|
||||||
<option value="A">A</option>
|
|
||||||
<option value="AAAA">AAAA</option>
|
<div class="form-group">
|
||||||
<option value="CNAME">CNAME</option>
|
<label for="name" class="col-sm-2 control-label">Nom</label>
|
||||||
<option value="MX">MX</option>
|
<div class="col-sm-3">
|
||||||
<option value="NS">NS</option>
|
<input type="text" id="name" name="name" class="form-control" placeholder="www">
|
||||||
<option value="PTR">PTR</option>
|
</div>
|
||||||
</select>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="col-sm-2 control-label">Type</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<select class="form-control" name="type" id="type" >
|
||||||
|
<option value="A">A</option>
|
||||||
|
<option value="AAAA">AAAA</option>
|
||||||
|
<option value="CNAME">CNAME</option>
|
||||||
|
<option value="MX">MX</option>
|
||||||
|
<option value="NS">NS</option>
|
||||||
|
<option value="PTR">PTR</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="priority" class="col-sm-2 control-label">Priorité (MX)</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="text" id="priority" name="priority" class="form-control" value="10" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="value" class="col-sm-2 control-label">Valeur</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="text" id="value" name="value" class="form-control" placeholder="IP ou ndd" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="input_ttl" class="col-sm-2 control-label">TTL</label>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="number" id="input_ttl" name="ttl" class="form-control" value="3600" placeholder="3600" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-3">
|
||||||
|
<button type="submit" class="btn btn-primary">Ajouter</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
<label for="value">Valeur : </label><input type="text" id="value" name="value" />
|
|
||||||
<label for="input_ttl">TTL</label><input type="number" id="input_ttl" name="ttl" min='1' value="3600"/>
|
|
||||||
<button type="submit" class="btn btn-sm btn-primary">Valider</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<% END %>
|
<% END %>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user