mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-05-08 20:41:20 +02:00
fix deprecated functions
This commit is contained in:
parent
be0ec7bc2f
commit
13b9a52f80
|
@ -51,7 +51,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func startGenerateMetadata() {
|
func startGenerateMetadata() {
|
||||||
pb.WithFilerClient(false, pb.ServerAddress(*tailFiler), grpc.WithInsecure(), func(client filer_pb.SeaweedFilerClient) error {
|
pb.WithFilerClient(false, pb.ServerAddress(*tailFiler), grpc.WithTransportCredentials(insecure.NewCredentials()), func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
for i := 0; i < *n; i++ {
|
for i := 0; i < *n; i++ {
|
||||||
name := fmt.Sprintf("file%d", i)
|
name := fmt.Sprintf("file%d", i)
|
||||||
|
@ -77,7 +77,7 @@ func startGenerateMetadata() {
|
||||||
|
|
||||||
func startSubscribeMetadata(eachEntryFunc func(event *filer_pb.SubscribeMetadataResponse) error) {
|
func startSubscribeMetadata(eachEntryFunc func(event *filer_pb.SubscribeMetadataResponse) error) {
|
||||||
|
|
||||||
tailErr := pb.FollowMetadata(pb.ServerAddress(*tailFiler), grpc.WithInsecure(), "tail", 0, 0, *dir, nil, 0, 0, 0, eachEntryFunc, pb.TrivialOnError)
|
tailErr := pb.FollowMetadata(pb.ServerAddress(*tailFiler), grpc.WithTransportCredentials(insecure.NewCredentials()), "tail", 0, 0, *dir, nil, 0, 0, 0, eachEntryFunc, pb.TrivialOnError)
|
||||||
|
|
||||||
if tailErr != nil {
|
if tailErr != nil {
|
||||||
fmt.Printf("tail %s: %v\n", *tailFiler, tailErr)
|
fmt.Printf("tail %s: %v\n", *tailFiler, tailErr)
|
||||||
|
|
|
@ -70,7 +70,7 @@ func GrpcDial(ctx context.Context, address string, opts ...grpc.DialOption) (*gr
|
||||||
// opts = append(opts, grpc.WithTimeout(time.Duration(5*time.Second)))
|
// opts = append(opts, grpc.WithTimeout(time.Duration(5*time.Second)))
|
||||||
var options []grpc.DialOption
|
var options []grpc.DialOption
|
||||||
options = append(options,
|
options = append(options,
|
||||||
// grpc.WithInsecure(),
|
// grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||||
grpc.WithDefaultCallOptions(
|
grpc.WithDefaultCallOptions(
|
||||||
grpc.MaxCallSendMsgSize(Max_Message_Size),
|
grpc.MaxCallSendMsgSize(Max_Message_Size),
|
||||||
grpc.MaxCallRecvMsgSize(Max_Message_Size),
|
grpc.MaxCallRecvMsgSize(Max_Message_Size),
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
"google.golang.org/grpc/credentials/tls/certprovider/pemfile"
|
"google.golang.org/grpc/credentials/tls/certprovider/pemfile"
|
||||||
"google.golang.org/grpc/security/advancedtls"
|
"google.golang.org/grpc/security/advancedtls"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -87,12 +88,12 @@ func LoadServerTLS(config *util.ViperProxy, component string) (grpc.ServerOption
|
||||||
|
|
||||||
func LoadClientTLS(config *util.ViperProxy, component string) grpc.DialOption {
|
func LoadClientTLS(config *util.ViperProxy, component string) grpc.DialOption {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return grpc.WithInsecure()
|
return grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||||
}
|
}
|
||||||
|
|
||||||
certFileName, keyFileName, caFileName := config.GetString(component+".cert"), config.GetString(component+".key"), config.GetString("grpc.ca")
|
certFileName, keyFileName, caFileName := config.GetString(component+".cert"), config.GetString(component+".key"), config.GetString("grpc.ca")
|
||||||
if certFileName == "" || keyFileName == "" || caFileName == "" {
|
if certFileName == "" || keyFileName == "" || caFileName == "" {
|
||||||
return grpc.WithInsecure()
|
return grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||||
}
|
}
|
||||||
|
|
||||||
clientOptions := pemfile.Options{
|
clientOptions := pemfile.Options{
|
||||||
|
@ -103,7 +104,7 @@ func LoadClientTLS(config *util.ViperProxy, component string) grpc.DialOption {
|
||||||
clientProvider, err := pemfile.NewProvider(clientOptions)
|
clientProvider, err := pemfile.NewProvider(clientOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("pemfile.NewProvider(%v) failed %v", clientOptions, err)
|
glog.Warningf("pemfile.NewProvider(%v) failed %v", clientOptions, err)
|
||||||
return grpc.WithInsecure()
|
return grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||||
}
|
}
|
||||||
clientRootOptions := pemfile.Options{
|
clientRootOptions := pemfile.Options{
|
||||||
RootFile: config.GetString("grpc.ca"),
|
RootFile: config.GetString("grpc.ca"),
|
||||||
|
@ -112,7 +113,7 @@ func LoadClientTLS(config *util.ViperProxy, component string) grpc.DialOption {
|
||||||
clientRootProvider, err := pemfile.NewProvider(clientRootOptions)
|
clientRootProvider, err := pemfile.NewProvider(clientRootOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("pemfile.NewProvider(%v) failed: %v", clientRootOptions, err)
|
glog.Warningf("pemfile.NewProvider(%v) failed: %v", clientRootOptions, err)
|
||||||
return grpc.WithInsecure()
|
return grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||||
}
|
}
|
||||||
options := &advancedtls.ClientOptions{
|
options := &advancedtls.ClientOptions{
|
||||||
IdentityOptions: advancedtls.IdentityCertificateOptions{
|
IdentityOptions: advancedtls.IdentityCertificateOptions{
|
||||||
|
@ -129,7 +130,7 @@ func LoadClientTLS(config *util.ViperProxy, component string) grpc.DialOption {
|
||||||
ta, err := advancedtls.NewClientCreds(options)
|
ta, err := advancedtls.NewClientCreds(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("advancedtls.NewClientCreds(%v) failed: %v", options, err)
|
glog.Warningf("advancedtls.NewClientCreds(%v) failed: %v", options, err)
|
||||||
return grpc.WithInsecure()
|
return grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||||
}
|
}
|
||||||
return grpc.WithTransportCredentials(ta)
|
return grpc.WithTransportCredentials(ta)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue