初步实现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

@@ -238,7 +238,8 @@ func (this *CreateAction) RunPost(params struct {
} }
sslPolicyIdResp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{ sslPolicyIdResp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
Http2Enabled: false, // 默认值 Http2Enabled: false, // 默认值
Http3Enabled: false,
MinVersion: "TLS 1.1", // 默认值 MinVersion: "TLS 1.1", // 默认值
SslCertsJSON: certRefsJSON, SslCertsJSON: certRefsJSON,
HstsJSON: nil, HstsJSON: nil,
@@ -387,7 +388,7 @@ func (this *CreateAction) RunPost(params struct {
AdminId: this.AdminId(), AdminId: this.AdminId(),
Type: params.ServerType, Type: params.ServerType,
Name: params.Name, Name: params.Name,
ServerNamesJSON: params.ServerNames, ServerNamesJSON: params.ServerNames,
Description: params.Description, Description: params.Description,
NodeClusterId: clusterId, NodeClusterId: clusterId,
IncludeNodesJSON: includeNodesJSON, IncludeNodesJSON: includeNodesJSON,

View File

@@ -6,6 +6,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs" "github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/serverutils" "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/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs" "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["serverType"] = server.Type
this.Data["httpsConfig"] = maps.Map{ this.Data["httpsConfig"] = maps.Map{
"isOn": httpsConfig.IsOn, "isOn": httpsConfig.IsOn,
"addresses": httpsConfig.Listen, "addresses": httpsConfig.Listen,
"sslPolicy": sslPolicy, "sslPolicy": sslPolicy,
"supportsHTTP3": supportsHTTP3,
} }
this.Show() this.Show()
@@ -175,6 +199,7 @@ func (this *IndexAction) RunPost(params struct {
_, err := this.RPC().SSLPolicyRPC().UpdateSSLPolicy(this.AdminContext(), &pb.UpdateSSLPolicyRequest{ _, err := this.RPC().SSLPolicyRPC().UpdateSSLPolicy(this.AdminContext(), &pb.UpdateSSLPolicyRequest{
SslPolicyId: sslPolicyId, SslPolicyId: sslPolicyId,
Http2Enabled: sslPolicy.HTTP2Enabled, Http2Enabled: sslPolicy.HTTP2Enabled,
Http3Enabled: sslPolicy.HTTP3Enabled,
MinVersion: sslPolicy.MinVersion, MinVersion: sslPolicy.MinVersion,
SslCertsJSON: certsJSON, SslCertsJSON: certsJSON,
HstsJSON: hstsJSON, HstsJSON: hstsJSON,
@@ -191,6 +216,7 @@ func (this *IndexAction) RunPost(params struct {
} else { } else {
resp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{ resp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
Http2Enabled: sslPolicy.HTTP2Enabled, Http2Enabled: sslPolicy.HTTP2Enabled,
Http3Enabled: sslPolicy.HTTP3Enabled,
MinVersion: sslPolicy.MinVersion, MinVersion: sslPolicy.MinVersion,
SslCertsJSON: certsJSON, SslCertsJSON: certsJSON,
HstsJSON: hstsJSON, HstsJSON: hstsJSON,

View File

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

View File

@@ -2,7 +2,8 @@ Vue.component("ssl-config-box", {
props: [ props: [
"v-ssl-policy", "v-ssl-policy",
"v-protocol", "v-protocol",
"v-server-id" "v-server-id",
"v-support-http3"
], ],
created: function () { created: function () {
let that = this let that = this
@@ -26,6 +27,7 @@ Vue.component("ssl-config-box", {
cipherSuitesIsOn: false, cipherSuitesIsOn: false,
cipherSuites: [], cipherSuites: [],
http2Enabled: true, http2Enabled: true,
http3Enabled: false,
ocspIsOn: false ocspIsOn: false
} }
} else { } else {
@@ -403,6 +405,15 @@ Vue.component("ssl-config-box", {
</div> </div>
</td> </td>
</tr> </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> <tr>
<td class="title">选择证书</td> <td class="title">选择证书</td>
<td> <td>

View File

@@ -36,7 +36,7 @@
</table> </table>
<!-- SSL配置 --> <!-- 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> <submit-btn></submit-btn>
</form> </form>