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

Enable authorizeMonitorConnectionServer option #629

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions pkg/networkservice/chains/forwarder/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ import (
)

type forwarderOptions struct {
name string
authorizeServer networkservice.NetworkServiceServer
clientURL *url.URL
dialTimeout time.Duration
domain2Device map[string]string
statsOpts []stats.Option
cleanupOpts []cleanup.Option
vxlanOpts []vxlan.Option
dialOpts []grpc.DialOption
clientAdditionalFunctionality []networkservice.NetworkServiceClient
name string
authorizeServer networkservice.NetworkServiceServer
authorizeMonitorConnectionServer networkservice.MonitorConnectionServer
clientURL *url.URL
dialTimeout time.Duration
domain2Device map[string]string
statsOpts []stats.Option
cleanupOpts []cleanup.Option
vxlanOpts []vxlan.Option
dialOpts []grpc.DialOption
clientAdditionalFunctionality []networkservice.NetworkServiceClient
}

// Option is an option pattern for forwarder chain elements
Expand All @@ -65,6 +66,16 @@ func WithAuthorizeServer(authorizeServer networkservice.NetworkServiceServer) Op
}
}

// WithAuthorizeMonitorConnectionServer sets authorization server chain element
func WithAuthorizeMonitorConnectionServer(authorizeMonitorConnectionServer networkservice.MonitorConnectionServer) Option {
if authorizeMonitorConnectionServer == nil {
panic("Authorize monitor server cannot be nil")
}
return func(o *forwarderOptions) {
o.authorizeMonitorConnectionServer = authorizeMonitorConnectionServer
}
}

// WithClientURL sets clientURL.
func WithClientURL(clientURL *url.URL) Option {
return func(c *forwarderOptions) {
Expand Down
13 changes: 8 additions & 5 deletions pkg/networkservice/chains/forwarder/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanismtranslation"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin"
authmonitor "github.com/networkservicemesh/sdk/pkg/tools/monitorconnection/authorize"
"github.com/networkservicemesh/sdk/pkg/tools/token"

registryclient "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
Expand Down Expand Up @@ -79,11 +80,12 @@ type xconnectNSServer struct {
// NewServer - returns an implementation of the xconnectns network service
func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, vppConn Connection, tunnelIP net.IP, options ...Option) endpoint.Endpoint {
opts := &forwarderOptions{
name: "forwarder-vpp-" + uuid.New().String(),
authorizeServer: authorize.NewServer(authorize.Any()),
clientURL: &url.URL{Scheme: "unix", Host: "connect.to.socket"},
dialTimeout: time.Millisecond * 200,
domain2Device: make(map[string]string),
name: "forwarder-vpp-" + uuid.New().String(),
authorizeServer: authorize.NewServer(authorize.Any()),
authorizeMonitorConnectionServer: authmonitor.NewMonitorConnectionServer(authmonitor.Any()),
clientURL: &url.URL{Scheme: "unix", Host: "connect.to.socket"},
dialTimeout: time.Millisecond * 200,
domain2Device: make(map[string]string),
}
for _, opt := range options {
opt(opts)
Expand Down Expand Up @@ -161,6 +163,7 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, vppConn
rv.Endpoint = endpoint.NewServer(ctx, tokenGenerator,
endpoint.WithName(opts.name),
endpoint.WithAuthorizeServer(opts.authorizeServer),
endpoint.WithAuthorizeMonitorConnectionServer(opts.authorizeMonitorConnectionServer),
endpoint.WithAdditionalFunctionality(additionalFunctionality...))

return rv
Expand Down