Merge branch 'master' of ssh://git.code.sf.net/p/netdisco/netdisco-ng into em-datatables-v1_10_0
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
* Increase default snmptimeout from 1 to 3 seconds
|
* Increase default snmptimeout from 1 to 3 seconds
|
||||||
* Add documentation note about non-standard pg port
|
* Add documentation note about non-standard pg port
|
||||||
* [#23] Move to NetAddr::MAC for better handling of MACs
|
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ requires 'MCE' => 1.408;
|
|||||||
requires 'Net::Domain' => 1.23;
|
requires 'Net::Domain' => 1.23;
|
||||||
requires 'Net::DNS' => 0.72;
|
requires 'Net::DNS' => 0.72;
|
||||||
requires 'Net::LDAP' => 0;
|
requires 'Net::LDAP' => 0;
|
||||||
requires 'NetAddr::MAC' => 0.82;
|
requires 'Net::MAC' => 2.103622;
|
||||||
requires 'Net::NBName' => 0.26;
|
requires 'Net::NBName' => 0.26;
|
||||||
requires 'NetAddr::IP' => 4.068;
|
requires 'NetAddr::IP' => 4.068;
|
||||||
requires 'Opcode' => 1.07;
|
requires 'Opcode' => 1.07;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use NetAddr::IP::Lite ':lower';
|
|||||||
use List::MoreUtils ();
|
use List::MoreUtils ();
|
||||||
use Encode;
|
use Encode;
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
use NetAddr::MAC;
|
use Net::MAC;
|
||||||
|
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
our @EXPORT = ();
|
our @EXPORT = ();
|
||||||
@@ -713,8 +713,8 @@ sub store_neighbors {
|
|||||||
$device->ip, $remote_ip, $port, $remote_id;
|
$device->ip, $remote_ip, $port, $remote_id;
|
||||||
|
|
||||||
if (!defined $neigh) {
|
if (!defined $neigh) {
|
||||||
my $mac = NetAddr::MAC->new(mac => $remote_id);
|
my $mac = Net::MAC->new(mac => $remote_id, 'die' => 0, verbose => 0);
|
||||||
if (not $mac->errstr) {
|
if (not $mac->get_error) {
|
||||||
$neigh = $devices->single({mac => $remote_id});
|
$neigh = $devices->single({mac => $remote_id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package App::Netdisco::DB::Result::Node;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use NetAddr::MAC;
|
use Net::MAC;
|
||||||
|
|
||||||
use base 'DBIx::Class::Core';
|
use base 'DBIx::Class::Core';
|
||||||
__PACKAGE__->table("node");
|
__PACKAGE__->table("node");
|
||||||
@@ -175,10 +175,10 @@ sub time_last_stamp { return (shift)->get_column('time_last_stamp') }
|
|||||||
|
|
||||||
=head2 net_mac
|
=head2 net_mac
|
||||||
|
|
||||||
Returns the C<mac> column instantiated into a L<NetAddr::MAC> object.
|
Returns the C<mac> column instantiated into a L<Net::MAC> object.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) }
|
sub net_mac { return Net::MAC->new(mac => (shift)->mac) }
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package App::Netdisco::DB::Result::NodeIp;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use NetAddr::MAC;
|
use Net::MAC;
|
||||||
|
|
||||||
use base 'DBIx::Class::Core';
|
use base 'DBIx::Class::Core';
|
||||||
__PACKAGE__->table("node_ip");
|
__PACKAGE__->table("node_ip");
|
||||||
@@ -221,10 +221,10 @@ sub time_last_stamp { return (shift)->get_column('time_last_stamp') }
|
|||||||
|
|
||||||
=head2 net_mac
|
=head2 net_mac
|
||||||
|
|
||||||
Returns the C<mac> column instantiated into a L<NetAddr::MAC> object.
|
Returns the C<mac> column instantiated into a L<Net::MAC> object.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) }
|
sub net_mac { return Net::MAC->new(mac => (shift)->mac) }
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ package App::Netdisco::DB::Result::NodeNbt;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use NetAddr::MAC;
|
|
||||||
|
|
||||||
use base 'DBIx::Class::Core';
|
use base 'DBIx::Class::Core';
|
||||||
__PACKAGE__->table("node_nbt");
|
__PACKAGE__->table("node_nbt");
|
||||||
__PACKAGE__->add_columns(
|
__PACKAGE__->add_columns(
|
||||||
@@ -178,10 +176,10 @@ sub time_last_stamp { return (shift)->get_column('time_last_stamp') }
|
|||||||
|
|
||||||
=head2 net_mac
|
=head2 net_mac
|
||||||
|
|
||||||
Returns the C<mac> column instantiated into a L<NetAddr::MAC> object.
|
Returns the C<mac> column instantiated into a L<Net::MAC> object.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub net_mac { return NetAddr::MAC->new(mac => (shift)->mac) }
|
sub net_mac { return Net::MAC->new(mac => (shift)->mac) }
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -262,8 +262,8 @@ Compared to the current Netdisco, the handler routines are very small. This is
|
|||||||
because (a) they don't include any HTML - this is delegated to a template, and
|
because (a) they don't include any HTML - this is delegated to a template, and
|
||||||
(b) they don't include an SQL - this is delegated to DBIx::Class. Small
|
(b) they don't include an SQL - this is delegated to DBIx::Class. Small
|
||||||
routines are more manageable, and easier to maintain. You'll also notice use
|
routines are more manageable, and easier to maintain. You'll also notice use
|
||||||
of modules such as L<NetAddr::MAC> and L<NetAddr::IP::Lite> to simplify and
|
of modules such as L<Net::MAC> and L<NetAddr::IP::Lite> to simplify and make
|
||||||
make more robust the handling of data.
|
more robust the handling of data.
|
||||||
|
|
||||||
In fact, many sections of the web application have been factored out into
|
In fact, many sections of the web application have been factored out into
|
||||||
separate Plugin modules. For more information see the
|
separate Plugin modules. For more information see the
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package App::Netdisco::Util::Node;
|
|||||||
use Dancer qw/:syntax :script/;
|
use Dancer qw/:syntax :script/;
|
||||||
use Dancer::Plugin::DBIC 'schema';
|
use Dancer::Plugin::DBIC 'schema';
|
||||||
|
|
||||||
use NetAddr::MAC;
|
use Net::MAC;
|
||||||
use App::Netdisco::Util::Permission 'check_acl';
|
use App::Netdisco::Util::Permission 'check_acl';
|
||||||
|
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
@@ -66,18 +66,18 @@ MAC address does not belong to an interface on any known Device
|
|||||||
|
|
||||||
sub check_mac {
|
sub check_mac {
|
||||||
my ($device, $node, $port_macs) = @_;
|
my ($device, $node, $port_macs) = @_;
|
||||||
my $mac = NetAddr::MAC->new(mac => $node);
|
my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0);
|
||||||
$port_macs ||= {};
|
$port_macs ||= {};
|
||||||
|
|
||||||
# incomplete MAC addresses (BayRS frame relay DLCI, etc)
|
# incomplete MAC addresses (BayRS frame relay DLCI, etc)
|
||||||
if ($mac->errstr) {
|
if ($mac->get_error) {
|
||||||
debug sprintf ' [%s] check_mac - mac [%s] malformed - skipping',
|
debug sprintf ' [%s] check_mac - mac [%s] malformed - skipping',
|
||||||
$device->ip, $node;
|
$device->ip, $node;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# lower case, hex, colon delimited, 8-bit groups
|
# lower case, hex, colon delimited, 8-bit groups
|
||||||
$node = lc $mac->as_microsoft;
|
$node = lc $mac->as_IEEE;
|
||||||
}
|
}
|
||||||
|
|
||||||
# broadcast MAC addresses
|
# broadcast MAC addresses
|
||||||
|
|||||||
@@ -55,11 +55,6 @@ hook 'before' => sub {
|
|||||||
{ name => 'n_archived', label => 'Archived Data', default => '' },
|
{ name => 'n_archived', label => 'Archived Data', default => '' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
# not stored in the cookie - global defaults
|
|
||||||
params->{'age_num'} ||= 3;
|
|
||||||
params->{'age_unit'} ||= 'months';
|
|
||||||
params->{'mac_format'} ||= 'microsoft';
|
|
||||||
|
|
||||||
return unless (request->path eq uri_for('/device')->path
|
return unless (request->path eq uri_for('/device')->path
|
||||||
or index(request->path, uri_for('/ajax/content/device')->path) == 0);
|
or index(request->path, uri_for('/ajax/content/device')->path) == 0);
|
||||||
|
|
||||||
@@ -106,10 +101,15 @@ hook 'before' => sub {
|
|||||||
if $col->{default} eq 'on';
|
if $col->{default} eq 'on';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# not stored in the cookie
|
||||||
|
params->{'age_num'} ||= 3;
|
||||||
|
params->{'age_unit'} ||= 'months';
|
||||||
|
params->{'mac_format'} ||= 'IEEE';
|
||||||
|
|
||||||
if (param('reset')) {
|
if (param('reset')) {
|
||||||
params->{'age_num'} = 3;
|
params->{'age_num'} = 3;
|
||||||
params->{'age_unit'} = 'months';
|
params->{'age_unit'} = 'months';
|
||||||
params->{'mac_format'} = 'microsoft';
|
params->{'mac_format'} = 'IEEE';
|
||||||
|
|
||||||
# nuke the port params cookie
|
# nuke the port params cookie
|
||||||
cookie('nd_ports-form' => '', expires => '-1 day');
|
cookie('nd_ports-form' => '', expires => '-1 day');
|
||||||
@@ -129,21 +129,7 @@ hook 'before_template' => sub {
|
|||||||
$tokens->{device_ports}->query_param($key, params->{$key});
|
$tokens->{device_ports}->query_param($key, params->{$key});
|
||||||
}
|
}
|
||||||
|
|
||||||
# for NetAddr::MAC method
|
# for Net::MAC method
|
||||||
$tokens->{mac_formats} = {
|
|
||||||
basic => 'Basic',
|
|
||||||
# bpr => 'BPR',
|
|
||||||
cisco => 'Cisco',
|
|
||||||
ieee => 'IEEE',
|
|
||||||
# ipv6 => 'IPv6 Suffix',
|
|
||||||
microsoft => 'Microsoft',
|
|
||||||
singledash => 'Single Dash',
|
|
||||||
sun => 'Sun',
|
|
||||||
tokenring => 'Token Ring',
|
|
||||||
# eui48 => 'EUI48',
|
|
||||||
# eui64 => 'EUI64',
|
|
||||||
};
|
|
||||||
|
|
||||||
$tokens->{mac_format_call} = 'as_'. params->{'mac_format'}
|
$tokens->{mac_format_call} = 'as_'. params->{'mac_format'}
|
||||||
if params->{'mac_format'};
|
if params->{'mac_format'};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use Dancer::Plugin::DBIC;
|
|||||||
use Dancer::Plugin::Auth::Extensible;
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
use NetAddr::IP::Lite ':lower';
|
use NetAddr::IP::Lite ':lower';
|
||||||
use NetAddr::MAC ();
|
use Net::MAC ();
|
||||||
|
|
||||||
use App::Netdisco::Web::Plugin;
|
use App::Netdisco::Web::Plugin;
|
||||||
use App::Netdisco::Util::Web 'sql_match';
|
use App::Netdisco::Util::Web 'sql_match';
|
||||||
@@ -22,7 +22,7 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
my $agenot = param('age_invert') || '0';
|
my $agenot = param('age_invert') || '0';
|
||||||
my ( $start, $end ) = param('daterange') =~ /(\d+-\d+-\d+)/gmx;
|
my ( $start, $end ) = param('daterange') =~ /(\d+-\d+-\d+)/gmx;
|
||||||
|
|
||||||
my $mac = NetAddr::MAC->new(mac => $node);
|
my $mac = Net::MAC->new(mac => $node, 'die' => 0, verbose => 0);
|
||||||
my @active = (param('archived') ? () : (-bool => 'active'));
|
my @active = (param('archived') ? () : (-bool => 'active'));
|
||||||
|
|
||||||
my @times = ();
|
my @times = ();
|
||||||
@@ -48,7 +48,7 @@ ajax '/ajax/content/search/node' => require_login sub {
|
|||||||
|
|
||||||
my @where_mac =
|
my @where_mac =
|
||||||
($using_wildcards ? \['me.mac::text ILIKE ?', $likeval]
|
($using_wildcards ? \['me.mac::text ILIKE ?', $likeval]
|
||||||
: ($mac->errstr ? \'0=1' : ('me.mac' => $mac->as_microsoft)) );
|
: ($mac->get_error ? \'0=1' : ('me.mac' => $mac->as_IEEE)) );
|
||||||
|
|
||||||
my $sightings = schema('netdisco')->resultset('Node')
|
my $sightings = schema('netdisco')->resultset('Node')
|
||||||
->search({-and => [@where_mac, @active, @times]}, {
|
->search({-and => [@where_mac, @active, @times]}, {
|
||||||
|
|||||||
@@ -125,9 +125,8 @@
|
|||||||
<li>
|
<li>
|
||||||
<em class="muted">MAC address format:</em><br/>
|
<em class="muted">MAC address format:</em><br/>
|
||||||
<select id="nd_mac-format" name="mac_format">
|
<select id="nd_mac-format" name="mac_format">
|
||||||
[% FOREACH format IN mac_formats.keys.sort %]
|
[% FOREACH format IN [ 'IEEE', 'Cisco', 'Microsoft', 'Sun' ] %]
|
||||||
<option[% ' selected="selected"' IF params.mac_format == format %]
|
<option[% ' selected="selected"' IF params.mac_format == format %]>[% format %]</option>
|
||||||
value="[% format %]">[% mac_formats.$format %]</option>
|
|
||||||
[% END %]
|
[% END %]
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -55,9 +55,8 @@
|
|||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<em class="muted">MAC address format:</em><br/>
|
<em class="muted">MAC address format:</em><br/>
|
||||||
<select id="nd_node-mac-format" name="mac_format">
|
<select id="nd_node-mac-format" name="mac_format">
|
||||||
[% FOREACH format IN mac_formats.keys.sort %]
|
[% FOREACH format IN [ 'IEEE', 'Cisco', 'Microsoft', 'Sun' ] %]
|
||||||
<option[% ' selected="selected"' IF params.mac_format == format %]
|
<option[% ' selected="selected"' IF params.mac_format == format %]>[% format %]</option>
|
||||||
value="[% format %]">[% mac_formats.$format %]</option>
|
|
||||||
[% END %]
|
[% END %]
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user