Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions backend/utils/ssl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ssl
import (
"crypto"
"encoding/json"
"github.com/go-acme/lego/v4/providers/dns/westcn"
"os"
"strings"
"time"
Expand Down Expand Up @@ -85,6 +86,7 @@ const (
TencentCloud DnsType = "TencentCloud"
HuaweiCloud DnsType = "HuaweiCloud"
RainYun DnsType = "RainYun"
WestCN DnsType = "WestCN"
)

type DNSParam struct {
Expand All @@ -103,6 +105,7 @@ type DNSParam struct {
AuthID string `json:"authID"`
SubAuthID string `json:"subAuthID"`
AuthPassword string `json:"authPassword"`
Username string `json:"username"`
}

var (
Expand Down Expand Up @@ -233,6 +236,14 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string, websiteSSL model.Web
rainyunConfig.PollingInterval = pollingInterval
rainyunConfig.TTL = ttl
p, err = rainyun.NewDNSProviderConfig(rainyunConfig)
case WestCN:
westcnConfig := westcn.NewDefaultConfig()
westcnConfig.Username = param.Username
westcnConfig.Password = param.Password
westcnConfig.PropagationTimeout = propagationTimeout
westcnConfig.PollingInterval = pollingInterval
westcnConfig.TTL = ttl
p, err = westcn.NewDNSProviderConfig(westcnConfig)
}
if err != nil {
return err
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code appears to be adding support for the West Cloud service provider, including configuring it using new parameters from the param struct. It adds methods to initialize a West Cloud-specific DNS provider with authentication details.

Here's an example of how you might use this function:

// Create a parameter object with necessary credentials and TTL value
params := &DNSParam{
    AuthID:       "your_auth_id",
    SubAuthID:    "your_sub_auth_id",
    AuthPassword: "your_password",
    Username:     "westcloud_username",  // New field required specifically for West Cloud
}

// Initialize AcmeClient and set DnsType to WestCN
acmeClient.UseDns(WestCN, json.Marshal(params).String(), model.WebsiteSSL)

// Wait for DNS records to propagate (optional)
time.Sleep(runningTime.Duration(time.Second))

This setup ensures that your Acme client can handle West Cloud specific requirements effectively after being initialized with proper configuration details.

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/global/mimetype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ export const DNSTypes = [
label: i18n.global.t('website.rainyun'),
value: 'RainYun',
},
{
label: i18n.global.t('website.westCN'),
value: 'WestCN',
},
];

export const Fields = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look mostly correct but there are a couple of suggestions for improvement:

  1. Spacing Consistency: Ensure consistent spacing around operators and curly braces to improve readability.

  2. Comments for New Entries: It's good practice to add comments explaining why you've added new entries if it enhances understanding or maintainability.

Here’s an optimized version with minor adjustments:

@@ -212,6 +212,10 @@
     label: i18n.global.t('website.rainyun'),
     value: 'RainYun',
 },

+// WestCN is another DNS service provider available.
+{
+    label: i18n.global.t('website.westCN'),
+    value: 'WestCN',
+},

These changes introduce clearer spacing and a brief comment in case someone reading the code later needs more context on the inclusion of WestCN as a DNS service provider.

Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,7 @@ const message = {
"When the reverse proxy backend is HTTPS, you might need to set the origin SNI. Please refer to the CDN service provider's documentation for details.",
huaweicloud: 'Huawei Cloud',
rainyun: 'Rain Yun',
westCN: 'West CN',
},
php: {
short_open_tag: 'Short tag support',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,8 @@ const message = {
sniHelper:
'逆プロキシバックエンドがHTTPSの場合、Origin SNIを設定する必要がある場合があります。詳細については、CDNサービスプロバイダーのドキュメントを参照してください。',
huaweicloud: 'huaweiCloud',
rainyun: 'Rain Yun',
westCN: 'West CN',
},
php: {
short_open_tag: '短いタグサポート',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,7 @@ const message = {
'역방향 프록시 백엔드가 HTTPS 인 경우 원본 SNI 를 설정해야 할 수 있습니다. 자세한 내용은 CDN 서비스 제공자의 문서를 참조하세요.',
huaweicloud: '화웨이 클라우드',
rainyun: '레인윤',
westCN: 'West CN',
},
php: {
short_open_tag: '짧은 태그 지원',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,7 @@ const message = {
'Apabila backend proksi terbalik adalah HTTPS, anda mungkin perlu menetapkan sumber SNI. Sila rujuk dokumentasi penyedia perkhidmatan CDN untuk butiran.',
huaweicloud: 'Huawei Cloud',
rainyun: 'Rain Yun',
westCN: 'West CN',
},
php: {
short_open_tag: 'Sokongan tag pendek',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,8 @@ const message = {
sniHelper:
'Quando o proxy reverso de backend for HTTPS, você pode precisar configurar o SNI de origem. Consulte a documentação do provedor de serviços CDN para mais detalhes.',
huaweicloud: 'Huawei Cloud',
rainyun: 'Rain Yun',
westCN: 'West CN',
},
php: {
short_open_tag: 'Suporte para short tags',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,7 @@ const message = {
'Когда бэкенд обратного прокси использует HTTPS, может потребоваться установить origin SNI. Подробности см. в документации провайдера CDN.',
huaweicloud: 'Huawei Cloud',
rainyun: 'Rain Yun',
westCN: 'West CN',
},
php: {
short_open_tag: 'Поддержка коротких тегов',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,7 @@ const message = {
sniHelper: '反代後端為 https 的時候可能需要設定回源 SNI,具體需要看 CDN 服務商文件',
huaweicloud: '華為雲',
rainyun: '雨雲',
westCN: '西部數據',
},
php: {
short_open_tag: '短標籤支援',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,7 @@ const message = {
sniHelper: '反代后端为 https 的时候可能需要设置回源 SNI,具体需要看 CDN 服务商文档',
huaweicloud: '华为云',
rainyun: '雨云',
westCN: '西部数码',
},
php: {
short_open_tag: '短标签支持',
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/views/website/ssl/dns-account/create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@
<el-input v-model.trim="account.authorization['token']"></el-input>
</el-form-item>
</div>
<div v-if="account.type === 'WestCN'">
<el-form-item label="Username" prop="authorization.username">
<el-input v-model.trim="account.authorization['username']"></el-input>
</el-form-item>
<el-form-item label="Password" prop="authorization.password">
<el-input v-model.trim="account.authorization['password']"></el-input>
</el-form-item>
</div>
</el-form>
</el-col>
</el-row>
Expand Down Expand Up @@ -181,6 +189,7 @@ const rules = ref<any>({
email: [Rules.email],
password: [Rules.requiredInput],
authPassword: [Rules.requiredInput],
username: [Rules.requiredInput],
},
});
const account = ref({
Expand Down Expand Up @@ -230,7 +239,7 @@ const submit = async (formEl: FormInstance | undefined) => {
return;
}
if (account.value.type === 'ClouDNS') {
if (!account.value.authorization.authID && !account.value.authorization.subAuthID) {
if (!account.value.authorization['authID'] && !account.value.authorization['subAuthID']) {
MsgError('Please input Auth ID or Sub Auth ID');
return;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code changes look generally consistent with the intended functionality. Here are some observations:

  1. New Conditional Formatting for WestCN Type:

    • A new <div> block is conditionally rendered when account.type equals 'WestCN'.
    • This includes two additional form fields:
      • One field labeled "Username"
      • One field labeled "Password"
    • These fields use v-model to bind their values to account.authorization['username'] and account.authorization['password'], respectively.

    The addition of these fields aligns with adding support for WestCN-specific authentication requirements.

  2. Validation Rules Update (Line 230):

    • There's an updated validation rule for rules.account. Specifically, it added a rule for Rules.username, allowing users to enter a username.
    • This update ensures that all necessary forms meet proper user input validity checks across different account types.

These changes improve the application's flexibility by handling different authentication methods based on customer type (WestCN) while maintaining consistency in data binding and validation logic.

Overall, the changes seem well-planned and should work smoothly without major issues when implemented.

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ require (
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/nrdcg/dnspod-go v0.4.0 // indirect
github.com/nrdcg/freemyip v0.3.0 // indirect
github.com/nrdcg/mailinabox v0.2.0 // indirect
github.com/nrdcg/namesilo v0.2.1 // indirect
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,8 @@ github.com/nrdcg/dnspod-go v0.4.0 h1:c/jn1mLZNKF3/osJ6mz3QPxTudvPArXTjpkmYj0uK6U
github.com/nrdcg/dnspod-go v0.4.0/go.mod h1:vZSoFSFeQVm2gWLMkyX61LZ8HI3BaqtHZWgPTGKr6KQ=
github.com/nrdcg/freemyip v0.3.0 h1:0D2rXgvLwe2RRaVIjyUcQ4S26+cIS2iFwnhzDsEuuwc=
github.com/nrdcg/freemyip v0.3.0/go.mod h1:c1PscDvA0ukBF0dwelU/IwOakNKnVxetpAQ863RMJoM=
github.com/nrdcg/mailinabox v0.2.0 h1:IKq8mfKiVwNW2hQii/ng1dJ4yYMMv3HAP3fMFIq2CFk=
github.com/nrdcg/mailinabox v0.2.0/go.mod h1:0yxqeYOiGyxAu7Sb94eMxHPIOsPYXAjTeA9ZhePhGnc=
github.com/nrdcg/namesilo v0.2.1 h1:kLjCjsufdW/IlC+iSfAqj0iQGgKjlbUUeDJio5Y6eMg=
github.com/nrdcg/namesilo v0.2.1/go.mod h1:lwMvfQTyYq+BbjJd30ylEG4GPSS6PII0Tia4rRpRiyw=
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 h1:e3mzJFJs4k83GXBEiTaQ5HgSc/kOK8q0rDaRO0MPaOk=
Expand Down
Loading