ipc: Remove AnonymousPrinicipal from server side of VCs.
This is part one of a two part change to get rid of VC.anonymous principal.
This change makes the following changes:
(1) InternalNewServer requires principal argument
(2) StreamManager.Listen requires principal argument
(3) vif.InternalNewAcceptedVIf requires principal argument
(4) vc.HandshakeAcceptedVC requires a principal argument
(5) vc.LocalPrincipal is no longer a Server or VC Opt.
And some other various cleanups.
Up next: Do something similar for the Client side of the VC.
Change-Id: I7c766383a18589b49df0a3978ef501643862f2b8
diff --git a/profiles/internal/ipc/stream/manager/manager.go b/profiles/internal/ipc/stream/manager/manager.go
index b8e657a..e7c42e1 100644
--- a/profiles/internal/ipc/stream/manager/manager.go
+++ b/profiles/internal/ipc/stream/manager/manager.go
@@ -19,7 +19,6 @@
"v.io/x/ref/lib/stats"
"v.io/x/ref/profiles/internal/ipc/stream"
"v.io/x/ref/profiles/internal/ipc/stream/crypto"
- "v.io/x/ref/profiles/internal/ipc/stream/vc"
"v.io/x/ref/profiles/internal/ipc/stream/vif"
"v.io/x/ref/profiles/internal/ipc/version"
inaming "v.io/x/ref/profiles/internal/naming"
@@ -160,12 +159,12 @@
return nil, fmt.Errorf("unknown network %s", protocol)
}
-func (m *manager) Listen(protocol, address string, opts ...stream.ListenerOpt) (stream.Listener, naming.Endpoint, error) {
- blessings, err := extractBlessings(opts)
+func (m *manager) Listen(protocol, address string, principal security.Principal, opts ...stream.ListenerOpt) (stream.Listener, naming.Endpoint, error) {
+ blessings, err := extractBlessings(principal, opts)
if err != nil {
return nil, nil, err
}
- ln, ep, err := m.internalListen(protocol, address, opts...)
+ ln, ep, err := m.internalListen(protocol, address, principal, opts...)
if err != nil {
return nil, nil, err
}
@@ -173,7 +172,7 @@
return ln, ep, nil
}
-func (m *manager) internalListen(protocol, address string, opts ...stream.ListenerOpt) (stream.Listener, *inaming.Endpoint, error) {
+func (m *manager) internalListen(protocol, address string, principal security.Principal, opts ...stream.ListenerOpt) (stream.Listener, *inaming.Endpoint, error) {
m.muListeners.Lock()
if m.shutdown {
m.muListeners.Unlock()
@@ -187,7 +186,7 @@
if err != nil {
return nil, nil, fmt.Errorf("failed to parse endpoint %q: %v", address, err)
}
- return m.remoteListen(ep, opts)
+ return m.remoteListen(ep, principal, opts)
}
netln, err := listen(protocol, address)
if err != nil {
@@ -201,14 +200,14 @@
return nil, nil, errShutDown
}
- ln := newNetListener(m, netln, opts)
+ ln := newNetListener(m, netln, principal, opts)
m.listeners[ln] = true
m.muListeners.Unlock()
return ln, version.Endpoint(protocol, netln.Addr().String(), m.rid), nil
}
-func (m *manager) remoteListen(proxy naming.Endpoint, listenerOpts []stream.ListenerOpt) (stream.Listener, *inaming.Endpoint, error) {
- ln, ep, err := newProxyListener(m, proxy, listenerOpts)
+func (m *manager) remoteListen(proxy naming.Endpoint, principal security.Principal, listenerOpts []stream.ListenerOpt) (stream.Listener, *inaming.Endpoint, error) {
+ ln, ep, err := newProxyListener(m, proxy, principal, listenerOpts)
if err != nil {
return nil, nil, err
}
@@ -298,15 +297,10 @@
return strings.Join(l, "\n")
}
-func extractBlessings(opts []stream.ListenerOpt) ([]string, error) {
- var (
- p security.Principal
- b security.Blessings
- )
+func extractBlessings(p security.Principal, opts []stream.ListenerOpt) ([]string, error) {
+ var b security.Blessings
for _, o := range opts {
switch v := o.(type) {
- case vc.LocalPrincipal:
- p = v.Principal
case options.ServerBlessings:
b = v.Blessings
}