mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	初步实现HTTP3
This commit is contained in:
		@@ -238,7 +238,8 @@ func (this *CreateAction) RunPost(params struct {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			sslPolicyIdResp, err := this.RPC().SSLPolicyRPC().CreateSSLPolicy(this.AdminContext(), &pb.CreateSSLPolicyRequest{
 | 
			
		||||
				Http2Enabled:      false,     // 默认值
 | 
			
		||||
				Http2Enabled:      false, // 默认值
 | 
			
		||||
				Http3Enabled:      false,
 | 
			
		||||
				MinVersion:        "TLS 1.1", // 默认值
 | 
			
		||||
				SslCertsJSON:      certRefsJSON,
 | 
			
		||||
				HstsJSON:          nil,
 | 
			
		||||
@@ -387,7 +388,7 @@ func (this *CreateAction) RunPost(params struct {
 | 
			
		||||
		AdminId:          this.AdminId(),
 | 
			
		||||
		Type:             params.ServerType,
 | 
			
		||||
		Name:             params.Name,
 | 
			
		||||
		ServerNamesJSON:   params.ServerNames,
 | 
			
		||||
		ServerNamesJSON:  params.ServerNames,
 | 
			
		||||
		Description:      params.Description,
 | 
			
		||||
		NodeClusterId:    clusterId,
 | 
			
		||||
		IncludeNodesJSON: includeNodesJSON,
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
		"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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user