jizhi.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function getAddress(field) {
  2. const id = getQueryParameter.call({ url: field.url, key: "id" });
  3. const s = getQueryParameter.call({ url: field.url, key: "s" });
  4. let fabu, ouhauCache, focusCache, res, result;
  5. // 检查是否存在已缓存的端口信息
  6. ouhauCache = getCache.call('OUHAU');
  7. focusCache = getCache.call('FOCHS');
  8. if (s === 'ouhau' && ouhauCache !== null) {
  9. return JSON.stringify({ url: `p3p://108.181.20.159:${ouhauCache}/${id}` });
  10. } else if (s === 'focus' && focusCache !== null) {
  11. return JSON.stringify({ url: `p3p://108.181.32.169:${focusCache}/${id}` });
  12. }
  13. const nameAPI = 'FABU';
  14. fabu = getCache.call(nameAPI);
  15. // 如果地址缓存不存在或已过期,则重新获取
  16. if (fabu === null) {
  17. const headers = {
  18. 'User-Agent': 'regimcode_162100bbs=123'
  19. };
  20. res = post.call({ url: 'http://103.45.68.47:6800/gy/gy-fabu.php', headers: JSON.stringify(headers), body: 'captcha=123' });
  21. result = />p3p端口:<a href="(.*?)"/.exec(res);
  22. if (!result) {
  23. return JSON.stringify({ error: '获取接口出错!' });
  24. }
  25. fabu = result[1];
  26. setCache.call({ name: nameAPI, value: fabu, expire: "21600000000" });
  27. }
  28. res = get.call({ url: fabu });
  29. result = [...res.matchAll(/(\d+):(\d+)/g)];
  30. if (!result) {
  31. return JSON.stringify({ error: '获取端口出错!' });
  32. }
  33. for (const match of result) {
  34. if (match[1] === '159') {
  35. ouhauCache = match[2];
  36. setCache.call({ name: 'OUHAU', value: match[2], expire: "21600000000" });
  37. } else if (match[1] === '169') {
  38. focusCache = match[2];
  39. setCache.call({ name: 'FOCHS', value: match[2], expire: "21600000000" });
  40. }
  41. }
  42. if (s === 'ouhau') {
  43. if (ouhauCache === null) {
  44. return JSON.stringify({ error: '获取端口出错!' });
  45. } else {
  46. return JSON.stringify({ url: `p3p://108.181.20.159:${ouhauCache}/${id}` });
  47. }
  48. } else if (s === 'focus') {
  49. if (focusCache === null) {
  50. return JSON.stringify({ error: '获取端口出错!' });
  51. } else {
  52. return JSON.stringify({ url: `p3p://108.181.32.169:${focusCache}/${id}` });
  53. }
  54. }
  55. return JSON.stringify({ error: '列表不正确!' });
  56. }