Obsolete
/
dnsmanagerv1
Archived
3
0
Fork 0

formulaire ++, debug MX, securité concernant les entrées

master
Philippe Pittoli 2014-01-25 14:08:01 +01:00
parent b556491b72
commit 529130953b
3 changed files with 141 additions and 81 deletions

View File

@ -77,6 +77,7 @@ sub update {
sub update_raw {
my ($self, $zonetext) = @_;
my $zonefile;
my $file = '/tmp/'.$self->zname;
# write the updated zone file to disk
@ -85,10 +86,17 @@ sub update_raw {
print $newzone $zonetext;
close $newzone;
my $zonefile = DNS::ZoneParse->new($file, $self->zname);
eval { $zonefile = DNS::ZoneParse->new($file, $self->zname); };
if( $@ ) {
unlink($file);
0;
}
unlink($file);
$self->update($zonefile);
1;
}
# sera utile plus tard, pour l'interface

View File

@ -136,14 +136,14 @@ prefix '/domain' => sub {
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
param('password') );
$app->update_domain_raw(session('login')
my $success = $app->update_domain_raw(session('login')
, param('zoneupdated')
, param('domain'));
redirect '/domain/details/' . param('domain');
}
}
};
};
any ['post', 'get'] => '/update/:domain' => sub {
unless( session('login') && param('domain') )
@ -152,75 +152,87 @@ prefix '/domain' => sub {
}
else
{
my $type = param('type');
my $name = param('name');
my $value = param('value');
my $ttl = param('ttl');
my $type = param('type');
my $name = param('name');
my $value = param('value');
my $ttl = param('ttl');
my $priority = param('priority');
my $app = initco();
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
param('password') );
my $zone = $app->get_domain( session('login') , param('domain') );
given( $type )
{
my $app = initco();
my ($auth_ok, $user, $isadmin) = $app->auth(param('login'),
param('password') );
my $zone = $app->get_domain( session('login') , param('domain') );
given( $type )
{
when ('A') { my $a=$zone->a();
push( @$a, {name => $name,
class => "IN",
host => $value,
ttl => $ttl,
ORIGIN => $zone->origin} );
}
when ('A') {
my $a = $zone->a();
push( @$a, {name => $name
, class => "IN"
, host => $value
, ttl => $ttl
, ORIGIN => $zone->origin} );
}
when ('AAAA') { my $aaaa=$zone->aaaa;
push(@$aaaa, {name => $name,
class => "IN",
host => $value,
ttl => $ttl,
ORIGIN => $zone->origin} );
}
when ('AAAA') {
my $aaaa = $zone->aaaa;
push(@$aaaa, {name => $name
, class => "IN"
, host => $value
, ttl => $ttl
, ORIGIN => $zone->origin} );
}
when ('CNAME') { my $cname=$zone->cname;
push(@$cname,
{name => $name,
class => "IN",
host => $value,
ttl => $ttl,
ORIGIN => $zone->origin} );
}
when ('CNAME') {
my $cname = $zone->cname;
push(@$cname,
{name => $name
, class => "IN"
, host => $value
, ttl => $ttl
, ORIGIN => $zone->origin} );
}
when ('MX') { my $ptr=$zone->ptr;
push(@$ptr, {name => $name,
class => "IN",
host => $value,
ttl => $ttl,
ORIGIN => $zone->origin} );
}
when ('MX') {
my $mx = $zone->mx;
push(@$mx, { name => $name
, class => "IN"
, host => $value
, priority => $priority
, ttl => $ttl
, ORIGIN => $zone->origin} );
}
when ('PTR') { my $ptr=$zone->ptr;
push(@$ptr, {name => $name,
class => "IN",
host => $value,
ttl => $ttl,
ORIGIN => $zone->origin} );
}
when ('PTR') {
my $ptr = $zone->ptr;
push(@$ptr, {name => $name
, class => "IN"
, host => $value
, ttl => $ttl
, ORIGIN => $zone->origin} );
}
when ('NS') { my $ns=$zone->ns;
push(@$ns, {name => $name,
class => "IN",
host => $value,
ttl => $ttl,
ORIGIN => $zone->origin} );
}
when ('NS') {
my $ns = $zone->ns;
push(@$ns, {name => $name
, class => "IN"
, host => $value
, ttl => $ttl
, ORIGIN => $zone->origin} );
}
}
$zone->new_serial();
my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini');
my $ed = app::zone::edit->new(zdir=>$cfg->param('zones_path'), zname => param('domain'));
$ed->update($zone);
redirect '/domain/details/'.param('domain');
}
};
}
$zone->new_serial();
my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini');
my $ed = app::zone::edit->new(zdir=>$cfg->param('zones_path')
, zname => param('domain'));
$ed->update($zone);
redirect '/domain/details/'.param('domain');
}
};
get '/details/:domain' => sub {

View File

@ -87,25 +87,65 @@
</table>
<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 />
<form action='/domain/update/<% domain %>' method='post' >
<hr />
<form class="form-horizontal" role="form" action='/domain/update/<% domain %>' method='post' >
<label for="name">Nom : </label><input type="text" name="name" />
<label for="type">Type : </label><select 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>
<fieldset>
<legend>Ajout d'un enregistrement</legend>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Nom</label>
<div class="col-sm-3">
<input type="text" id="name" name="name" class="form-control" placeholder="www">
</div>
</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 %>