初步实现HTTP3

This commit is contained in:
GoEdgeLab
2023-06-01 17:44:39 +08:00
parent c3b616c13e
commit b9d67d4ce6
5 changed files with 47 additions and 7 deletions

View File

@@ -239,6 +239,7 @@ func (this *CreateAction) RunPost(params struct {
sslPolicyIdResp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
Http2Enabled: false, // 默认值
Http3Enabled: false,
MinVersion: "TLS 1.1", // 默认值
SslCertsJSON: certRefsJSON,
HstsJSON: nil,

View File

@@ -6,6 +6,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
@@ -85,11 +86,34 @@ func (this *IndexAction) RunGet(params struct {
}
}
// 当前集群是否支持HTTP/3
// TODO 检查当前服务所属用户是否支持HTTP/3
if server.NodeCluster == nil {
this.ErrorPage(errors.New("no node cluster for the server"))
return
}
http3PolicyResp, err := this.RPC().NodeClusterRPC().FindNodeClusterHTTP3Policy(this.AdminContext(), &pb.FindNodeClusterHTTP3PolicyRequest{NodeClusterId: server.NodeCluster.Id})
if err != nil {
this.ErrorPage(err)
return
}
var supportsHTTP3 = false
if len(http3PolicyResp.Http3PolicyJSON) > 0 {
var http3Policy = nodeconfigs.NewHTTP3Policy()
err = json.Unmarshal(http3PolicyResp.Http3PolicyJSON, http3Policy)
if err != nil {
this.ErrorPage(err)
return
}
supportsHTTP3 = http3Policy.IsOn
}
this.Data["serverType"] = server.Type
this.Data["httpsConfig"] = maps.Map{
"isOn": httpsConfig.IsOn,
"addresses": httpsConfig.Listen,
"sslPolicy": sslPolicy,
"supportsHTTP3": supportsHTTP3,
}
this.Show()
@@ -175,6 +199,7 @@ func (this *IndexAction) RunPost(params struct {
_, err := this.RPC().SSLPolicyRPC().UpdateSSLPolicy(this.AdminContext(), &pb.UpdateSSLPolicyRequest{
SslPolicyId: sslPolicyId,
Http2Enabled: sslPolicy.HTTP2Enabled,
Http3Enabled: sslPolicy.HTTP3Enabled,
MinVersion: sslPolicy.MinVersion,
SslCertsJSON: certsJSON,
HstsJSON: hstsJSON,
@@ -191,6 +216,7 @@ func (this *IndexAction) RunPost(params struct {
} else {
resp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
Http2Enabled: sslPolicy.HTTP2Enabled,
Http3Enabled: sslPolicy.HTTP3Enabled,
MinVersion: sslPolicy.MinVersion,
SslCertsJSON: certsJSON,
HstsJSON: hstsJSON,

View File

@@ -128,6 +128,7 @@ func (this *IndexAction) RunPost(params struct {
_, err := this.RPC().SSLPolicyRPC().UpdateSSLPolicy(this.AdminContext(), &pb.UpdateSSLPolicyRequest{
SslPolicyId: sslPolicyId,
Http2Enabled: sslPolicy.HTTP2Enabled,
Http3Enabled: sslPolicy.HTTP3Enabled,
MinVersion: sslPolicy.MinVersion,
SslCertsJSON: certsJSON,
HstsJSON: hstsJSON,
@@ -144,6 +145,7 @@ func (this *IndexAction) RunPost(params struct {
} else {
resp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
Http2Enabled: sslPolicy.HTTP2Enabled,
Http3Enabled: sslPolicy.HTTP3Enabled,
MinVersion: sslPolicy.MinVersion,
SslCertsJSON: certsJSON,
HstsJSON: hstsJSON,

View File

@@ -2,7 +2,8 @@ Vue.component("ssl-config-box", {
props: [
"v-ssl-policy",
"v-protocol",
"v-server-id"
"v-server-id",
"v-support-http3"
],
created: function () {
let that = this
@@ -26,6 +27,7 @@ Vue.component("ssl-config-box", {
cipherSuitesIsOn: false,
cipherSuites: [],
http2Enabled: true,
http3Enabled: false,
ocspIsOn: false
}
} else {
@@ -403,6 +405,15 @@ Vue.component("ssl-config-box", {
</div>
</td>
</tr>
<tr v-show="vProtocol == 'https' && vSupportHttp3">
<td class="title">启用HTTP/3</td>
<td>
<div class="ui checkbox">
<input type="checkbox" value="1" v-model="policy.http3Enabled"/>
<label></label>
</div>
</td>
</tr>
<tr>
<td class="title">选择证书</td>
<td>

View File

@@ -36,7 +36,7 @@
</table>
<!-- SSL配置 -->
<ssl-config-box :v-ssl-policy="httpsConfig.sslPolicy" :v-protocol="'https'" v-show="httpsConfig.isOn" :v-server-id="serverId"></ssl-config-box>
<ssl-config-box :v-ssl-policy="httpsConfig.sslPolicy" :v-protocol="'https'" v-show="httpsConfig.isOn" :v-server-id="serverId" :v-support-http3="httpsConfig.supportsHTTP3"></ssl-config-box>
<submit-btn></submit-btn>
</form>