fix: add support for claude.ai reverse proxy

This commit is contained in:
ikechan8370 2023-09-13 20:25:02 +08:00
parent bb51e53e02
commit 08e92d871e
3 changed files with 13 additions and 4 deletions

View file

@ -601,16 +601,22 @@ export function supportGuoba () {
bottomHelpMessage: 'claude.ai Cookie中的SessionKey',
component: 'Input'
},
{
field: 'claudeAIReverseProxy',
label: 'claude2 反代',
bottomHelpMessage: 'claude.ai 的反代。或许可以参考https://github.com/ikechan8370/sydney-ws-proxy/tree/claude.ai搭建',
component: 'Input'
},
{
field: 'claudeAIJA3',
label: 'claude2浏览器指纹',
bottomHelpMessage: 'claude.ai使用的浏览器TLS指纹去https://scrapfly.io/web-scraping-tools/ja3-fingerprint或https://ja3.zone/check查看',
bottomHelpMessage: 'claude.ai使用的浏览器TLS指纹去https://scrapfly.io/web-scraping-tools/ja3-fingerprint或https://ja3.zone/check查看。如果用了反代就不用管',
component: 'Input'
},
{
field: 'claudeAIUA',
label: 'claude2浏览器UA',
bottomHelpMessage: 'claude.ai使用的浏览器UA去https://scrapfly.io/web-scraping-tools/ja3-fingerprint或https://ja3.zone/check查看',
bottomHelpMessage: 'claude.ai使用的浏览器UAhttps://scrapfly.io/web-scraping-tools/http2-fingerprint或https://ja3.zone/check查看。如果用了反代就不用管',
component: 'Input'
},
{

View file

@ -103,8 +103,9 @@ export class ClaudeAIClient {
// redirect: 'manual'
// // referrer: 'https://claude.ai/chat/bba5a67d-ee59-4196-a371-ece8a35db1f2'
// })
let host = Config.claudeAIReverseProxy || 'https://claude.ai'
const cycleTLS = await initCycleTLS()
let result = await cycleTLS(`https://claude.ai/api/organizations/${this.organizationId}/chat_conversations`, {
let result = await cycleTLS(`${host}/api/organizations/${this.organizationId}/chat_conversations`, {
ja3: this.JA3,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
proxy: this.proxy,
@ -140,7 +141,8 @@ export class ClaudeAIClient {
timezone: 'Asia/Hong_Kong'
}
}
let url = 'https://claude.ai/api/append_message'
let host = Config.claudeAIReverseProxy || 'https://claude.ai'
let url = host + '/api/append_message'
const cycleTLS = await initCycleTLS()
let streamDataRes = await cycleTLS(url, {
ja3: this.JA3,

View file

@ -147,6 +147,7 @@ const defaultConfig = {
// claude2
claudeAIOrganizationId: '',
claudeAISessionKey: '',
claudeAIReverseProxy: '',
claudeAIJA3: '772,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,27-5-65281-13-35-0-51-18-16-43-10-45-11-17513-23,29-23-24,0',
claudeAIUA: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
version: 'v2.7.4'