Skip to content

Commit

Permalink
fix(core): fix missing proxyAgent config
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 30, 2023
1 parent ed1c3d8 commit c914665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare module 'cordis-axios' {

defineProperty(Quester, 'Config', Schema.object({
timeout: Schema.natural().role('ms').description('等待连接建立的最长时间。'),
proxyAgent: Schema.string().description('使用的代理服务器地址。'),
}).description('请求设置'))

Quester.createConfig = function createConfig(this, endpoint) {
Expand Down Expand Up @@ -107,7 +108,7 @@ export class Context extends cordis.Context {
// remove generic type to loosen the constraint
static readonly Session = Session as new (bot: Bot, event: Partial<Event>) => Session

public bots = new Proxy([] as Bot<this>[] & Dict<Bot<this>>, {
public bots = new Proxy([], {
get(target, prop) {
if (prop in target || typeof prop === 'symbol') {
return Reflect.get(target, prop)
Expand All @@ -123,7 +124,7 @@ export class Context extends cordis.Context {
target.splice(bot, 1)
return true
},
})
}) as Bot<this>[] & Dict<Bot<this>>

constructor(config: Context.Config = {}) {
super(config)
Expand Down
9 changes: 2 additions & 7 deletions packages/satori/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Quester, Schema } from '@satorijs/core'
import { base64ToArrayBuffer, defineProperty } from 'cosmokit'
import { Quester } from '@satorijs/core'
import { base64ToArrayBuffer } from 'cosmokit'
import { ClientRequestArgs } from 'http'
import { WebSocket } from 'ws'
import { basename } from 'path'
Expand Down Expand Up @@ -50,11 +50,6 @@ Quester.prototype.prepare = function prepare(this: Quester) {
return options
}

defineProperty(Quester, 'Config', Schema.object({
...Quester.Config.dict,
proxyAgent: Schema.string().description('使用的代理服务器地址。'),
}).description('请求设置'))

Quester.defineAgent(['http'], createHttpProxyAgent)
Quester.defineAgent(['https'], createHttpsProxyAgent)
Quester.defineAgent(['socks', 'socks4', 'socks4a', 'socks5', 'socks5h'], createSocksProxyAgent)

0 comments on commit c914665

Please sign in to comment.