diff --git a/core/class/dyndns.class.php b/core/class/dyndns.class.php index 406a7c1..31ff120 100755 --- a/core/class/dyndns.class.php +++ b/core/class/dyndns.class.php @@ -254,16 +254,35 @@ public function updateIP() { } break; case 'gandinet': - $url = 'https://dns.api.gandi.net/api/v5/domains/' . $this->getConfiguration('domainname') . '/records/' . $this->getConfiguration('hostname') .'/A'; - $payload = array('rrset_type'=>'A','rrset_ttl'=>'3600','rrset_name'=>$this->getConfiguration('hostname'),'rrset_values'=>array($ip)); + $url = 'https://api.gandi.net/v5/livedns/domains/' . $this->getConfiguration('domainname') . '/records/' . $this->getConfiguration('hostname') .'/A'; + $payload = array( + 'rrset_type'=>'A', + 'rrset_ttl'=>'3600', + 'rrset_name'=>$this->getConfiguration('hostname'), + 'rrset_values'=>array($ip) + ); $payload_json = json_encode($payload); $request_http = new com_http($url); $request_http->setUserAgent('Jeedom dyndns plugin'); - $request_http->setHeader(array('Content-Type: application/json', 'Content-Length: ' . strlen($payload_json), 'X-API-Key:' . $this->getConfiguration('token'))); + // Manage compatibility with old version of the plugin where the auth-method was apikey by default + if ($this->getConfiguration('auth-method') == ""){ + $authMethod = "apikey"; + } else { + $authMethod = $this->getConfiguration('auth-method'); + } + if ($authMethod == "apikey"){ + $request_http->setHeader(array('Content-Type: application/json', 'Content-Length: ' . strlen($payload_json), 'Authorization: Apikey ' . $this->getConfiguration('token'))); + } + if ($authMethod == "pat"){ + $request_http->setHeader(array('Content-Type: application/json', 'Content-Length: ' . strlen($payload_json), 'Authorization: Bearer ' . $this->getConfiguration('token'))); + } $request_http->setPut($payload_json); $result = $request_http->exec(); - if (strpos($result, 'error') !== false) { - throw new Exception(__('Erreur de mise à jour de gandinet : ' . $url, __FILE__) . $result); + $status_code = $request_http->getHttpCode(); + if ($status_code !== 200 && $status_code !== 201) { + throw new Exception(__('Erreur de mise à jour de gandinet : ' . $url, __FILE__) . ' Response code: ' . $status_code . ' Result: ' . $result); + } else { + log::add('dyndns', 'debug', 'Gandi.net update success on: ' . $url ); } break; case 'infomaniak': diff --git a/core/i18n/de_DE.json b/core/i18n/de_DE.json index 74ff30b..eaf81c9 100644 --- a/core/i18n/de_DE.json +++ b/core/i18n/de_DE.json @@ -28,6 +28,9 @@ "Domainname": "Domänenname", "Nom d'utilisateur": "Benutzername", "Mot de passe": "Passwort", + "Méthode d'authentification": "Authentifizierungsmethode", + "API Key": "API key", + "Personal Access Token (PAT)": "Persönlicher Zugriffstoken (PAT)", "Token": "Zeichen", "IPv6": "IPv6", "Nom": "Name", diff --git a/core/i18n/en_US.json b/core/i18n/en_US.json index bf62fe8..23a89f2 100644 --- a/core/i18n/en_US.json +++ b/core/i18n/en_US.json @@ -28,6 +28,9 @@ "Domainname": "Domain name", "Nom d'utilisateur": "Username", "Mot de passe": "Password", + "Méthode d'authentification": "Authentication method", + "API Key": "API key", + "Personal Access Token (PAT)": "Personal Access Token (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "Name", diff --git a/core/i18n/es_ES.json b/core/i18n/es_ES.json index f76b357..8ee904d 100644 --- a/core/i18n/es_ES.json +++ b/core/i18n/es_ES.json @@ -28,6 +28,9 @@ "Domainname": "Nombre de dominio", "Nom d'utilisateur": "Nombre de usuario", "Mot de passe": "Contraseña", + "Méthode d'authentification": "Método de autenticación", + "API Key": "API key", + "Personal Access Token (PAT)": "Token de acceso personal (PAT)", "Token": "Simbólico", "IPv6": "IPv6", "Nom": "Nombre", diff --git a/core/i18n/fr_FR.json b/core/i18n/fr_FR.json index 9882375..9de92b4 100644 --- a/core/i18n/fr_FR.json +++ b/core/i18n/fr_FR.json @@ -28,6 +28,9 @@ "Domainname": "Domainname", "Nom d'utilisateur": "Nom d'utilisateur", "Mot de passe": "Mot de passe", + "Méthode d'authentification": "Méthode d'authentification", + "API Key": "API key", + "Personal Access Token (PAT)": "Personal Access Token (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "Nom", diff --git a/core/i18n/id_ID.json b/core/i18n/id_ID.json index 9676346..6ddc752 100644 --- a/core/i18n/id_ID.json +++ b/core/i18n/id_ID.json @@ -28,6 +28,9 @@ "Domainname": "Domainname", "Nom d'utilisateur": "Nama pemakai", "Mot de passe": "Password", + "Méthode d'authentification": "Metode autentikasi", + "API Key": "API key", + "Personal Access Token (PAT)": "Token akses pribadi (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "Nama", diff --git a/core/i18n/it_IT.json b/core/i18n/it_IT.json index 29690b9..f88f222 100644 --- a/core/i18n/it_IT.json +++ b/core/i18n/it_IT.json @@ -28,6 +28,9 @@ "Domainname": "Domainname", "Nom d'utilisateur": "Nome utente", "Mot de passe": "Password", + "Méthode d'authentification": "Metodo di autenticazionen", + "API Key": "API key", + "Personal Access Token (PAT)": "Token di accesso personale (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "Nome", diff --git a/core/i18n/ja_JP.json b/core/i18n/ja_JP.json index b29d9ad..4ed73b7 100644 --- a/core/i18n/ja_JP.json +++ b/core/i18n/ja_JP.json @@ -28,6 +28,9 @@ "Domainname": "Domainname", "Nom d'utilisateur": "ユーザー名", "Mot de passe": "パスワード", + "Méthode d'authentification": "認証方法", + "API Key": "API key", + "Personal Access Token (PAT)": "個人アクセストークン (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "表題", diff --git a/core/i18n/pt_PT.json b/core/i18n/pt_PT.json index f322561..ea63a76 100644 --- a/core/i18n/pt_PT.json +++ b/core/i18n/pt_PT.json @@ -28,6 +28,9 @@ "Domainname": "Nome do domínio", "Nom d'utilisateur": "Nome de Usuário", "Mot de passe": "Senha", + "Méthode d'authentification": "Método de autenticação", + "API Key": "API key", + "Personal Access Token (PAT)": "Token de acesso pessoal (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "Nome", diff --git a/core/i18n/ru_RU.json b/core/i18n/ru_RU.json index 69f165e..260c780 100644 --- a/core/i18n/ru_RU.json +++ b/core/i18n/ru_RU.json @@ -28,6 +28,9 @@ "Domainname": "Domainname", "Nom d'utilisateur": "Имя пользователя", "Mot de passe": "Пароль", + "Méthode d'authentification": "Метод аутентификации", + "API Key": "API key", + "Personal Access Token (PAT)": "Персональный токен доступа (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "Имя", diff --git a/core/i18n/tr.json b/core/i18n/tr.json index ec54671..c9bfc77 100644 --- a/core/i18n/tr.json +++ b/core/i18n/tr.json @@ -28,6 +28,9 @@ "Domainname": "Domainname", "Nom d'utilisateur": "Kullanıcı adı", "Mot de passe": "Şifre", + "Méthode d'authentification": "Kimlik doğrulama yöntemi", + "API Key": "API key", + "Personal Access Token (PAT)": "Kişisel erişim anahtarı (PAT)", "Token": "Token", "IPv6": "IPv6", "Nom": "İsim", diff --git a/desktop/php/dyndns.php b/desktop/php/dyndns.php index 509cfc6..7cc825d 100755 --- a/desktop/php/dyndns.php +++ b/desktop/php/dyndns.php @@ -149,6 +149,15 @@ +