Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftr: add TLS support #685

Merged
merged 25 commits into from
Aug 14, 2020
Merged
1 change: 1 addition & 0 deletions common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
DUBBO_KEY = "dubbo"
RELEASE_KEY = "release"
ANYHOST_KEY = "anyhost"
SSL_ENABLED_KEY = "ssl-enabled"
)

const (
Expand Down
9 changes: 6 additions & 3 deletions config/consumer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

import (
"github.com/creasty/defaults"
"github.com/dubbogo/getty"
aliiohs marked this conversation as resolved.
Show resolved Hide resolved
perrors "github.com/pkg/errors"
)

Expand All @@ -34,6 +33,10 @@ import (
"github.com/apache/dubbo-go/common/yaml"
)

const (
MaxWheelTimeSpan = 900e9 // 900s, 15 minute
aliiohs marked this conversation as resolved.
Show resolved Hide resolved
)

/////////////////////////
// consumerConfig
/////////////////////////
Expand Down Expand Up @@ -107,9 +110,9 @@ func ConsumerInit(confConFile string) error {
if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil {
return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout)
}
if consumerConfig.RequestTimeout >= time.Duration(getty.MaxWheelTimeSpan) {
if consumerConfig.RequestTimeout >= time.Duration(MaxWheelTimeSpan) {
return perrors.WithMessagef(err, "request_timeout %s should be less than %s",
consumerConfig.Request_Timeout, time.Duration(getty.MaxWheelTimeSpan))
consumerConfig.Request_Timeout, time.Duration(MaxWheelTimeSpan))
}
}
if consumerConfig.Connect_Timeout != "" {
Expand Down
7 changes: 4 additions & 3 deletions config/protocol_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import (

// ProtocolConfig is protocol configuration
type ProtocolConfig struct {
Name string `required:"true" yaml:"name" json:"name,omitempty" property:"name"`
Ip string `required:"true" yaml:"ip" json:"ip,omitempty" property:"ip"`
Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"`
Name string `required:"true" yaml:"name" json:"name,omitempty" property:"name"`
Ip string `required:"true" yaml:"ip" json:"ip,omitempty" property:"ip"`
Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"`
SslEnabled bool `required:"false" yaml:"sslEnabled" json:"sslEnabled,omitempty" property:"sslEnabled"`
}

// nolint
Expand Down
1 change: 1 addition & 0 deletions config/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (c *ServiceConfig) Export() error {
common.WithPort(port),
common.WithParams(urlMap),
common.WithParamsValue(constant.BEAN_NAME_KEY, c.id),
common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(proto.SslEnabled)),
common.WithMethods(strings.Split(methods, ",")),
common.WithToken(c.Token),
)
Expand Down
43 changes: 43 additions & 0 deletions config/ssl_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package config

import (
"github.com/dubbogo/getty"
)

var (
serverTlsConfigBuilder getty.TlsConfigBuilder
clientTlsConfigBuilder getty.TlsConfigBuilder
)

func GetServerTlsConfigBuilder() getty.TlsConfigBuilder {
return serverTlsConfigBuilder
}

func GetClientTlsConfigBuilder() getty.TlsConfigBuilder {
return clientTlsConfigBuilder
}

func SetServerTlsConfigBuilder(configBuilder getty.TlsConfigBuilder) {
serverTlsConfigBuilder = configBuilder
}

func SetClientTlsConfigBuilder(configBuilder getty.TlsConfigBuilder) {
clientTlsConfigBuilder = configBuilder
}
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module github.com/apache/dubbo-go


require (
cloud.google.com/go v0.39.0 // indirect
github.com/Microsoft/go-winio v0.4.13 // indirect
Expand All @@ -13,7 +14,7 @@ require (
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/creasty/defaults v1.3.0
github.com/docker/go-connections v0.4.0 // indirect
github.com/dubbogo/getty v1.3.7
github.com/dubbogo/getty v1.3.8
github.com/dubbogo/go-zookeeper v1.0.1
github.com/dubbogo/gost v1.9.0
github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect
Expand All @@ -36,8 +37,6 @@ require (
github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff // indirect
github.com/hashicorp/vault/sdk v0.1.14-0.20191112033314-390e96e22eb2
github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect
github.com/magiconair/properties v1.8.1
github.com/mitchellh/hashstructure v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.2.3
Expand All @@ -58,12 +57,9 @@ require (
go.uber.org/zap v1.15.0
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 // indirect
google.golang.org/grpc v1.23.0
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.16.9
k8s.io/apimachinery v0.16.9
k8s.io/client-go v0.16.9
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect
)

go 1.13
Loading