public static function postJsonRpc(&$_result) { if (is_array($_result)) { if (config::byKey('market::allowDNS') == 1) { $dnsRestart = false; if (isset($_result['register::ngrokAddr']) && config::byKey('ngrok::addr') != $_result['register::ngrokAddr']) { config::save('ngrok::addr', $_result['register::ngrokAddr']); $dnsRestart = true; } if (isset($_result['register::ngrokToken']) && config::byKey('ngrok::token') != $_result['register::ngrokToken']) { config::save('ngrok::token', $_result['register::ngrokToken']); $dnsRestart = true; } if ($dnsRestart) { if (network::dns_run()) { network::dns_stop(); } network::dns_start(); } if (isset($_result['jeedom::url']) && config::byKey('jeedom::url') != $_result['jeedom::url']) { config::save('jeedom::url', $_result['jeedom::url']); } } if (isset($_result['register::ngrokAddr'])) { unset($_result['register::ngrokAddr']); } if (isset($_result['register::ngrokPort'])) { unset($_result['register::ngrokPort']); } if (isset($_result['register::ngrokToken'])) { unset($_result['register::ngrokToken']); } if (isset($_result['jeedom::url'])) { unset($_result['jeedom::url']); } if (isset($_result['register::hwkey_nok']) && $_result['register::hwkey_nok'] == 1) { config::save('jeedom::installKey', ''); } } }
public static function cron() { if (config::byKey('market::allowDNS') == 1 && !network::test('external', false, 120)) { network::dns_start(); } if (config::byKey('network::disableMangement') == 1) { return; } if (!jeedom::isCapable('sudo')) { return; } try { $gws = self::checkGw(); if (count($gws) == 0) { log::add('network', 'error', __('Aucune interface réseau trouvée, je redemarre tous les réseaux', __FILE__)); exec('sudo service networking restart'); return; } foreach ($gws as $iface => $gw) { if ($gw['ping'] != 'ok') { if (strpos($iface, 'tun') !== false) { continue; } if (strpos($iface, 'br0') !== false) { continue; } log::add('network', 'error', __('La passerelle distante de l\'interface ', __FILE__) . $iface . __(' est injoignable, je la redemarre pour essayer de corriger', __FILE__)); exec('sudo ifdown ' . $iface); sleep(5); exec('sudo ifup --force ' . $iface); } } } catch (Exception $e) { } }
} if ($jsonrpc->getMethod() == 'update::update') { jeedom::update('', 0); $jsonrpc->makeSuccess('ok'); } if ($jsonrpc->getMethod() == 'update::checkUpdate') { update::checkAllUpdate(); $jsonrpc->makeSuccess('ok'); } /* * ************************Network*************************** */ if ($jsonrpc->getMethod() == 'network::restartNgrok') { config::save('market::allowDNS', 1); if (network::dns_run()) { network::dns_stop(); } network::dns_start(); $jsonrpc->makeSuccess(); } if ($jsonrpc->getMethod() == 'network::stopNgrok') { config::save('market::allowDNS', 0); network::dns_stop(); $jsonrpc->makeSuccess(); } if ($jsonrpc->getMethod() == 'network::ngrokRun') { if (!isset($params['proto'])) { $params['proto'] = 'https'; } if (!isset($params['port'])) { $params['port'] = 80; } if (!isset($params['name'])) {