プロキシの除外ホスト (#6244)
* プロキシの除外ホスト * オブジェクトストレージとの通信にProxyを使うかを選択できるように * fix lint * コメント Co-authored-by: rinsuki <428rinsuki+git@gmail.com>
This commit is contained in:
parent
e7da10ae58
commit
36b9a0d42f
12 changed files with 89 additions and 16 deletions
|
@ -1,8 +1,12 @@
|
|||
import * as S3 from 'aws-sdk/clients/s3';
|
||||
import { Meta } from '../../models/entities/meta';
|
||||
import { httpsAgent, httpAgent } from '../../misc/fetch';
|
||||
import { getAgentByUrl } from '../../misc/fetch';
|
||||
|
||||
export function getS3(meta: Meta) {
|
||||
const u = meta.objectStorageEndpoint != null
|
||||
? `${meta.objectStorageUseSSL ? 'https://' : 'http://'}${meta.objectStorageEndpoint}`
|
||||
: `${meta.objectStorageUseSSL ? 'https://' : 'http://'}example.net`;
|
||||
|
||||
return new S3({
|
||||
endpoint: meta.objectStorageEndpoint || undefined,
|
||||
accessKeyId: meta.objectStorageAccessKey!,
|
||||
|
@ -11,7 +15,7 @@ export function getS3(meta: Meta) {
|
|||
sslEnabled: meta.objectStorageUseSSL,
|
||||
s3ForcePathStyle: !!meta.objectStorageEndpoint,
|
||||
httpOptions: {
|
||||
agent: meta.objectStorageUseSSL ? httpsAgent : httpAgent
|
||||
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue