Skip to content

Commit

Permalink
Add grpcfd.TransportCredentials()
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Nov 6, 2020
1 parent 196a358 commit 437a222
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 13 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.15

require (
github.com/antonfisher/nested-logrus-formatter v1.3.0
github.com/edwarnicke/grpcfd v0.0.0-20200920223154-d5b6e1f19bd0
github.com/edwarnicke/serialize v1.0.4
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v0.0.0-20201026112722-9b20186587a5
Expand Down
25 changes: 25 additions & 0 deletions internal/manager/grpcfd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed 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.

//+build !linux

package manager

import "google.golang.org/grpc/credentials"

func grpcfdTransportCredentials(cred credentials.TransportCredentials) credentials.TransportCredentials {
return cred
}
26 changes: 26 additions & 0 deletions internal/manager/grpcfd_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed 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 manager

import (
"github.com/edwarnicke/grpcfd"
"google.golang.org/grpc/credentials"
)

func grpcfdTransportCredentials(cred credentials.TransportCredentials) credentials.TransportCredentials {
return grpcfd.TransportCredentials(cred)
}
25 changes: 16 additions & 9 deletions internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ import (
"sync"
"time"

"github.com/networkservicemesh/cmd-nsmgr/internal/authz"
"github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize"
"github.com/networkservicemesh/sdk/pkg/tools/callback"
"github.com/networkservicemesh/sdk/pkg/tools/grpcutils"

"github.com/sirupsen/logrus"
"github.com/spiffe/go-spiffe/v2/spiffetls/tlsconfig"
"github.com/spiffe/go-spiffe/v2/svid/x509svid"
Expand All @@ -38,10 +32,16 @@ import (
"google.golang.org/grpc/credentials"

"github.com/networkservicemesh/api/pkg/api/registry"
"github.com/networkservicemesh/cmd-nsmgr/internal/config"
"github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/authorize"
"github.com/networkservicemesh/sdk/pkg/tools/callback"
"github.com/networkservicemesh/sdk/pkg/tools/grpcutils"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/spanhelper"
"github.com/networkservicemesh/sdk/pkg/tools/spiffejwt"

"github.com/networkservicemesh/cmd-nsmgr/internal/authz"
"github.com/networkservicemesh/cmd-nsmgr/internal/config"
)

const (
Expand Down Expand Up @@ -122,13 +122,20 @@ func RunNsmgr(ctx context.Context, configuration *config.Config) error {
regConn, callbackServer.WithCallbackDialer(),

// Default client security call options
grpc.WithTransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(m.source, m.source, tlsconfig.AuthorizeAny()))),
grpc.WithTransportCredentials(
grpcfdTransportCredentials(
credentials.NewTLS(tlsconfig.MTLSClientConfig(m.source, m.source, tlsconfig.AuthorizeAny())),
),
),
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)))

// If we Listen on Unix socket for local connections we need to be sure folder are exist
createListenFolders(configuration)

m.server = grpc.NewServer(grpc.Creds(credentials.NewTLS(tlsconfig.MTLSServerConfig(m.source, m.source, tlsconfig.AuthorizeAny()))))
m.server = grpc.NewServer(grpc.Creds(
grpcfdTransportCredentials(
credentials.NewTLS(tlsconfig.MTLSServerConfig(m.source, m.source, tlsconfig.AuthorizeAny()))),
))
m.mgr.Register(m.server)

// Register callback serve to grpc.
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import (
"context"
"os"

"github.com/networkservicemesh/sdk/pkg/tools/debug"

nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/kelseyhightower/envconfig"
"github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus"

"github.com/networkservicemesh/cmd-nsmgr/internal/config"
"github.com/networkservicemesh/cmd-nsmgr/internal/manager"
"github.com/networkservicemesh/sdk/pkg/tools/debug"
"github.com/networkservicemesh/sdk/pkg/tools/jaeger"
"github.com/networkservicemesh/sdk/pkg/tools/log"
"github.com/networkservicemesh/sdk/pkg/tools/signalctx"
"github.com/networkservicemesh/sdk/pkg/tools/spanhelper"

"github.com/networkservicemesh/cmd-nsmgr/internal/config"
"github.com/networkservicemesh/cmd-nsmgr/internal/manager"
)

func main() {
Expand Down

0 comments on commit 437a222

Please sign in to comment.