protected function execute(InputInterface $input, OutputInterface $output) { $this->updateVars(); $edgemode = \FreePBX::Config()->get('MODULEADMINEDGE'); $alerts = \FreePBX::Notifications()->get_num_active(); $output->write(base64_decode($this->banner)); $output->writeln(""); $output->writeln(""); if ($alerts != 0) { $output->writeln("<fg=red>" . sprintf(_("NOTICE! You have %s notifications! Please log into the UI to see them!"), $alerts) . "</fg=red>"); } if ($edgemode == 1) { $output->writeln("<fg=red>" . sprintf(_("NOTICE! This system had EDGE mode enabled. For more information visit %s"), 'http://wiki.freepbx.org/x/boi3Aw') . "</fg=red>"); } $output->writeln(""); $output->writeln("<info>" . _("Current Network Configuration") . "</info>"); $iflist = $this->listIFS(); if ($iflist) { $rows = array(); foreach ($iflist as $if => $info) { $rows[] = array($if, $info['mac'], $info['ip']); } $table = new Table($output); $table->setHeaders(array(_('Interface'), _('MAC Address'), _('IP Addresses')))->setRows($rows); $table->render(); } else { $output->writeln("-------------------"); $output->writeln(_("No interfaces found")); $output->writeln("-------------------"); } $messages = $this->externalMessages(); if (isset($messages['pre'])) { foreach ($messages['pre'] as $o) { $output->writeln($o); } } if (!$messages['cancel']) { $output->writeln(""); $output->writeln(_("Please note most tasks should be handled through the GUI.")); $output->writeln(_("You can access the GUI by typing one of the above IPs in to your web browser.")); $output->writeln(_("For support please visit: ")); $output->writeln(" " . $this->supporturl); $output->writeln(""); } if (isset($messages['post'])) { foreach ($messages['post'] as $o) { $output->writeln($o); } } }
/** * Make sure that none of the SIP channel drivers have conflicting ports * * This will give priority to PJSIP owning the ports. */ public function validateNoPortConflicts() { // Get all of our binds $binds = $this->getBinds(true); $allports = array("tcp" => array(), "udp" => array()); foreach ($binds as $driver => $listenarr) { // We explicitly don't care about interfaces. Having // chansip on 5060 on int1 and pjsip on 5060 on int2 // is just going to be a nightmare. We asked getBinds // to return a flattened array, so we just disregard // the interface foreach ($listenarr as $ports) { foreach ($ports as $proto => $port) { // Phew. Finally. // Is it a websocket port? We don't care about them if ($proto == "wss" || $proto == "ws") { continue; } // Is it a TCP port? if ($proto !== "udp") { $type = "tcp"; } else { $type = "udp"; } // Is there a conflict? if (isset($allports[$type][$port])) { // Yes. Poot. $n = \FreePBX::Notifications(); // If this isn't chansip, then somehow the user has managed // to do something crazy to pjsip. We can't fix it. if ($driver !== "sip") { $n->add_critical("sipsettings", "unknownpjsip", _("Unknown Port Conflict"), _("An unknown port conflict has been detected in PJSIP. Please check and validate your PJSIP Ports to ensure they're not overlapping"), "", true, true); continue; } // So, is this udp, tcp, or tls? if ($proto == "udp") { // Try a couple of ports until we find a spare. Default is first, // just in case we have a conflict on 5061 or something. $attempts = array(5060, 5062, 5161, 5199, 5260, 15060); foreach ($attempts as $portattempt) { if (!isset($allports['udp'][$portattempt])) { // Yes. Found a spare. $this->updateChanSipSettings("bindport", $portattempt); $allports['udp'][$portattempt] = true; $n->add_critical("sipsettings", "sipmoved", _("CHANSIP Port Moved"), sprintf(_("Chansip was assigned the same port as pjsip for UDP traffic. The Chansip port has been changed to %s"), $portattempt), "", true, true); needreload(); break; } } } elseif ($proto == "tcp") { // This means pjsip is listening on TCP, and, someone's turned on tcpenable // in chansip settings. We just turn it off, as chansip can't move its tcp // port. $this->updateChanSipSettings("tcpenable"); $n->add_critical("sipsettings", "siptcpdisabled", _("CHANSIP TCP Disabled"), _("Chansip was assigned the same port as pjsip for TCP traffic. Chansip has had the tcpenable setting removed, and is no longer listening for TCP connections."), true, true); needreload(); continue; } elseif ($proto == "tls") { // TLS is conflicting with PJSIP. Try to find a spare port $attempts = array(5061, 5161, 5162, 5199, 5261, 15061); foreach ($attempts as $portattempt) { if (!isset($allports['tcp'][$portattempt])) { // Yes. Found a spare. $this->updateChanSipSettings("tlsbindport", $portattempt); $allports['tcp'][$portattempt] = true; $n->add_critical("sipsettings", "siptlsmoved", _("CHANSIP TLS Port Moved"), sprintf(_("Chansip was assigned a port that was already in use for TLS traffic. The Chansip TLS port has been changed to %s"), $portattempt), true, true); needreload(); break; } } } else { throw new \Exception("Unknown protocol ({$proto}) to fix"); } } // No conflict! $allports[$type][$port] = true; // Debugging help // $allports[$type][$port] = "$driver, $proto on port $port ($type)"; } } } }
protected function configure() { $this->FreePBXConf = \FreePBX::Config(); $this->Notifications = \FreePBX::Notifications(); $this->setName('dbug')->setAliases(array('debug'))->setDescription(_('Stream files for debugging'))->setDefinition(array(new InputArgument('args', InputArgument::IS_ARRAY, null, null), new InputOption('skipstandard', 's', InputOption::VALUE_NONE, _('Do not tail standard freepbx.log')))); }