Пример #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $option = new DhcpOption();
     $option->default_lease_time = '3600';
     $option->max_lease_time = '3600';
     $option->dns_1 = '8.8.8.8';
     $option->dns_2 = '8.8.4.4';
     $option->save();
 }
 public function rewriteDhcpConfig()
 {
     $date = date('Y-m-d-H-i-s');
     $fileToStore = 'dhcp/dhcpd.conf';
     $backupFile = 'dhcp/backups/dhcpd.conf-' . $date;
     Storage::copy($fileToStore, $backupFile);
     $globalOptions = DhcpOption::first();
     $sharedNetworks = DhcpSharedNetwork::with('subnets')->get();
     $template = view()->file(app_path('../resources/views/dhcp/templates/dhcpd-body.blade.php'))->with('dhcpOptions', $globalOptions)->with('sharedNetworks', $sharedNetworks);
     Storage::put($fileToStore, $template);
     logThis('dhcpd.conf rewritten, backup written to ' . $backupFile);
 }
Пример #3
0
 /**
  * The Construct
  */
 public function __construct($ipaddress, $cidr, $gateway_setting = 'top')
 {
     $this->ipaddress = $ipaddress;
     $this->cidr = $cidr;
     $this->gateway_setting = $gateway_setting;
     $this->net_addr = IP\NetworkAddress::factory($this->ipaddress, $this->cidr);
     $dhcp = DhcpOption::first();
     $this->default_lease_time = $dhcp->default_lease_time;
     $this->max_lease_time = $dhcp->max_lease_time;
     $this->dns_1 = $dhcp->dns_1;
     $this->dns_2 = $dhcp->dns_2;
     $this->dns_3 = $dhcp->dns_3;
     $this->dns_4 = $dhcp->dns_4;
 }
Пример #4
0
 public function getDhcpFile()
 {
     if (Cache::has('dhcpfile')) {
         return (new Response(Cache::get('dhcpfile'), 200))->header('Content-Type', 'text/plain');
     }
     $globals = DhcpOption::globals()->get();
     $networks = DhcpSharedNetwork::all();
     $subnets = DhcpSubnet::notInSharedNetwork()->get();
     $entries = DhcpEntry::all();
     $dhcpFile = new DhcpFile($globals, $networks, $subnets, $entries);
     $contents = Cache::rememberForever('dhcpfile', function () use($dhcpFile) {
         return $dhcpFile->asText();
     });
     return (new Response($contents, 200))->header('Content-Type', 'text/plain');
 }
Пример #5
0
 public function update(Request $request, $subnetId = null)
 {
     if (!$request->has('ids')) {
         return redirect()->action('DhcpOptionsController@edit');
     }
     foreach ($request->ids as $index => $id) {
         $option = new DhcpOption();
         $option->subnet_id = $request->subnet_id;
         if ($id) {
             $option = DhcpOption::findOrFail($id);
         }
         $option->optional = $request->optionals[$index];
         $option->name = $request->names[$index];
         $option->value = $request->values[$index];
         if (!($option->optional or $option->name or $option->value) and $option->id) {
             $option->delete();
         } else {
             if ($option->id or $option->name) {
                 $option->save();
             }
         }
     }
     return redirect()->action('DhcpOptionController@edit', $subnetId)->with('success_message', 'Updated!');
 }
Пример #6
0
 /**
  * Update the DHCP Global Options
  */
 public function update(DhcpOptionRequest $request, DhcpOption $dhcpoption)
 {
     $dhcpoption->update($request->all());
     $this->dispatch(new RewriteDhcpConfig());
     return $dhcpoption;
 }