From b7d32b9cbcde886994d247eae424b65413f33903 Mon Sep 17 00:00:00 2001 From: "yanlong.wang" Date: Mon, 7 Apr 2025 15:07:02 +0800 Subject: [PATCH] saas: tweaks --- src/api/crawler.ts | 11 +---------- src/api/serp.ts | 2 +- src/services/serp/google.ts | 10 ++-------- thinapps-shared | 2 +- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/api/crawler.ts b/src/api/crawler.ts index bafdd4e..8312bce 100644 --- a/src/api/crawler.ts +++ b/src/api/crawler.ts @@ -891,9 +891,6 @@ export class CrawlerHost extends RPCHost { } } else if (crawlOpts?.allocProxy && crawlOpts.allocProxy !== 'none' && !crawlOpts.proxyUrl) { const proxyUrl = await this.proxyProvider.alloc(this.figureOutBestProxyCountry(crawlOpts)); - if (proxyUrl.protocol === 'socks5h:') { - proxyUrl.protocol = 'socks5:'; - } crawlOpts.proxyUrl = proxyUrl.href; } @@ -1242,7 +1239,6 @@ export class CrawlerHost extends RPCHost { }; } - retryDet = new WeakSet(); @retryWith((err) => { if (err instanceof ServiceBadApproachError) { return false; @@ -1263,12 +1259,7 @@ export class CrawlerHost extends RPCHost { } const proxy = await this.proxyProvider.alloc(this.figureOutBestProxyCountry(opts)); - if (opts) { - if (this.retryDet.has(opts) && proxy.protocol === 'socks5h:') { - proxy.protocol = 'socks5:'; - } - this.retryDet.add(opts); - } + this.logger.debug(`Proxy allocated`, { proxy: proxy.href }); const r = await this.curlControl.sideLoad(url, { ...opts, proxyUrl: proxy.href, diff --git a/src/api/serp.ts b/src/api/serp.ts index 4359413..b367b10 100644 --- a/src/api/serp.ts +++ b/src/api/serp.ts @@ -136,7 +136,7 @@ export class SerpHost extends RPCHost { @Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string, @Param('location') location?: string, @Param('page') page?: number, - @Param('fallback', { default: true }) fallback?: boolean, + @Param('fallback') fallback?: boolean, ) { const authToken = auth.bearerToken; let highFreqKey: RateLimitCache | undefined; diff --git a/src/services/serp/google.ts b/src/services/serp/google.ts index 11b4ac4..3f82d3e 100644 --- a/src/services/serp/google.ts +++ b/src/services/serp/google.ts @@ -16,7 +16,7 @@ import { ProxyProvider } from '../../shared/services/proxy-provider'; @singleton() export class GoogleSERP extends AsyncService { - + logger = this.globalLogger.child({ service: this.constructor.name }); googleDomain = process.env.OVERRIDE_GOOGLE_DOMAIN || 'www.google.com'; constructor( @@ -36,7 +36,6 @@ export class GoogleSERP extends AsyncService { this.emit('ready'); } - retryDet = new WeakSet(); @retryWith((err) => { if (err instanceof ServiceBadApproachError) { return false; @@ -59,12 +58,7 @@ export class GoogleSERP extends AsyncService { const proxy = await this.proxyProvider.alloc( process.env.PREFERRED_PROXY_COUNTRY || 'auto' ); - if (opts) { - if (this.retryDet.has(opts) && proxy.protocol === 'socks5h:') { - proxy.protocol = 'socks5:'; - } - this.retryDet.add(opts); - } + this.logger.debug(`Proxy allocated`, { proxy: proxy.href }); const r = await this.curlControl.sideLoad(url, { ...opts, proxyUrl: proxy.href, diff --git a/thinapps-shared b/thinapps-shared index 936ebc4..424f50c 160000 --- a/thinapps-shared +++ b/thinapps-shared @@ -1 +1 @@ -Subproject commit 936ebc4158a3007b59496822ef650e995c189614 +Subproject commit 424f50ca8b6277d74185e16aa67ff2b366d9f727