|
@@ -64,15 +64,20 @@ module.exports = app => {
|
|
|
* @return {String} 详细地址
|
|
|
*/
|
|
|
async getIpInfoFromApi(a_ip = '') {
|
|
|
- if (!a_ip) return '';
|
|
|
- if (a_ip === '127.0.0.1' || a_ip === '::1' || a_ip.indexOf('192.168') !== -1) return '服务器本机访问';
|
|
|
- const { ip = '', region = '', city = '', isp = '' } = await this.sendRequest(a_ip);
|
|
|
- let address = '';
|
|
|
- region && (address += region + '省');
|
|
|
- city && (address += city + '市 ');
|
|
|
- isp && (address += isp + ' ');
|
|
|
- ip && (address += `(${ip})`);
|
|
|
- return address;
|
|
|
+ try {
|
|
|
+ if (!a_ip) return '';
|
|
|
+ if (a_ip === '127.0.0.1' || a_ip === '::1' || a_ip.indexOf('192.168') !== -1) return '服务器本机访问';
|
|
|
+ const { ip = '', region = '', city = '', isp = '' } = await this.sendRequest(a_ip);
|
|
|
+ let address = '';
|
|
|
+ region && (address += region + '省');
|
|
|
+ city && (address += city + '市 ');
|
|
|
+ isp && (address += isp + ' ');
|
|
|
+ ip && (address += `(${ip})`);
|
|
|
+ return address;
|
|
|
+ } catch (error) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|