diff --git a/CloudFlare/cloudflare_ddns.ps1 b/CloudFlare/cloudflare_ddns.ps1 index d6ffbd3..d9fdfbf 100644 --- a/CloudFlare/cloudflare_ddns.ps1 +++ b/CloudFlare/cloudflare_ddns.ps1 @@ -33,6 +33,8 @@ if (-not (Test-Path $path_sites)) { 'http://ifconfig.me/ip' 'http://icanhazip.com' 'http://ident.me' + 'https://api.ipify.org' + 'https://ip2location.io/ip' ) } else { [array]$ip_sites = Get-Content $path_sites @@ -82,43 +84,65 @@ function get-ip { $ip = (Invoke-RestMethod -Uri $uri -Method Get).Trim() } catch { - $global:logs += log -l_level 1 -l_message "IP: ERROR | URL: $($uri)" + $global:logs += log -l_level 1 -l_message "IP: $($Error[0].Exception) | URL: $($uri)" continue } } 'http://ifconfig.me/ip' { $uri = $ip_sites[$i] try { - $test = Test-Connection -TargetName $uri.Replace("http://","").Split("/")[0] -Count 2 + $test = Test-Connection -TargetName $uri.Replace("http://","").Split("/")[0] -Count 1 $ip = (Invoke-RestMethod -Uri $uri -Method Get).Trim() } catch { - $global:logs += log -l_level 1 -l_message "IP: ERROR | URL: $($uri)" + $global:logs += log -l_level 1 -l_message "IP: $($Error[0].Exception) | URL: $($uri)" continue } } 'http://icanhazip.com' { $uri = $ip_sites[$i] try { - $test = Test-Connection -TargetName $uri.Replace("http://","").Split("/")[0] -Count 2 + $test = Test-Connection -TargetName $uri.Replace("http://","").Split("/")[0] -Count 1 $ip = (Invoke-RestMethod -Uri $uri -Method Get).Trim() } catch { - $global:logs += log -l_level 1 -l_message "IP: ERROR | URL: $($uri)" + $global:logs += log -l_level 1 -l_message "IP: $($Error[0].Exception) | URL: $($uri)" continue } } 'http://ident.me' { $uri = $ip_sites[$i] try { - $test = Test-Connection -TargetName $uri.Replace("http://","").Split("/")[0] -Count 2 + $test = Test-Connection -TargetName $uri.Replace("http://","").Split("/")[0] -Count 1 + $ip = (Invoke-RestMethod -Uri $uri -Method Get).Trim() + } + catch { + $global:logs += log -l_level 1 -l_message "IP: $($Error[0].Exception) | URL: $($uri)" + continue + } + } + 'https://api.ipify.org' { + $uri = $ip_sites[$i] + try { + $test = Test-Connection -TargetName $uri.Replace("https://","").Split("/")[0] -Count 1 $ip = (Invoke-RestMethod -Uri $uri -Method Get).Trim() } catch { $global:logs += log -l_level 1 -l_message "IP: ERROR | URL: $($uri)" continue } - } + } + 'https://ip2location.io/ip' { + $uri = $ip_sites[$i] + try { + $test = Test-Connection -TargetName $uri.Replace("https://","").Split("/")[0] -Count 1 + $ip = (Invoke-RestMethod -Uri $uri -Method Get).Trim() + } + catch { + $global:logs += log -l_level 1 -l_message "IP: ERROR | URL: $($uri)" + continue + } + } } if ($null -ne $ip) { $global:logs += log -l_level 0 -l_message "IP: $($ip) | URL: $($uri)"