mirror of
				https://github.com/whyour/qinglong.git
				synced 2025-10-31 17:06:07 +08:00 
			
		
		
		
	更换ip查询接口
This commit is contained in:
		
							parent
							
								
									f3518d0cad
								
							
						
					
					
						commit
						930541d5d6
					
				|  | @ -159,14 +159,16 @@ export async function getNetIp(req: any) { | ||||||
|     const baiduApi = got.get( |     const baiduApi = got.get( | ||||||
|       `https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=${ip}&co=&resource_id=6006&t=1555898284898&ie=utf8&oe=utf8&format=json&tn=baidu`, |       `https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=${ip}&co=&resource_id=6006&t=1555898284898&ie=utf8&oe=utf8&format=json&tn=baidu`, | ||||||
|     ); |     ); | ||||||
|     const ipApi = got.get(`http://ip-api.com/json/${ip}?lang=zh-CN`); |     const ipApi = got.get( | ||||||
|     const [{ data }, { country, regionName, city }] = await ( |       `https://whois.pconline.com.cn/ipJson.jsp?ip=${ip}&json=true`, | ||||||
|  |     ); | ||||||
|  |     const [{ data }, { addr, region, city }] = await ( | ||||||
|       await Promise.all<any>([baiduApi, ipApi]) |       await Promise.all<any>([baiduApi, ipApi]) | ||||||
|     ).map((x) => JSON.parse(x.body)); |     ).map((x) => JSON.parse(x.body)); | ||||||
|     if (data[0] && data[0].location) { |     if (data[0] && data[0].location) { | ||||||
|       return { address: data[0].location, ip }; |       return { address: data[0].location, ip }; | ||||||
|     } else if (country && regionName) { |     } else if (city && region) { | ||||||
|       return { address: `${country} ${regionName} ${city}`, ip }; |       return { address: `${addr}`, ip }; | ||||||
|     } else { |     } else { | ||||||
|       return { address: `获取失败`, ip }; |       return { address: `获取失败`, ip }; | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 hanhh
						hanhh