/[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.6 by brianr, Sun Jan 21 16:59:03 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-21 16:53: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,167 @@
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    +    if($ping_result =~ /1 packets transmitted, 1 received/) {
189    +        # Fetch the ARP table and find the line with the IP address
190    +        my $arp_result = `arp -an | grep "\($ip)"`;
191    +        # If found, return the MAC address
192    +        return $arp_result;
193    +        if ($arp_result =~ /.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) {
194    +            return $1;
195    +        } else { return "not in arp table"}
196    +    } else { return "no ping"}
197    +    return undef;
198    +}
199    +
200    +
201    +
202  +sub Scan_Local_Network ($) {            +sub Scan_Local_Network ($) {          
203  +      +  
204  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
205  +        my $mask = $nmap_sme->get_value('LocalNetmask');  +        my $mask = $nmap_sme->get_value('LocalNetmask');
206  +        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 215  diff -urN smeserver-dhcpmanager-2.0.4.ol
215  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;
216  +        +      
217  +    my @extracted_output;  +    my @extracted_output;
218    +    my $leasefile = "/var/lib/dhcpd/dhcpd.leases";
219  +    foreach my $line (@nmap_output) {  +    foreach my $line (@nmap_output) {
220  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {
221  +            my %pair = ('Network' => $1, 'ip' => $2);  # $1 => PC Name, $2 => IP Address  +                       my $ip = $2;
222  +            push @extracted_output, \%pair;  +                       my $mac = get_mac_address($ip,$leasefile);
223  +        }  +                       if (!$mac){
224    +                               $mac = get_mac_address_by_ping($ip);
225    +                       }
226    +                       if (!$mac) {$mac = "unknown";}
227    +                       my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac);  # $1 => PC Name, $2 => IP Address
228    +                       push @extracted_output, \%pair;
229    +       }
230  +    }  +    }
231  +    return \@extracted_output;  +    return \@extracted_output;
232  +}  +}
# Line 191  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 236  diff -urN smeserver-dhcpmanager-2.0.4.ol
236   #=========================================================================   #=========================================================================
237   # Procedure qui charge le dhcpd.conf   # Procedure qui charge le dhcpd.conf
238   # retourne un tableau contenant les informations   # retourne un tableau contenant les informations
239  @@ -536,4 +649,4 @@  @@ -536,4 +697,4 @@
240    
241   1;   1;
242    
# Line 313  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 358  diff -urN smeserver-dhcpmanager-2.0.4.ol
358  +1;  +1;
359  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
360  --- 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
361  +++ 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
362  @@ -49,24 +49,26 @@  @@ -49,24 +49,26 @@
363    
364          % if ($dhcp_data->{trt} eq 'LEASES') {          % if ($dhcp_data->{trt} eq 'LEASES') {
# Line 345  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 390  diff -urN smeserver-dhcpmanager-2.0.4.ol
390  +                                 <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>
391  +                               </button>  +                               </button>
392  +                       </td><td>        +                       </td><td>      
393  +                               %= 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"
394  +                               <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">
395  +                                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->  +                                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
396  +                                 <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 501  diff -urN smeserver-dhcpmanager-2.0.4.ol
501  +</div>  +</div>
502  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
503  --- 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
504  +++ 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
505  @@ -0,0 +1,49 @@  @@ -0,0 +1,63 @@
506  +<div id='dhcpd-scan'>  +<div id='dhcpd-scan'>
507  +       <table><tr><td>  +       <table><tr><td>
508  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork"  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
509  +       <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">
510  +         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->  +         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
511  +         <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>
512  +       </button>  +       </button>
# Line 478  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 523  diff -urN smeserver-dhcpmanager-2.0.4.ol
523  +                       <th class='sme-border'>  +                       <th class='sme-border'>
524  +                               %=l 'dhcpd_IP'  +                               %=l 'dhcpd_IP'
525  +                       </th>  +                       </th>
526    +                       <th class='sme-border'>
527    +                               %=l 'dhcpd_MAC_ADDRESS'
528    +                       </th>
529    +
530  +               </tr>  +               </tr>
531  +               </thead>  +               </thead>
532  +               <tbody>  +               <tbody>
# Line 485  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 534  diff -urN smeserver-dhcpmanager-2.0.4.ol
534  +        <tr>  +        <tr>
535  +                       %= t td => (class => 'sme-border') => $ip->{Network}  +                       %= t td => (class => 'sme-border') => $ip->{Network}
536  +                       %= t td => (class => 'sme-border') => $ip->{ip}  +                       %= t td => (class => 'sme-border') => $ip->{ip}
537    +                       %= t td => (class => 'sme-border') => $ip->{mac}
538  +               </tr>  +               </tr>
539  +               %}  +               %}
540  +               </tbody>  +               </tbody>
# Line 507  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 557  diff -urN smeserver-dhcpmanager-2.0.4.ol
557  +  +
558  +  +
559  +</div>  +</div>
560    +%= javascript begin
561    +       document.getElementById("loadingNetwork1").style.display="none";
562    +  
563    +       function showSpinnerNetwork1(){
564    +         document.getElementById("scanNetwork1").style.display="none";
565    +         document.getElementById("loadingNetwork1").style.display="inline";
566    +       }
567    +
568    +%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