Skip to content

Commit

Permalink
improve get ip
Browse files Browse the repository at this point in the history
  • Loading branch information
zoic21 authored Oct 24, 2024
1 parent 5d58547 commit af1bd22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/class/dyndns.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ class dyndns extends eqLogic {

public static function getExternalIP() {
$url = config::byKey('service::cloud::url').'/service/myip';
$request_http = new com_http($url);
$request_http->setHeader(array('Content-Type: application/json','Autorization: '.sha512(mb_strtolower(config::byKey('market::username')).':'.config::byKey('market::password'))));
$data = $request_http->exec(30,3);
$request_http = new com_http($url);
$request_http->setHeader(array('Content-Type: application/json','Autorization: '.sha512(mb_strtolower(config::byKey('market::username')).':'.config::byKey('market::password'))));
$data = $request_http->exec(120,6);
$result = is_json($data, $data);
if(isset($result['state']) && $result['state'] != 'ok'){
sleep(3);
$data = $request_http->exec(30,3);
sleep(10);
$data = $request_http->exec(120,6);
}
if(isset($result['state']) && $result['state'] != 'ok'){
sleep(30);
$data = $request_http->exec(120,6);
}
$result = is_json($data, $data);
if(isset($result['state']) && $result['state'] != 'ok'){
throw new \Exception(__('Erreur lors de la requête au serveur cloud Jeedom : ',__FILE__).$data);
return;
}
if(isset($result['data']) && isset($result['data']['ip'])){
//log::add('dyndns','debug','getExternalIP result: ' . $result['data']['ip']);
return $result['data']['ip'];
}
throw new \Exception(__('impossible de récupérer votre IP externe : ',__FILE__).$data);
Expand Down
4 changes: 4 additions & 0 deletions docs/fr_FR/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
>
>Pour rappel s'il n'y a pas d'information sur la mise à jour, c'est que celle-ci concerne uniquement de la mise à jour de documentation, de traduction ou de texte
# 24/10/2024

- Optimisation de la récuperation de l'ip

# 31/05/2024

- Optimisation de la récuperation de l'ip
Expand Down

0 comments on commit af1bd22

Please sign in to comment.