mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 04:10:25 +08:00
优化检查端口是否已被使用API
This commit is contained in:
@@ -2498,7 +2498,8 @@ type FindFreePortInNodeClusterRequest struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
NodeClusterId int64 `protobuf:"varint,1,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"`
|
||||
NodeClusterId int64 `protobuf:"varint,1,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"`
|
||||
ProtocolFamily string `protobuf:"bytes,2,opt,name=protocolFamily,proto3" json:"protocolFamily,omitempty"`
|
||||
}
|
||||
|
||||
func (x *FindFreePortInNodeClusterRequest) Reset() {
|
||||
@@ -2540,6 +2541,13 @@ func (x *FindFreePortInNodeClusterRequest) GetNodeClusterId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *FindFreePortInNodeClusterRequest) GetProtocolFamily() string {
|
||||
if x != nil {
|
||||
return x.ProtocolFamily
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type FindFreePortInNodeClusterResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -2597,6 +2605,7 @@ type CheckPortIsUsingInNodeClusterRequest struct {
|
||||
NodeClusterId int64 `protobuf:"varint,2,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"`
|
||||
ExcludeServerId int64 `protobuf:"varint,3,opt,name=excludeServerId,proto3" json:"excludeServerId,omitempty"`
|
||||
ExcludeProtocol string `protobuf:"bytes,4,opt,name=excludeProtocol,proto3" json:"excludeProtocol,omitempty"`
|
||||
ProtocolFamily string `protobuf:"bytes,5,opt,name=protocolFamily,proto3" json:"protocolFamily,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CheckPortIsUsingInNodeClusterRequest) Reset() {
|
||||
@@ -2659,6 +2668,13 @@ func (x *CheckPortIsUsingInNodeClusterRequest) GetExcludeProtocol() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CheckPortIsUsingInNodeClusterRequest) GetProtocolFamily() string {
|
||||
if x != nil {
|
||||
return x.ProtocolFamily
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CheckPortIsUsingInNodeClusterResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -3347,26 +3363,31 @@ var file_service_node_cluster_proto_rawDesc = []byte{
|
||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x22,
|
||||
0x48, 0x0a, 0x20, 0x46, 0x69, 0x6e, 0x64, 0x46, 0x72, 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x49,
|
||||
0x70, 0x0a, 0x20, 0x46, 0x69, 0x6e, 0x64, 0x46, 0x72, 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x49,
|
||||
0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74,
|
||||
0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65,
|
||||
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x21, 0x46, 0x69, 0x6e,
|
||||
0x64, 0x46, 0x72, 0x65, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x49, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x43,
|
||||
0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f,
|
||||
0x72, 0x74, 0x22, 0xb4, 0x01, 0x0a, 0x24, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x72, 0x74,
|
||||
0x49, 0x73, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75,
|
||||
0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70,
|
||||
0x6f, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12,
|
||||
0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73,
|
||||
0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65,
|
||||
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f,
|
||||
0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12,
|
||||
0x28, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63,
|
||||
0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64,
|
||||
0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x41, 0x0a, 0x25, 0x43, 0x68, 0x65,
|
||||
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x46, 0x61, 0x6d, 0x69, 0x6c,
|
||||
0x79, 0x22, 0x37, 0x0a, 0x21, 0x46, 0x69, 0x6e, 0x64, 0x46, 0x72, 0x65, 0x65, 0x50, 0x6f, 0x72,
|
||||
0x74, 0x49, 0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xdc, 0x01, 0x0a, 0x24, 0x43,
|
||||
0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x72, 0x74, 0x49, 0x73, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x49,
|
||||
0x6e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43,
|
||||
0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d,
|
||||
0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x28, 0x0a,
|
||||
0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75,
|
||||
0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0f, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f,
|
||||
0x6c, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x46, 0x61, 0x6d,
|
||||
0x69, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x63, 0x6f, 0x6c, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x22, 0x41, 0x0a, 0x25, 0x43, 0x68, 0x65,
|
||||
0x63, 0x6b, 0x50, 0x6f, 0x72, 0x74, 0x49, 0x73, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x4e,
|
||||
0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20,
|
||||
|
||||
@@ -374,6 +374,7 @@ message FindNodeClusterSystemServiceResponse {
|
||||
// 获取集群中可以使用的端口
|
||||
message FindFreePortInNodeClusterRequest {
|
||||
int64 nodeClusterId = 1;
|
||||
string protocolFamily = 2;
|
||||
}
|
||||
|
||||
message FindFreePortInNodeClusterResponse {
|
||||
@@ -386,6 +387,7 @@ message CheckPortIsUsingInNodeClusterRequest {
|
||||
int64 nodeClusterId = 2;
|
||||
int64 excludeServerId = 3;
|
||||
string excludeProtocol = 4;
|
||||
string protocolFamily = 5;
|
||||
}
|
||||
|
||||
message CheckPortIsUsingInNodeClusterResponse {
|
||||
|
||||
@@ -16,7 +16,7 @@ func NewTLSProtocolConfigFromJSON(configJSON []byte) (*TLSProtocolConfig, error)
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// TLS协议配置
|
||||
// TLSProtocolConfig TLS协议配置
|
||||
type TLSProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
|
||||
@@ -24,7 +24,7 @@ type TLSProtocolConfig struct {
|
||||
SSLPolicy *sslconfigs.SSLPolicy `yaml:"sslPolicy" json:"sslPolicy"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
// Init 初始化
|
||||
func (this *TLSProtocolConfig) Init() error {
|
||||
err := this.InitBase()
|
||||
if err != nil {
|
||||
@@ -41,7 +41,7 @@ func (this *TLSProtocolConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
// AsJSON 转换为JSON
|
||||
func (this *TLSProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,17 @@ package serverconfigs
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func NewUDPProtocolConfigFromJSON(configJSON []byte) (*UDPProtocolConfig, error) {
|
||||
config := &UDPProtocolConfig{}
|
||||
if len(configJSON) > 0 {
|
||||
err := json.Unmarshal(configJSON, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
type UDPProtocolConfig struct {
|
||||
BaseProtocol `yaml:",inline"`
|
||||
}
|
||||
@@ -15,7 +26,7 @@ func (this *UDPProtocolConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
// AsJSON 转换为JSON
|
||||
func (this *UDPProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user