mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: dns支持火山引擎
This commit is contained in:
@@ -54,6 +54,18 @@
|
||||
<div class="content unicode" style="display: block;">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">京东云</div>
|
||||
<div class="code-name">&#xe653;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">volcengine</div>
|
||||
<div class="code-name">&#xe651;</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont"></span>
|
||||
<div class="name">upyun</div>
|
||||
@@ -180,7 +192,7 @@
|
||||
<pre><code class="language-css"
|
||||
>@font-face {
|
||||
font-family: 'iconfont';
|
||||
src: url('iconfont.svg?t=1742952318857#iconfont') format('svg');
|
||||
src: url('iconfont.svg?t=1743171100316#iconfont') format('svg');
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
|
||||
@@ -206,6 +218,24 @@
|
||||
<div class="content font-class">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont icon-jdcloud"></span>
|
||||
<div class="name">
|
||||
京东云
|
||||
</div>
|
||||
<div class="code-name">.icon-jdcloud
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont icon-volcengine"></span>
|
||||
<div class="name">
|
||||
volcengine
|
||||
</div>
|
||||
<div class="code-name">.icon-volcengine
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<span class="icon iconfont icon-upyun"></span>
|
||||
<div class="name">
|
||||
@@ -395,6 +425,22 @@
|
||||
<div class="content symbol">
|
||||
<ul class="icon_lists dib-box">
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-jdcloud"></use>
|
||||
</svg>
|
||||
<div class="name">京东云</div>
|
||||
<div class="code-name">#icon-jdcloud</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-volcengine"></use>
|
||||
</svg>
|
||||
<div class="name">volcengine</div>
|
||||
<div class="code-name">#icon-volcengine</div>
|
||||
</li>
|
||||
|
||||
<li class="dib">
|
||||
<svg class="icon svg-icon" aria-hidden="true">
|
||||
<use xlink:href="#icon-upyun"></use>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 4688792 */
|
||||
src: url('iconfont.svg?t=1742952318857#iconfont') format('svg');
|
||||
src: url('iconfont.svg?t=1743171100316#iconfont') format('svg');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
@@ -11,6 +11,14 @@
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-jdcloud:before {
|
||||
content: "\e653";
|
||||
}
|
||||
|
||||
.icon-volcengine:before {
|
||||
content: "\e651";
|
||||
}
|
||||
|
||||
.icon-upyun:before {
|
||||
content: "\e62f";
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -5,6 +5,20 @@
|
||||
"css_prefix_text": "icon-",
|
||||
"description": "",
|
||||
"glyphs": [
|
||||
{
|
||||
"icon_id": "30950102",
|
||||
"name": "京东云",
|
||||
"font_class": "jdcloud",
|
||||
"unicode": "e653",
|
||||
"unicode_decimal": 58963
|
||||
},
|
||||
{
|
||||
"icon_id": "43404901",
|
||||
"name": "volcengine",
|
||||
"font_class": "volcengine",
|
||||
"unicode": "e651",
|
||||
"unicode_decimal": 58961
|
||||
},
|
||||
{
|
||||
"icon_id": "5771134",
|
||||
"name": "upyun",
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
/>
|
||||
<missing-glyph />
|
||||
|
||||
<glyph glyph-name="jdcloud" unicode="" d="M1764.515669 474.466832c17.649055-24.683993 30.854991-58.192512 29.373951-128.41847-19.870614-220.489763-207.036987-359.707481-393.40113-359.707481-201.668219 0-343.662885 145.141875-429.0695 307.315707C951.239827 331.978486 936.614562 374.743503 922.853236 411.769491c-26.967262-36.655729-83.802155-96.452701-112.744136-124.283902A715.835781 715.835781 0 0 1 878.360339 146.416573c22.770983-35.483239 80.222976-115.767924 162.358961-179.329206 74.669077-57.575412 146.314366-92.935232 227.33957-113.114395a555.01957 555.01957 0 0 1 403.521567 56.896602c146.561205 83.987284 249.863714 238.694207 268.561838 399.325289-36.100339 59.858682-114.348595 130.57832-175.626606 164.271969zM531.488535 532.906185a271.894177 271.894177 0 0 0 144.463065-41.407398c34.742719 37.025988 65.47429 75.286177 97.378351 113.854915A421.602591 421.602591 0 0 1 109.700813 259.962938a424.50296 424.50296 0 0 1 4.998509-64.857191c11.786607-14.563555 130.51661-4.689958 149.029604 11.971737a275.905326 275.905326 0 0 0-5.183638 52.885454 272.943247 272.943247 0 0 0 272.943247 272.943247zM531.488535-162.133333a421.726012 421.726012 0 0 0-365.199668 210.924715c5.677318 7.528618 138.353778 22.277303 170.010997 20.487715a272.017597 272.017597 0 0 1 195.188671-82.259406s167.851149-12.897386 324.717921 111.077967c0 0 58.994742-84.048994 104.289868-115.644505 0 0-147.918825-144.586486-429.007789-144.586486zM1623.384941 881.999548C1424.123413 965.739993 1229.736972 941.302839 1037.6338 800.110403 868.239902 675.641371 800.852603 550.246689 692.489876 442.624482c-129.59096-128.727021-226.78418-172.047427-303.859948-201.174539-79.605875-30.11447-190.683842-50.663894-273.930606-46.097355a422.589951 422.589951 0 0 1 51.589545-146.314366c212.529175 3.640889 362.361009 84.974644 458.998839 143.907677 84.480964 51.527835 211.603525 181.303924 278.312015 265.352918 107.190237 134.898019 246.839924 263.933589 374.517876 304.415338 178.341845 56.464633 351.746893-22.524143 435.795887-134.095789 7.528618-9.811887 165.135909-66.39994 214.689024-108.979827C1910.398064 596.899435 1824.49777 797.456874 1623.384941 881.999548zM1923.97426 536.670494A565.880527 565.880527 0 0 1 1602.156708 640.096421c-139.526268 0-279.237665-54.366494-377.541664-151.189454-71.521868-70.349378-106.326298-127.431111-185.623624-222.526192a648.942162 648.942162 0 0 1 105.400648-123.419961c10.243857 14.933815 67.880979 96.514411 111.077966 153.842982 55.538983 72.941198 111.941906 131.25713 197.47194 165.01249a398.276219 398.276219 0 0 0 486.398071-158.532941A552.983141 552.983141 0 0 1 1923.97426 536.670494z" horiz-adv-x="2030" />
|
||||
|
||||
<glyph glyph-name="volcengine" unicode="" d="M836.395 420.139L709.973-74.155a8.661 8.661 0 0 1 0-4.138 9.216 9.216 0 0 1 9.174-7.04H971.86a9.216 9.216 0 0 1 9.216 11.178L854.06 420.14a9.301 9.301 0 0 1-14.379 4.736 8.96 8.96 0 0 1-3.328-4.694M140.8 308.14L42.88-74.155a9.173 9.173 0 0 1 9.259-11.136h195.029a9.344 9.344 0 0 1 7.381 3.328 8.917 8.917 0 0 1 1.792 3.67 8.661 8.661 0 0 1 0.043 4.138L158.379 308.14a8.96 8.96 0 0 1-3.328 4.65 9.387 9.387 0 0 1-5.419 1.792 9.387 9.387 0 0 1-5.547-1.792 8.96 8.96 0 0 1-3.285-4.65M313.43 624.64L135.082-74.155a8.96 8.96 0 0 1 1.706-7.594 9.088 9.088 0 0 1 7.04-3.542H500.65a9.216 9.216 0 0 1 9.258 11.094L331.051 624.725a8.96 8.96 0 0 1-3.328 4.651 9.387 9.387 0 0 1-5.462 1.792 9.387 9.387 0 0 1-5.504-1.792 8.96 8.96 0 0 1-3.328-4.693M621.141 846.89a8.96 8.96 0 0 1-3.328 4.651 9.387 9.387 0 0 1-5.504 1.792 9.387 9.387 0 0 1-5.461-1.792 8.96 8.96 0 0 1-3.328-4.65L359.723-74.155a9.173 9.173 0 0 1 9.216-11.093h487.253a9.344 9.344 0 0 1 7.339 3.328 9.472 9.472 0 0 1 1.877 3.67 9.173 9.173 0 0 1 0 4.095L621.141 846.891zM442.027 523.05L287.36-74.111a8.832 8.832 0 0 1 1.835-7.85 9.216 9.216 0 0 1 7.381-3.371h308.608a9.387 9.387 0 0 1 7.424 3.413 9.301 9.301 0 0 1 1.835 7.808L459.648 523.093a8.96 8.96 0 0 1-3.328 4.608 9.387 9.387 0 0 1-5.504 1.835 9.387 9.387 0 0 1-5.461-1.835 8.96 8.96 0 0 1-3.328-4.608" horiz-adv-x="1024" />
|
||||
|
||||
<glyph glyph-name="upyun" unicode="" d="M800.499763 767.681969a449.332702 449.332702 0 0 1-55.882631 35.892097 31.803124 31.803124 0 0 1-40.435399-8.177947L584.238523 636.834832l-6.814954-12.266919a65.877899 65.877899 0 0 0-55.428301-25.89683h-23.625178a213.989588 213.989588 0 0 1-200.359678-224.893515 23.625177 23.625177 0 0 1 13.62991-20.444865 56.336962 56.336962 0 1 0-77.236157-67.24089v3.634642a56.791292 56.791292 0 0 0 10.903928 45.433034 34.529106 34.529106 0 0 1 7.269285 24.988168 261.694273 261.694273 0 0 0 259.422622 284.410791 48.613346 48.613346 0 0 1 38.618078 19.536204l110.402272 146.748699a19.990535 19.990535 0 0 1-10.903927 31.803123A479.772834 479.772834 0 0 1 278.928538-35.574066a31.803124 31.803124 0 0 1 40.88973 8.632277L441.124467 132.073829l8.177947 11.358258a66.332229 66.332229 0 0 0 55.428301 25.89683 204.902981 204.902981 0 0 1 23.625177 0 215.80691 215.80691 0 0 1 157.652627 84.959772 211.717937 211.717937 0 0 1 42.707051 139.933743 23.625177 23.625177 0 0 1-13.62991 20.444865 56.336962 56.336962 0 0 0-33.620445 40.4354 56.336962 56.336962 0 0 0 109.947941 25.4425 13.17558 13.17558 0 0 1 0-4.088973 57.245622 57.245622 0 0 0-10.903927-45.433034 34.529106 34.529106 0 0 1-7.269286-24.988168 261.694273 261.694273 0 0 0-259.422622-284.410791 48.613346 48.613346 0 0 1-38.618078-19.536204L365.705632-44.660672a20.444865 20.444865 0 0 1 10.449598-31.803124 480.227166 480.227166 0 0 1 424.344533 844.145765z" horiz-adv-x="1024" />
|
||||
|
||||
<glyph glyph-name="plesk" unicode="" d="M716.942589 895.930235V211.95271h68.439611V896zM1987.156664 894.953523v-683.070578h68.369846V894.822713z m68.369846-430.930607L2286.10905 211.95271h94.810838L2141.477174 465.967619 2381.818114 700.448286h-91.810937zM1682.701552 709.238695c-49.882082 0-90.415634-11.65078-121.870996-35.161635q-46.986828-35.161635-46.951945-99.554868c0-24.199786 4.534735-44.091574 13.735014-59.718968a123.499576 123.499576 0 0 1 35.37093-38.588849 201.316059 201.316059 0 0 1 48.556544-24.836393c18.069174-6.488159 36.277878-12.487962 54.905173-17.659303a999.135047 999.135047 0 0 0 46.533355-14.171046 172.450729 172.450729 0 0 0 38.859188-18.069174 87.335066 87.335066 0 0 0 26.580522-25.88287q9.732238-15.17392 9.697355-37.673181c0-19.534242-8.860174-36.068582-26.580521-49.742552-17.659303-13.673969-44.998521-20.580719-81.834521-20.580719q-84.973952 0-138.134995 68.369847l-53.230809-46.87346c26.580522-29.301363 54.905173-50.230908 84.904186-63.067695 29.929249-12.627492 64.462998-18.9674 103.252421-18.9674a263.165044 263.165044 0 0 1 71.230218 9.278765 175.136687 175.136687 0 0 1 58.2539 27.688044l-0.488356-0.348826a134.548631 134.548631 0 0 1 38.998718 44.4404 123.211794 123.211794 0 0 1 14.232091 59.518393c0 24.199786-4.74403 44.091574-14.232091 60.067794a136.449731 136.449731 0 0 1-36.975529 40.254491l-0.418591 0.27906a207.96119 207.96119 0 0 1-49.254195 26.379948l-1.465068 0.488356c-9.836886 4.116144-28.18512 10.604303-46.672885 16.67387l-8.581114 2.441781q-22.499261 6.802102-43.463688 14.171046a184.546261 184.546261 0 0 0-37.742946 17.580817l0.837182-0.488356a86.116356 86.116356 0 0 0-25.394514 23.16203l-0.139531 0.27906a55.225656 55.225656 0 0 0-9.697355 31.394318v1.813893a59.891201 59.891201 0 0 0 20.929544 46.87346c13.95303 12.348431 38.440597 18.627295 73.183642 18.627295q40.91726 0 70.602331-15.139037c19.813302-10.115947 38.152816-25.88287 55.253999-47.440302l1.046477-0.906947 50.230908 45.975234q-37.987124 43.952044-79.322975 61.463096a235.913033 235.913033 0 0 1-90.345869 17.659304c-1.526113 0-3.069667 0-4.534735-0.069765h0.218017zM316.420866 705.401612q-82.043816 0-167.087533-26.440992v-709.372039h67.462899V222.626778a487.405496 487.405496 0 0 1 50.79775-10.682789 320.047623 320.047623 0 0 1 51.556445-4.046378 329.08657 329.08657 0 0 1 98.299096 14.929742l-2.30225-0.627887a238.439839 238.439839 0 0 1 83.500163 44.440401q36.626703 30.243192 59.160847 77.23002 22.289965 46.87346 22.394613 112.391656a262.628725 262.628725 0 0 1-18.627295 99.633354 226.263641 226.263641 0 0 1-53.169765 79.113679l-0.069765 0.069765a246.486813 246.486813 0 0 1-81.83452 51.277385l-1.674364 0.558121q-48.870487 18.531368-108.484807 18.627295z m826.57749 0a239.863484 239.863484 0 0 1-85.043717-15.139038 191.080204 191.080204 0 0 1-70.323271-46.533354 222.204181 222.204181 0 0 1-47.440301-77.020725l-0.488356-1.526113q-17.580818-47.405419-17.580818-111.842255a291.786197 291.786197 0 0 1 14.580916-92.857414 231.293272 231.293272 0 0 1 44.021809-78.136967 207.054243 207.054243 0 0 1 73.323172-54.216242q43.952044-20.092363 102.624535-20.092363 63.521169 0 108.484808 19.045886a226.717114 226.717114 0 0 1 79.043914 56.160945l-40.952143 42.992773q-28.464181-31.28967-63.556051-45.417112a203.949694 203.949694 0 0 0-75.485892-14.23209h-2.651075q-77.334668 0-122.228542 48.905369-44.893874 48.870487-47.789127 131.786368h366.406564q1.779011 126.100508-52.812218 191.993691-54.722039 66.032714-162.134207 66.058876z m2.860371-57.695779c24.199786 0 45.277582-3.706274 63.556051-11.232189a122.333189 122.333189 0 0 0 44.4404-29.789719 130.168688 130.168688 0 0 0 26.440992-44.998521 170.763284 170.763284 0 0 0 9.278765-56.649301h-296.153059a197.470255 197.470255 0 0 0 46.184529 102.83383l-0.218017-0.279061c10.325242 11.720545 24.557333 21.417901 42.417211 28.813007 17.929643 7.464871 39.277779 11.162424 64.114173 11.232189z m-823.507823-0.985432q85.915781 0 133.390965-52.393628 47.405419-52.219214 47.440302-137.228049c0-61.323566-17.223271-108.353998-51.34715-141.204662q-51.382033-49.393726-138.204761-49.31524a225.391576 225.391576 0 0 0-48.347249 5.302151 434.560575 434.560575 0 0 0-51.556445 14.171046l3.139432-0.976712V631.023242a260.609896 260.609896 0 0 0 51.835506 12.278666 424.403205 424.403205 0 0 0 53.6494 3.348727z m221.085758-612.808352v-64.393233h411.396365v64.393233z" horiz-adv-x="2467" />
|
||||
|
||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 44 KiB |
@@ -21,3 +21,4 @@ run/
|
||||
.env.pgpl.yaml
|
||||
tools/lego/*
|
||||
!tools/lego/readme.md
|
||||
test.mjs
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
"@midwayjs/typeorm": "~3.20.3",
|
||||
"@midwayjs/upload": "~3.20.3",
|
||||
"@midwayjs/validate": "~3.20.3",
|
||||
"@volcengine/openapi": "^1.28.1",
|
||||
"ali-oss": "^6.21.0",
|
||||
"axios": "^1.7.2",
|
||||
"basic-ftp": "^5.0.5",
|
||||
|
||||
@@ -16,3 +16,4 @@ export * from './plugin-qnap/index.js';
|
||||
export * from './plugin-aws/index.js';
|
||||
export * from './plugin-dnsla/index.js';
|
||||
export * from './plugin-upyun/index.js';
|
||||
export * from './plugin-volcengine/index.js'
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import {AccessInput, BaseAccess, IsAccess} from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
* 在certd的后台管理系统中,用户可以选择添加此类型的授权
|
||||
*/
|
||||
@IsAccess({
|
||||
name: 'volcengine',
|
||||
title: '火山引擎',
|
||||
desc: '',
|
||||
icon: 'svg:icon-volcengine',
|
||||
})
|
||||
export class VolcengineAccess extends BaseAccess {
|
||||
|
||||
@AccessInput({
|
||||
title: 'AccessKeyID',
|
||||
component: {
|
||||
placeholder: 'AccessKeyID',
|
||||
},
|
||||
helper:"[获取密钥](https://console.volcengine.com/iam/keymanage/)",
|
||||
required: true,
|
||||
})
|
||||
accessKeyId = '';
|
||||
@AccessInput({
|
||||
title: 'SecretAccessKey',
|
||||
component: {
|
||||
placeholder: 'SecretAccessKey',
|
||||
},
|
||||
required: true,
|
||||
encrypt: true,
|
||||
})
|
||||
secretAccessKey = '';
|
||||
|
||||
}
|
||||
|
||||
new VolcengineAccess();
|
||||
@@ -0,0 +1,182 @@
|
||||
import { VolcengineAccess } from "./access.js";
|
||||
import { http, HttpClient, ILogger } from "@certd/basic";
|
||||
import querystring from "querystring";
|
||||
|
||||
export type VolcengineOpts = {
|
||||
access: VolcengineAccess
|
||||
logger: ILogger
|
||||
http: HttpClient
|
||||
}
|
||||
|
||||
export type VolcengineReq = {
|
||||
method?: string;
|
||||
path?: string;
|
||||
headers?: any;
|
||||
body?: any;
|
||||
query?: any;
|
||||
service?: string, // 替换为实际服务名称
|
||||
region?: string, // 替换为实际区域名称
|
||||
}
|
||||
|
||||
export class VolcengineClient {
|
||||
opts: VolcengineOpts;
|
||||
|
||||
constructor(opts: VolcengineOpts) {
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
// // 生成签名函数
|
||||
// async createSignedRequest(req: VolcengineReq) {
|
||||
// if (!req.body) {
|
||||
// req.body = {};
|
||||
// }
|
||||
// const bodyStr = JSON.stringify(req.body);
|
||||
// const { method, path, body, query } = req;
|
||||
// const crypto = await import("crypto");
|
||||
// const config = {
|
||||
// accessKeyId: this.opts.access.accessKeyId,
|
||||
// secretKey: this.opts.access.secretAccessKey,
|
||||
// service: req.service || "dns", // 默认服务名称为 dns
|
||||
// region: req.region || "cn-beijing", // 默认区域名称为 cn-beijing
|
||||
// endpoint: "https://open.volcengineapi.com"
|
||||
// };
|
||||
//
|
||||
// // 1. 生成时间戳
|
||||
// const now = new Date();
|
||||
// // 20201103T104027Z
|
||||
// const timestamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
||||
//
|
||||
// // 2. 处理查询参数
|
||||
// const sortedQuery = Object.keys(query || {})
|
||||
// .sort()
|
||||
// .map(k => `${encodeURIComponent(k)}=${encodeURIComponent(query[k])}`)
|
||||
// .join("&");
|
||||
//
|
||||
// // 3. 构造规范请求
|
||||
// const canonicalRequest = [
|
||||
// method.toUpperCase(),
|
||||
// path || "/",
|
||||
// sortedQuery,
|
||||
// `content-type:application/json\nhost:${new URL(config.endpoint).host}`,
|
||||
// "content-type;host",
|
||||
// crypto.createHash("sha256").update(bodyStr).digest("hex")
|
||||
// ].join("\n");
|
||||
//
|
||||
// // 4. 生成签名字符串
|
||||
// const date = now.toISOString().substring(0, 10).replace(/-/g, "");
|
||||
// const credentialScope = `${date}/${config.region}/${config.service}/request`;
|
||||
//
|
||||
// const stringToSign = [
|
||||
// "HMAC-SHA256",
|
||||
// timestamp,
|
||||
// credentialScope,
|
||||
// crypto.createHash("sha256").update(canonicalRequest).digest("hex")
|
||||
// ].join("\n");
|
||||
//
|
||||
// // 5. 计算签名
|
||||
// const sign = (key: Buffer, msg: string) => crypto.createHmac("sha256", key).update(msg).digest();
|
||||
//
|
||||
// const kDate = sign(Buffer.from(`HMAC${config.secretKey}`, "utf8"), date);
|
||||
// const kRegion = sign(kDate, config.region);
|
||||
// const kService = sign(kRegion, config.service);
|
||||
// const kSigning = sign(kService, "request");
|
||||
// const signature = crypto.createHmac("sha256", kSigning)
|
||||
// .update(stringToSign)
|
||||
// .digest("hex");
|
||||
//
|
||||
// // 6. 构造请求头
|
||||
// const headers = {
|
||||
// "Content-Type": "application/json",
|
||||
// Host: new URL(config.endpoint).host,
|
||||
// "X-Date": timestamp,
|
||||
// Authorization: `HMAC-SHA256 Credential=${config.accessKeyId}/${credentialScope}, SignedHeaders=content-type;host, Signature=${signature}`
|
||||
// };
|
||||
//
|
||||
// return {
|
||||
// method,
|
||||
// url: `${config.endpoint}${path || ""}${sortedQuery ? `?${sortedQuery}` : ""}`,
|
||||
// headers,
|
||||
// data: body
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// async doRequest(req: VolcengineReq) {
|
||||
// const requestConfig = await this.createSignedRequest(req);
|
||||
// try {
|
||||
// const res = await this.opts.http.request(requestConfig);
|
||||
// if (res?.ResponseMetadata?.Error) {
|
||||
// throw new Error(JSON.stringify(res.ResponseMetadata.Error));
|
||||
// }
|
||||
// return res;
|
||||
// } catch (e) {
|
||||
// if (e?.response?.ResponseMetadata.Error) {
|
||||
// throw new Error(JSON.stringify(e.response.ResponseMetadata.Error));
|
||||
// }
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
async doRequest(req: VolcengineReq) {
|
||||
const {Signer} =await import('@volcengine/openapi') ;
|
||||
|
||||
// http request data
|
||||
const openApiRequestData: any = {
|
||||
region: req.region,
|
||||
method: req.method,
|
||||
// [optional] http request url query
|
||||
params: {
|
||||
...req.query,
|
||||
},
|
||||
// http request headers
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
// [optional] http request body
|
||||
body: req.body,
|
||||
}
|
||||
|
||||
const signer = new Signer(openApiRequestData, req.service);
|
||||
|
||||
// sign
|
||||
signer.addAuthorization({accessKeyId:this.opts.access.accessKeyId, secretKey:this.opts.access.secretAccessKey});
|
||||
|
||||
// Print signed headers
|
||||
console.log(openApiRequestData.headers);
|
||||
|
||||
|
||||
const url = `https://open.volcengineapi.com/?${querystring.stringify(req.query)}`
|
||||
const res = await http.request({
|
||||
url: url,
|
||||
method: req.method,
|
||||
headers: openApiRequestData.headers,
|
||||
data:req.body
|
||||
});
|
||||
|
||||
if (res?.ResponseMetadata?.Error) {
|
||||
throw new Error(JSON.stringify(res.ResponseMetadata.Error));
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
// 列出域名解析记录
|
||||
async findDomain(domain: string) {
|
||||
const req: VolcengineReq = {
|
||||
method: "POST",
|
||||
region: "cn-beijing",
|
||||
service: "dns",
|
||||
query: {
|
||||
Action: "ListZones",
|
||||
Version: "2018-08-01",
|
||||
},
|
||||
body:{
|
||||
Key: domain,
|
||||
SearchMode: "exact"
|
||||
}
|
||||
};
|
||||
|
||||
return this.doRequest(req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './plugins/index.js';
|
||||
export * from './access.js';
|
||||
export * from './volcengine-dns-provider.js';
|
||||
@@ -0,0 +1,93 @@
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
||||
import { Autowire } from "@certd/pipeline";
|
||||
|
||||
import { VolcengineClient } from "./client.js";
|
||||
import { VolcengineAccess } from "./access.js";
|
||||
|
||||
@IsDnsProvider({
|
||||
name: "volcengine",
|
||||
title: "火山引擎",
|
||||
desc: "火山引擎DNS解析提供商",
|
||||
accessType: "volcengine",
|
||||
icon: "svg:icon-volcengine"
|
||||
})
|
||||
export class VolcengineDnsProvider extends AbstractDnsProvider {
|
||||
client: VolcengineClient;
|
||||
@Autowire()
|
||||
access!: VolcengineAccess;
|
||||
|
||||
|
||||
async onInstance() {
|
||||
this.client = new VolcengineClient({
|
||||
access: this.access,
|
||||
logger: this.logger,
|
||||
http: this.http
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domain
|
||||
*/
|
||||
async getDomain(domain: string) {
|
||||
const res = await this.client.findDomain(domain)
|
||||
|
||||
if (res.Result.Zones && res.Result.Zones.length > 0) {
|
||||
return res.Result.Zones[0];
|
||||
}
|
||||
throw new Error(`域名${domain}不存在`);
|
||||
}
|
||||
|
||||
|
||||
async createRecord(options: CreateRecordOptions): Promise<any> {
|
||||
const { fullRecord, hostRecord, value, type, domain } = options;
|
||||
this.logger.info("添加域名解析:", fullRecord, value, domain);
|
||||
|
||||
const domainInfo = await this.getDomain(domain);
|
||||
const ZID = domainInfo.ZID;
|
||||
|
||||
const body = {
|
||||
ZID,
|
||||
"Host": hostRecord,
|
||||
"Type": type,
|
||||
"Value": value
|
||||
};
|
||||
|
||||
const res = await this.client.doRequest({
|
||||
method: "POST",
|
||||
service: "dns",
|
||||
region: "cn-beijing",
|
||||
query: {
|
||||
Action: "CreateRecord",
|
||||
Version: "2018-08-01"
|
||||
},
|
||||
body
|
||||
});
|
||||
|
||||
return {
|
||||
RecordID: res.Result.RecordID,
|
||||
ZID: ZID
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
async removeRecord(options: RemoveRecordOptions<any>): Promise<any> {
|
||||
const record = options.recordRes;
|
||||
|
||||
const body = {
|
||||
RecordID: record.RecordID
|
||||
};
|
||||
|
||||
await this.client.doRequest({
|
||||
method: "POST",
|
||||
service: "dns",
|
||||
region: "cn-beijing",
|
||||
query: {
|
||||
Action: "DeleteRecord",
|
||||
Version: "2018-08-01"
|
||||
},
|
||||
body
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
new VolcengineDnsProvider();
|
||||
Reference in New Issue
Block a user