Skip to content

Commit

Permalink
more providers
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Nov 21, 2024
1 parent b9b52a1 commit 4b9d499
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)

## [3.1.0](https://github.com/homebridge-plugins/homebridge-noip/releases/tag/v3.1.0) (2024-11-04)

### What's Changes
- Added ipv6 support [#161](https://github.com/homebridge-plugins/homebridge-noip/pull/161), Thanks [@v0lume](https://github.com/v0lume)
- Added support for other ip providers
- `ipify.org`, `ipinfo.io`, `ipapi.co`, `my-ip.io`, and `getmyip.dev`
- Housekeeping and updated dependencies.

**Full Changelog**: https://github.com/homebridge-plugins/homebridge-noip/compare/v3.0.6...v3.1.0

## [3.0.6](https://github.com/homebridge-plugins/homebridge-noip/releases/tag/v3.0.6) (2024-11-04)

### What's Changes
Expand Down
18 changes: 13 additions & 5 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,27 @@
"title": "IP Provider",
"type": "string",
"required": true,
"default": "default",
"default": "ipinfo",
"oneOf": [
{
"title": "ipify.org",
"enum": ["ipify"]
},
{
"title": "ipinfo.io",
"enum": ["ipinfo"]
},
{
"title": "getmyip.dev",
"enum": ["getmyip"]
},
{
"title": "ipapi.co",
"enum": ["ipapi"]
},
{
"title": "my-ip.io",
"enum": ["myip"]
},
{
"title": "ipinfo.io",
"enum": ["ipinfo"]
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion src/devices/contactsensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ContactSensor extends deviceBase {
try {
const ip = this.device.ipv4or6 === 'ipv6' ? await this.platform.publicIPv6(this.device) : await this.platform.publicIPv4(this.device)
const ipv4or6 = this.device.ipv4or6 === 'ipv6' ? 'IPv6' : 'IPv4'
const ipProvider = this.device.ipProvider === 'ipify' ? 'ipify.org' : this.device.ipProvider === 'getmyip' ? 'getmyip.dev' : 'ipinfo.io'
const ipProvider = this.device.ipProvider === 'ipify' ? 'ipify.org' : this.device.ipProvider === 'getmyip' ? 'getmyip.dev' : this.device.ipProvider === 'ipapi' ? 'ipapi.co' : this.device.ipProvider === 'myip' ? 'my-ip.io' : 'ipinfo.io'
const { body, statusCode } = await request(noip, {
method: 'GET',
query: {
Expand Down
6 changes: 3 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { request } from 'undici'
import validator from 'validator'

import { ContactSensor } from './devices/contactsensor.js'
import { getmyip_v4, getmyip_v6, ipify_v4, ipify_v6, ipinfo_v4, ipinfo_v6, PLATFORM_NAME, PLUGIN_NAME } from './settings.js'
import { getmyip_v4, getmyip_v6, ipapi_v4, ipapi_v6, ipify_v4, ipify_v6, ipinfo_v4, ipinfo_v6, myip_v4, myip_v6, PLATFORM_NAME, PLUGIN_NAME } from './settings.js'

/**
* HomebridgePlatform
Expand Down Expand Up @@ -223,7 +223,7 @@ export class NoIPPlatform implements DynamicPlatformPlugin {

async publicIPv4(device: devicesConfig) {
try {
const { body, statusCode } = await request(device.ipProvider === 'ipify' ? ipify_v4 : device.ipProvider === 'getmyip' ? getmyip_v4 : ipinfo_v4, {
const { body, statusCode } = await request(device.ipProvider === 'ipify' ? ipify_v4 : device.ipProvider === 'getmyip' ? getmyip_v4 : device.ipProvider === 'ipapi' ? ipapi_v4 : device.ipProvider === 'myip' ? myip_v4 : ipinfo_v4, {
method: 'GET',
})
const pubIp: any = await body.json()
Expand All @@ -238,7 +238,7 @@ export class NoIPPlatform implements DynamicPlatformPlugin {

async publicIPv6(device: devicesConfig) {
try {
const { body, statusCode } = await request(device.ipProvider === 'ipify' ? ipify_v6 : device.ipProvider === 'getmyip' ? getmyip_v6 : ipinfo_v6, {
const { body, statusCode } = await request(device.ipProvider === 'ipify' ? ipify_v6 : device.ipProvider === 'getmyip' ? getmyip_v6 : device.ipProvider === 'ipapi' ? ipapi_v6 : device.ipProvider === 'myip' ? myip_v6 : ipinfo_v6, {
method: 'GET',
})
const pubIp: any = await body.json()
Expand Down
4 changes: 4 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ export const PLUGIN_NAME = 'homebridge-noip'
export const ipinfo_v4 = 'https://ipinfo.io/json'
export const getmyip_v4 = 'https://ipv4.getmyip.dev'
export const ipify_v4 = 'https://api.ipify.org?format=json'
export const ipapi_v4 = 'https://ipapi.co/json'
export const myip_v4 = 'https://api4.my-ip.io/v2/ip.json'
export const ipinfo_v6 = 'https://v6.ipinfo.io/json'
export const getmyip_v6 = 'https://ipv6.getmyip.dev'
export const ipify_v6 = 'https://api64.ipify.org?format=json'
export const ipapi_v6 = 'https://ip6api.co/json'
export const myip_v6 = 'https://api6.my-ip.io/v2/ip.txt'
export const noip = 'https://dynupdate.no-ip.com/nic/update'

// Config
Expand Down

0 comments on commit 4b9d499

Please sign in to comment.