π 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 IP blacklist widget (#1014, #1749)
Alicia Sykes30f70c1032b8
diff --git a/src/components/Widgets/BlacklistCheck.vue b/src/components/Widgets/BlacklistCheck.vueindex 7fee0094..56cd1837 100644--- a/src/components/Widgets/BlacklistCheck.vue+++ b/src/components/Widgets/BlacklistCheck.vue@@ -25,21 +25,10 @@ import { widgetApiEndpoints } from '@/utils/defaults';export default {mixins: [WidgetMixin],computed: {- version() {- return this.options.version || 'v2';- },- ipAddress() {- if (this.autoIp) return this.autoIp;- if (!this.options.apiKey) this.error('Missing IP Address');- return this.options.ipAddress;- },apiKey() {if (!this.options.apiKey) this.error('Missing API Key');return this.parseAsEnvVar(this.options.apiKey);},- endpoint() {- return `${widgetApiEndpoints.blacklistCheck}/${this.ipAddress}`;- },blacklistFiltered() {return this.showAll ? this.blacklisted : this.blacklisted.filter(bl => (bl.detected));},@@ -49,31 +38,30 @@ export default {blacklisted: null,message: '',showAll: false,- autoIp: null,};},methods: {- /* Make GET request to CoinGecko API endpoint */- fetchData() {- if (!this.ipAddress) {- this.getUsersIpAddress(); return;+ /* Fetch the user's IP (if not supplied), then run the blacklist check */+ async fetchData() {+ let ip = this.options.ipAddress;+ if (!ip) {+ const ipInfo = await this.makeRequest(widgetApiEndpoints.userIpLookup);+ if (!ipInfo || !ipInfo.ip) {+ this.error('Unable to determine your IP. Set `ipAddress` in options to check manually.');+ return;+ }+ ip = ipInfo.ip;}this.defaultTimeout = 200000;- const options = { Authorization: `Basic ${this.apiKey}` };- this.makeRequest(this.endpoint, options).then(this.processData);+ const endpoint = `${widgetApiEndpoints.blacklistCheck}/${ip}`;+ const options = { Authorization: `Basic ${btoa(`${this.apiKey}:`)}` };+ this.makeRequest(endpoint, options).then(this.processData);},/* Assign data variables to the returned data */processData(blResponse) {this.message = `${blResponse.detections} detections found for ${blResponse.ip_address}`;this.blacklisted = blResponse.blacklists;},- getUsersIpAddress() {- this.makeRequest(widgetApiEndpoints.publicIp)- .then((ipInfo) => {- this.autoIp = ipInfo.ip;- this.fetchData();- });- },},};</script>diff --git a/src/utils/defaults.js b/src/utils/defaults.jsindex ec8207e6..33be165b 100644--- a/src/utils/defaults.js+++ b/src/utils/defaults.js@@ -249,7 +249,7 @@ module.exports = {minecraftStatus: 'https://api.mcsrvstat.us/',mullvad: 'https://am.i.mullvad.net/json',mvg: 'https://www.mvg.de/api/fib/v2/',- publicIp: 'https://ipapi.co/json',+ userIpLookup: 'https://api.ipify.org?format=json',publicIp2: 'https://api.ipgeolocation.io/ipgeo',publicIp3: 'http://ip-api.com/json',publicIp4: 'https://free.freeipapi.com/api/json',