优化检查端口是否已被使用API

This commit is contained in:
刘祥超
2021-11-24 19:47:48 +08:00
parent ccb326603c
commit 12a2dde2e6
4 changed files with 56 additions and 22 deletions

View File

@@ -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)
}