π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π Fixes depricated IP providers for IP widget (#1735, #1414, #437)
Alicia Sykesf10a3343baa4
diff --git a/docs/privacy.md b/docs/privacy.mdindex 5a2f56b1..44dad083 100644--- a/docs/privacy.md+++ b/docs/privacy.md@@ -176,10 +176,11 @@ Dashy supports [Widgets](/docs/widgets.md) for displaying dynamic content. Below|---|---|---|| [Weather](/docs/widgets.md#weather) / [Weather Forecast](/docs/widgets.md#weather-forecast) | `https://api.openweathermap.org` | [OWM Privacy Policy](https://openweather.co.uk/privacy-policy) || [RSS Feed](/docs/widgets.md#rss-feed) | `https://api.rss2json.com/v1/api.json` | [Rss2Json Privacy Policy](https://rss2json.com/privacy-policy) |-| [IP Address](/docs/widgets.md#public-ip) | `https://ipapi.co/json` | [IP API Privacy Policy](https://ipapi.co/privacy/) |-| | `https://api.ipgeolocation.io/ipgeo` | [IPGeoLocation Privacy Policy](https://ipgeolocation.io/privacy.html) |+| [IP Address](/docs/widgets.md#public-ip) | `https://free.freeipapi.com/api/json` | [FreeIPAPI](https://freeipapi.com/) |+| | `https://ipinfo.io/json` | [IPInfo Privacy Policy](https://ipinfo.io/privacy-policy) |+| | `https://api.ipquery.io/` | [IPQuery](https://ipquery.io/) || | `http://ip-api.com/json` | [IP-API Privacy Policy](https://ip-api.com/docs/legal) |-| | `https://api.ip2location.io/` | [IP2Location.io Privacy Policy](https://ip2location.io/privacy-policy) |+| | `https://api.ipgeolocation.io/ipgeo` | [IPGeoLocation Privacy Policy](https://ipgeolocation.io/privacy.html) || [IP Blacklist](/docs/widgets.md#ip-blacklist) | `https://api.blacklistchecker.com` | [Blacklist Checker Privacy Policy](https://blacklistchecker.com/privacy) || [Domain Monitor](/docs/widgets.md#domain-monitor) | `https://api.whoapi.com` | [WhoAPI Privacy Policy](https://whoapi.com/privacy-policy/) || [Crypto Watch List](/docs/widgets.md#crypto-watch-list) / [Token Price History](/docs/widgets.md#crypto-token-price-history) | `https://api.coingecko.com` | [CoinGecko Privacy Policy](https://www.coingecko.com/en/privacy) |diff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex a0f7f0e7..170dcb39 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -630,6 +630,12 @@ Finally, be sure to remain respectful to other users and project maintainers, in---+## Public IP Widget not working for `ipinfo` or `ipquery` providers++If you've set `options.provider` to either `ipinfo` and `ipquery` and the requests are failing, it's likley that they're being blocked. Check your adblocker (uBlock, PrivacyBadger, etc), DNS block lists (PiHole, AdGuard, etc). Or, try proxying the request (with `useProxy: true`) or just try a different provider.++---+## How-To Open Browser ConsoleWhen raising a bug, one crucial piece of info needed is the browser's console output. This will help the developer diagnose and fix the issue.diff --git a/docs/widgets.md b/docs/widgets.mdindex c1fa7104..6957379e 100644--- a/docs/widgets.md+++ b/docs/widgets.md@@ -296,26 +296,35 @@ Unless image fetched from remote source, no external data request is made.### Public IP-Often find yourself searching "What's my IP", just so you can check your VPN is still connected? This widget displays your public IP address, along with ISP name and approx location. Data can be fetched from either [IpApi.co](https://ipapi.co/), [IP-API.com](https://ip-api.com/), [IpGeolocation.io](https://ipgeolocation.io/) or [IP2Location.io](https://ip2location.io/).+Displays your public IP address, ISP and approximate location.<p align="center"><img width="400" src="https://pixelflare.cc/alicia/dashy/public-ip" /></p>#### Options-_All fields are optional._-**Field** | **Type** | **Required** | **Description**--- | --- | --- | ----**`provider`** | `string` | _Optional_ | The name of the service to fetch IP address from. Can be either `ipapi.co`, `ip-api`, `ipgeolocation` or `ip2location.io`. Defaults to `ipapi.co`. Note, `ip-api` doesn't work on HTTPS, and if you set to `ipgeolocation` or `ip2location.io` then you must also provide an API key-**`apiKey`** | `string` | _Optional_ | Only required if provider is set to `ipgeolocation` or `ip2location.io`. You can get a free IPGeolocation API key [here](https://ipgeolocation.io/signup.html) or a free IP2Location.io API key [here](https://ip2location.io/pricing)+**`provider`** | `string` | _Optional_ | One of `freeipapi` _(default)_, `ipinfo`, `ipquery`, `ip-api`, or `ipgeolocation`. See the table below+**`apiKey`** | `string` | _Optional_ | Required for `ipgeolocation`. Optional for `ipinfo` (a [free token](https://ipinfo.io/signup) raises the rate limit from ~1k/day to ~50k/month)#### Example+Default (no options needed)+```yaml- type: public-ip```-Or+Using `ip-api` via the proxy (gets server IP, because of `useProxy`)++```yaml+- type: public-ip+ useProxy: true+ options:+ provider: ip-api+```++Using `ipgeolocation` with a key:```yaml- type: public-ip@@ -324,13 +333,27 @@ OrapiKey: xxxxxxxxxxxxxxx```+> [!TIP]+> Setting `useProxy: true` makes the lookup happen from Dashy's server instead of your browser, so the upstream API returns the public IP of the machine running Dashy, whereas without `useProxy` it will show your public IP.++#### Supported providers++**Provider** | **Key** | **Proxy** | **Notes**+--- | --- | --- | ---+`freeipapi` _(default)_ | π’ Not needed | π’ Not needed | Keyless, 60 req/min via [freeipapi.com](https://freeipapi.com/).+`ipinfo` | π’ Not needed / π Optional | π’ Not needed | Industry-standard service from [ipinfo.io](https://ipinfo.io/). Keyless gives ~1k/day; a [free token](https://ipinfo.io/signup) raises this to ~50k/month. Sometimes blocked by adblockers.+`ipquery` | π’ Not needed | π’ Not needed | Modern keyless API from [ipquery.io](https://ipquery.io/). Includes VPN/Tor/datacenter risk flags in the raw response.+`ip-api` | π’ Not needed | π΄ **Required** | [ip-api.com](https://ip-api.com/) is HTTP-only on the free tier, so the proxy is needed to avoid mixed-content errors.+`ipgeolocation` | π΄ **Required** | π’ Not needed | Get a free key from [ipgeolocation.io](https://ipgeolocation.io/signup.html).++#### Info-- **CORS**: π’ Enabled-- **Auth**: π Optional+- **CORS**: π’ Enabled (only `provider: ip-api` needs the proxy)+- **Auth**: π Optional (only `ipgeolocation` requires a key, and `ipinfo` is optional)- **Price**: π’ Free- **Host**: Managed Instance Only-- **Privacy**: _See [IPGeoLocation Privacy Policy](https://ipgeolocation.io/privacy.html) or [IP-API Privacy Policy](https://ip-api.com/docs/legal) or [IP2Location.io Privacy Policy](https://ip2location.io/privacy-policy)+- **Privacy**: See the policy for whichever provider you choose: [freeipapi.com](https://freeipapi.com/), [ipinfo.io](https://ipinfo.io/privacy-policy), [ipquery.io](https://ipquery.io/), [ip-api.com](https://ip-api.com/docs/legal), [IPGeoLocation](https://ipgeolocation.io/privacy.html).---diff --git a/src/components/Widgets/PublicIp.vue b/src/components/Widgets/PublicIp.vueindex 878b39f6..47d675be 100644--- a/src/components/Widgets/PublicIp.vue+++ b/src/components/Widgets/PublicIp.vue@@ -15,31 +15,115 @@<script>import WidgetMixin from '@/mixins/WidgetMixin';-import { widgetApiEndpoints } from '@/utils/defaults';+import { widgetApiEndpoints as urls } from '@/utils/defaults';import { getCountryFlag, getMapUrl } from '@/utils/MiscHelpers';+/* Each provider's `parse` returns a normalised shape:+ * { ip, isp, city, region, countryCode, lat, lon }+ * `url` may be a string or a function that takes the user's apiKey. */+const PROVIDERS = {+ freeipapi: {+ url: urls.publicIp4,+ parse: (d) => ({+ ip: d.ipAddress,+ isp: d.asnOrganization,+ city: d.cityName,+ region: d.regionName,+ countryCode: d.countryCode,+ lat: d.latitude,+ lon: d.longitude,+ }),+ },+ ipinfo: {+ url: (key) => (key ? `${urls.publicIp5}?token=${key}` : urls.publicIp5),+ parse: (d) => {+ const [lat, lon] = (d.loc || ',').split(',');+ return {+ ip: d.ip,+ isp: d.org,+ city: d.city,+ region: d.region,+ countryCode: d.country,+ lat,+ lon,+ };+ },+ },+ ipquery: {+ url: urls.publicIp6,+ parse: (d) => ({+ ip: d.ip,+ isp: d.isp && (d.isp.org || d.isp.isp),+ city: d.location && d.location.city,+ region: d.location && d.location.state,+ countryCode: d.location && d.location.country_code,+ lat: d.location && d.location.latitude,+ lon: d.location && d.location.longitude,+ }),+ },+ 'ip-api': {+ url: urls.publicIp3,+ parse: (d) => ({+ ip: d.query,+ isp: d.isp,+ city: d.city,+ region: d.regionName,+ countryCode: d.countryCode,+ lat: d.lat,+ lon: d.lon,+ }),+ },+ ipgeolocation: {+ url: (key) => `${urls.publicIp2}?apiKey=${key}`,+ requiresKey: true,+ parse: (d) => ({+ ip: d.ip,+ isp: d.organization || d.isp,+ city: d.city,+ region: d.state_prov,+ countryCode: d.country_code2,+ lat: d.latitude,+ lon: d.longitude,+ }),+ },+};++/* List of deleted/depricated providers. Used to show warning if user tries to use */+const REMOVED_PROVIDERS = {+ 'ipapi.co': 'ipapi.co now serves a Cloudflare bot challenge to many clients.',+ 'ifconfig.co': 'ifconfig.co does not send Access-Control-Allow-Origin headers.',+ 'ip2location.io': 'ip2location.io does not send Access-Control-Allow-Origin headers.',+};++const DEFAULT_PROVIDER = 'freeipapi';+export default {mixins: [WidgetMixin],computed: {- endpoint() {- if (this.provider === 'ipgeolocation') {- return `${widgetApiEndpoints.publicIp2}?apiKey=${this.apiKey}`;- } else if (this.provider === 'ip2location.io') {- return `${widgetApiEndpoints.publicIp4}?key=${this.apiKey}`;- } else if (this.provider === 'ip-api') {- return widgetApiEndpoints.publicIp3;+ provider() {+ const chosen = this.parseAsEnvVar(this.options.provider);+ if (chosen && REMOVED_PROVIDERS[chosen]) {+ this.error(`Provider '${chosen}' is no longer supported: ${REMOVED_PROVIDERS[chosen]} `+ + `Pick one of: ${Object.keys(PROVIDERS).join(', ')}.`);+ return null;}- return widgetApiEndpoints.publicIp;+ if (chosen && !PROVIDERS[chosen]) {+ this.error(`Unknown provider '${chosen}'. Pick one of: ${Object.keys(PROVIDERS).join(', ')}.`);+ return null;+ }+ return chosen || DEFAULT_PROVIDER;+ },+ endpoint() {+ if (!this.provider) return null;+ const { url } = PROVIDERS[this.provider];+ return typeof url === 'function' ? url(this.apiKey) : url;},apiKey() {- if (this.provider === 'ipgeolocation' && !this.options.apiKey) this.error('Missing API Key');- if (this.provider === 'ip2location.io' && !this.options.apiKey) this.error('Missing API Key');+ if (!this.provider) return null;+ const needsKey = PROVIDERS[this.provider].requiresKey;+ if (needsKey && !this.options.apiKey) this.error('Missing API Key');return this.options.apiKey;},- provider() {- // Can be either `ip-api`, `ipapi.co`, `ipgeolocation` or `ip2location.io`- return this.parseAsEnvVar(this.options.provider) || 'ipapi.co';- },},data() {return {@@ -51,39 +135,19 @@ export default {};},methods: {- /* Make GET request to CoinGecko API endpoint */+ /* Make GET request to selected provider */fetchData() {+ if (!this.endpoint) return;this.makeRequest(this.endpoint).then(this.processData);},- /* Assign data variables to the returned data */+ /* Normalise the response and assign to display fields */processData(ipInfo) {- if (this.provider === 'ipapi.co') {- this.ipAddr = ipInfo.ip;- this.ispName = ipInfo.org;- this.location = `${ipInfo.city}, ${ipInfo.region}`;- this.flagImg = getCountryFlag(ipInfo.country_code);- this.mapsUrl = getMapUrl({ lat: ipInfo.latitude, lon: ipInfo.longitude });- } else if (this.provider === 'ipgeolocation') {- this.ipAddr = ipInfo.ip;- this.ispName = ipInfo.organization || ipInfo.isp;- this.location = `${ipInfo.city}, ${ipInfo.country_name}`;- this.flagImg = ipInfo.country_flag;- this.mapsUrl = getMapUrl({ lat: ipInfo.latitude, lon: ipInfo.longitude });- } else if (this.provider === 'ip-api') {- this.ipAddr = ipInfo.query;- this.ispName = ipInfo.isp;- this.location = `${ipInfo.city}, ${ipInfo.regionName}`;- this.flagImg = getCountryFlag(ipInfo.countryCode);- this.mapsUrl = getMapUrl({ lat: ipInfo.lat, lon: ipInfo.lon });- } else if (this.provider === 'ip2location.io') {- this.ipAddr = ipInfo.ip;- this.ispName = ipInfo.isp || 'IP2Location.io Starter plan or higher required.';- this.location = `${ipInfo.city_name}, ${ipInfo.region_name}`;- this.flagImg = getCountryFlag(ipInfo.country_code);- this.mapsUrl = getMapUrl({ lat: ipInfo.latitude, lon: ipInfo.longitude });- } else {- this.error('Unknown API provider fo IP address');- }+ const parsed = PROVIDERS[this.provider].parse(ipInfo);+ this.ipAddr = parsed.ip;+ this.ispName = parsed.isp;+ this.location = [parsed.city, parsed.region].filter(Boolean).join(', ');+ this.flagImg = parsed.countryCode ? getCountryFlag(parsed.countryCode) : null;+ this.mapsUrl = getMapUrl({ lat: parsed.lat, lon: parsed.lon });},},};diff --git a/src/utils/defaults.js b/src/utils/defaults.jsindex 89b11569..ec8207e6 100644--- a/src/utils/defaults.js+++ b/src/utils/defaults.js@@ -252,7 +252,9 @@ module.exports = {publicIp: 'https://ipapi.co/json',publicIp2: 'https://api.ipgeolocation.io/ipgeo',publicIp3: 'http://ip-api.com/json',- publicIp4: 'https://api.ip2location.io/',+ publicIp4: 'https://free.freeipapi.com/api/json',+ publicIp5: 'https://ipinfo.io/json',+ publicIp6: 'https://api.ipquery.io/?format=json',readMeStats: 'https://github-readme-stats.vercel.app/api',rescueTime: 'https://www.rescuetime.com/anapi/data',rssToJson: 'https://api.rss2json.com/v1/api.json',