77 "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
88 "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
99 "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
10+ "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
1011 "github.com/iwind/TeaGo/actions"
1112 "github.com/iwind/TeaGo/maps"
1213 "github.com/iwind/TeaGo/types"
@@ -86,6 +87,12 @@ func (this *UpdatePopupAction) RunGet(params struct {
8687 config .Domains = []string {}
8788 }
8889
90+ // 重置数据
91+ if config .Cert != nil {
92+ config .Cert .CertData = nil
93+ config .Cert .KeyData = nil
94+ }
95+
8996 this .Data ["origin" ] = maps.Map {
9097 "id" : config .Id ,
9198 "protocol" : config .Addr .Protocol ,
@@ -99,6 +106,7 @@ func (this *UpdatePopupAction) RunGet(params struct {
99106 "idleTimeout" : idleTimeout ,
100107 "maxConns" : config .MaxConns ,
101108 "maxIdleConns" : config .MaxIdleConns ,
109+ "cert" : config .Cert ,
102110 "domains" : config .Domains ,
103111 }
104112
@@ -121,6 +129,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
121129 MaxIdleConns int32
122130 IdleTimeout int
123131
132+ CertIdsJSON []byte
124133 DomainsJSON []byte
125134
126135 Description string
@@ -188,6 +197,31 @@ func (this *UpdatePopupAction) RunPost(params struct {
188197 return
189198 }
190199
200+ // 证书
201+ var certIds = []int64 {}
202+ if len (params .CertIdsJSON ) > 0 {
203+ err = json .Unmarshal (params .CertIdsJSON , & certIds )
204+ if err != nil {
205+ this .ErrorPage (err )
206+ return
207+ }
208+ }
209+ var certRefJSON []byte
210+ if len (certIds ) > 0 {
211+ var certId = certIds [0 ]
212+ if certId > 0 {
213+ var certRef = & sslconfigs.SSLCertRef {
214+ IsOn : true ,
215+ CertId : certId ,
216+ }
217+ certRefJSON , err = json .Marshal (certRef )
218+ if err != nil {
219+ this .ErrorPage (err )
220+ return
221+ }
222+ }
223+ }
224+
191225 var domains = []string {}
192226 if len (params .DomainsJSON ) > 0 {
193227 err = json .Unmarshal (params .DomainsJSON , & domains )
@@ -218,6 +252,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
218252 IdleTimeoutJSON : idleTimeoutJSON ,
219253 MaxConns : params .MaxConns ,
220254 MaxIdleConns : params .MaxIdleConns ,
255+ CertRefJSON : certRefJSON ,
221256 Domains : domains ,
222257 })
223258 if err != nil {
0 commit comments