/[smecontribs]/rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch
ViewVC logotype

Diff of /rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.4 by brianr, Sat Jan 20 14:09:56 2024 UTC Revision 1.7 by brianr, Mon Jan 22 20:02:27 2024 UTC
# Line 1  Line 1 
1  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm
2  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm     2023-12-19 09:44:56.678590486 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm     2023-12-19 09:44:56.678590486 +0000
3  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-20 13:24:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-22 19:57:00.000000000 +0000
4  @@ -137,15 +137,16 @@  @@ -140,12 +140,12 @@
         #  
         # call to show scan results  
         #  
 +       my $y = 1/0;  
5          my $c = shift;          my $c = shift;
6       my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");       my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");
7       my $modul = '';       my $modul = '';
# Line 22  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 18  diff -urN smeserver-dhcpmanager-2.0.4.ol
18       $c->render( template => 'dhcpd' );       $c->render( template => 'dhcpd' );
19   }   }
20        
21  @@ -332,10 +333,10 @@  @@ -332,10 +332,10 @@
22          my $c = shift;          my $c = shift;
23       my $ret = delete_all_leases($c);       my $ret = delete_all_leases($c);
24          if ($ret == 'ok') {          if ($ret == 'ok') {
# Line 35  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 31  diff -urN smeserver-dhcpmanager-2.0.4.ol
31       return ;       return ;
32   }   }
33    
34  @@ -352,17 +353,17 @@  @@ -352,17 +352,17 @@
35       # else return "ok"       # else return "ok"
36       my $ret = delete_lease($c);       my $ret = delete_lease($c);
37          if ($ret == 'ok') {          if ($ret == 'ok') {
# Line 56  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 52  diff -urN smeserver-dhcpmanager-2.0.4.ol
52   }   }
53                    
54    
55  @@ -374,13 +375,13 @@  @@ -374,13 +374,13 @@
56    
57   sub delete_one_lease {   sub delete_one_lease {
58          my $c = shift;            my $c = shift;  
# Line 72  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 68  diff -urN smeserver-dhcpmanager-2.0.4.ol
68       return "ok";       return "ok";
69   }   }
70    
71  @@ -391,6 +392,118 @@  @@ -391,6 +391,169 @@
72       return @leases;       return @leases;
73   }   }
74    
# Line 148  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 144  diff -urN smeserver-dhcpmanager-2.0.4.ol
144  +      $binoct = dec2bin($_);  +      $binoct = dec2bin($_);
145  +      $binmask = $binmask . substr $binoct, -8;  +      $binmask = $binmask . substr $binoct, -8;
146  +    }  +    }
147  +  +
148  +    # let's count the 1s  +    # let's count the 1s
149  +    @bits = split (//,$binmask);  +    @bits = split (//,$binmask);
150  +    foreach (@bits) {  +    foreach (@bits) {
# Line 156  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 152  diff -urN smeserver-dhcpmanager-2.0.4.ol
152  +        $bitcount++;  +        $bitcount++;
153  +      }  +      }
154  +    }  +    }
 +  
155  +    my $cidr = $network . "/" . $bitcount;  +    my $cidr = $network . "/" . $bitcount;
156  +    return $cidr;  +    return $cidr;
157  +}  +}
158  +  +
159    +sub get_mac_address {
160    +       # From the leases file
161    +    my ($ip, $file) = @_;
162    +    open(my $fh, '<', $file) or die "Could not open file '$file' $!";
163    +    my $mac_address = undef;
164    +    my $lease_block;
165    +    while(my $line = <$fh>) {
166    +        if($line =~ /lease $ip {/ .. $line =~ /}/) {
167    +            $lease_block .= $line;
168    +            if($line =~ /}/) {
169    +                if($lease_block =~ /hardware ethernet (\S+);/) {
170    +                    $mac_address = $1;
171    +                    last;
172    +                } else {
173    +                    $lease_block = '';
174    +                }
175    +            }
176    +        }
177    +    }
178    +    close $fh;
179    +    return $mac_address;
180    +}
181    +
182    +sub  trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
183    +
184    +sub get_mac_address_by_ping {
185    +    my ($ip) = trim(@_);
186    +    # Ping the IP to ensure it's in the ARP table
187    +    my $ping_result = `ping -c 1 -W 1 $ip`;
188    +    #return $ping_result;
189    +    if($ping_result =~ m/1 packets transmitted, 1 received/) {
190    +        # Fetch the ARP table and find the line with the IP address
191    +        my $mac_result = `nmap -PR -sn $ip`;
192    +        #return "*$arp_result *$ip*";
193    +        # If found, return the MAC address
194    +        #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) {
195    +               if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) {
196    +            return $1;
197    +        } else { return "mac not in nmap result";}
198    +    } else { return "no ping";}
199    +    return undef;
200    +}
201    +
202    +
203    +
204  +sub Scan_Local_Network ($) {            +sub Scan_Local_Network ($) {          
205  +      +  
206  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
207  +        my $mask = $nmap_sme->get_value('LocalNetmask');  +        my $mask = $nmap_sme->get_value('LocalNetmask');
208  +        my $network = $nmap_sme->get_prop('InternalInterface','Network');  +        my $network = $nmap_sme->get_prop('InternalInterface','Network');
# Line 177  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 217  diff -urN smeserver-dhcpmanager-2.0.4.ol
217  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;
218  +        +      
219  +    my @extracted_output;  +    my @extracted_output;
220    +    my $leasefile = "/var/lib/dhcpd/dhcpd.leases";
221  +    foreach my $line (@nmap_output) {  +    foreach my $line (@nmap_output) {
222  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {
223  +            my %pair = ('Network' => $1, 'ip' => $2);  # $1 => PC Name, $2 => IP Address  +                       my $ip = $2;
224  +            push @extracted_output, \%pair;  +                       my $mac = get_mac_address($ip,$leasefile);
225  +        }  +                       if (!$mac){
226    +                               $mac = get_mac_address_by_ping($ip);
227    +                       }
228    +#                      if (!$mac) {$mac = "unknown";}
229    +                       my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac);  # $1 => PC Name, $2 => IP Address
230    +                       push @extracted_output, \%pair;
231    +       }
232  +    }  +    }
233  +    return \@extracted_output;  +    return \@extracted_output;
234  +}  +}
# Line 191  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 238  diff -urN smeserver-dhcpmanager-2.0.4.ol
238   #=========================================================================   #=========================================================================
239   # Procedure qui charge le dhcpd.conf   # Procedure qui charge le dhcpd.conf
240   # retourne un tableau contenant les informations   # retourne un tableau contenant les informations
241  @@ -536,4 +649,4 @@  @@ -536,4 +699,4 @@
242    
243   1;   1;
244    
# Line 313  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 360  diff -urN smeserver-dhcpmanager-2.0.4.ol
360  +1;  +1;
361  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep
362  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep      2023-12-19 09:44:56.680590493 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep      2023-12-19 09:44:56.680590493 +0000
363  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep  2024-01-20 13:44:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep  2024-01-20 17:01:00.000000000 +0000
364  @@ -49,24 +49,26 @@  @@ -49,24 +49,26 @@
365    
366          % if ($dhcp_data->{trt} eq 'LEASES') {          % if ($dhcp_data->{trt} eq 'LEASES') {
# Line 345  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 392  diff -urN smeserver-dhcpmanager-2.0.4.ol
392  +                                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  +                                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
393  +                               </button>  +                               </button>
394  +                       </td><td>        +                       </td><td>      
395  +                               %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3, onclick=>"showSpinnerNetwork()", id=>"scanNetwork'  +                               %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork"
396  +                               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadingNetwork" style="display:true">  +                               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadingNetwork" style="display:true">
397  +                                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->  +                                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
398  +                                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  +                                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
# Line 456  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 503  diff -urN smeserver-dhcpmanager-2.0.4.ol
503  +</div>  +</div>
504  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep
505  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100
506  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 11:34:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 17:30:00.000000000 +0000
507  @@ -0,0 +1,49 @@  @@ -0,0 +1,63 @@
508  +<div id='dhcpd-scan'>  +<div id='dhcpd-scan'>
509  +       <table><tr><td>  +       <table><tr><td>
510  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork"  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
511  +       <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadingNetwork" style="display:true">  +       <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadingNetwork1" style="display:true">
512  +         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->  +         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
513  +         <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  +         <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
514  +       </button>  +       </button>
# Line 478  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 525  diff -urN smeserver-dhcpmanager-2.0.4.ol
525  +                       <th class='sme-border'>  +                       <th class='sme-border'>
526  +                               %=l 'dhcpd_IP'  +                               %=l 'dhcpd_IP'
527  +                       </th>  +                       </th>
528    +                       <th class='sme-border'>
529    +                               %=l 'dhcpd_MAC_ADDRESS'
530    +                       </th>
531    +
532  +               </tr>  +               </tr>
533  +               </thead>  +               </thead>
534  +               <tbody>  +               <tbody>
# Line 485  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 536  diff -urN smeserver-dhcpmanager-2.0.4.ol
536  +        <tr>  +        <tr>
537  +                       %= t td => (class => 'sme-border') => $ip->{Network}  +                       %= t td => (class => 'sme-border') => $ip->{Network}
538  +                       %= t td => (class => 'sme-border') => $ip->{ip}  +                       %= t td => (class => 'sme-border') => $ip->{ip}
539    +                       %= t td => (class => 'sme-border') => $ip->{mac}
540  +               </tr>  +               </tr>
541  +               %}  +               %}
542  +               </tbody>  +               </tbody>
# Line 507  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 559  diff -urN smeserver-dhcpmanager-2.0.4.ol
559  +  +
560  +  +
561  +</div>  +</div>
562    +%= javascript begin
563    +       document.getElementById("loadingNetwork1").style.display="none";
564    +  
565    +       function showSpinnerNetwork1(){
566    +         document.getElementById("scanNetwork1").style.display="none";
567    +         document.getElementById("loadingNetwork1").style.display="inline";
568    +       }
569    +
570    +%end


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed