ref: Remove support for API versions <9 and endpoint versions < 5.
This removes version numbers from endpoints entirely
which changes the public API.
MultiPart: 2/3
Change-Id: I7f78136c9e8370afecf34ed779949dd707b61e2e
diff --git a/profiles/internal/naming/endpoint.go b/profiles/internal/naming/endpoint.go
index e38f3cf..74b1b2b 100644
--- a/profiles/internal/naming/endpoint.go
+++ b/profiles/internal/naming/endpoint.go
@@ -13,7 +13,6 @@
"strings"
"v.io/v23/naming"
- "v.io/v23/rpc/version"
)
const (
@@ -33,14 +32,12 @@
// Endpoint is a naming.Endpoint implementation used to convey RPC information.
type Endpoint struct {
- Protocol string
- Address string
- RID naming.RoutingID
- MinRPCVersion version.RPCVersion
- MaxRPCVersion version.RPCVersion
- Blessings []string
- IsMountTable bool
- IsLeaf bool
+ Protocol string
+ Address string
+ RID naming.RoutingID
+ Blessings []string
+ IsMountTable bool
+ IsLeaf bool
}
// NewEndpoint creates a new endpoint from a string as per naming.NewEndpoint
@@ -69,14 +66,6 @@
}
switch version {
- case 1:
- err = ep.parseV1(parts)
- case 2:
- err = ep.parseV2(parts)
- case 3:
- err = ep.parseV3(parts)
- case 4:
- err = ep.parseV4(parts)
case 5:
err = ep.parseV5(parts)
default:
@@ -99,46 +88,6 @@
return nil
}
-func (ep *Endpoint) parseV1(parts []string) error {
- if len(parts) != 4 {
- return errInvalidEndpointString
- }
-
- ep.Protocol = parts[1]
- if len(ep.Protocol) == 0 {
- ep.Protocol = naming.UnknownProtocol
- }
-
- ep.Address = parts[2]
- if len(ep.Address) == 0 {
- ep.Address = net.JoinHostPort("", "0")
- }
-
- if err := ep.RID.FromString(parts[3]); err != nil {
- return fmt.Errorf("invalid routing id: %v", err)
- }
-
- return nil
-}
-
-func parseRPCVersion(input string) (version.RPCVersion, error) {
- if input == "" {
- return version.UnknownRPCVersion, nil
- }
- v, err := strconv.ParseUint(input, 10, 32)
- if err != nil {
- err = fmt.Errorf("invalid RPC version: %s, %v", input, err)
- }
- return version.RPCVersion(v), err
-}
-
-func printRPCVersion(v version.RPCVersion) string {
- if v == version.UnknownRPCVersion {
- return ""
- }
- return strconv.FormatUint(uint64(v), 10)
-}
-
func parseMountTableFlag(input string) (bool, bool, error) {
switch len(input) {
case 0:
@@ -158,59 +107,26 @@
return false, false, fmt.Errorf("flag is either missing or too long")
}
-func (ep *Endpoint) parseV2(parts []string) error {
- var err error
- if len(parts) != 6 {
- return errInvalidEndpointString
- }
- if err = ep.parseV1(parts[:4]); err != nil {
- return err
- }
- if ep.MinRPCVersion, err = parseRPCVersion(parts[4]); err != nil {
- return fmt.Errorf("invalid RPC version: %v", err)
- }
- if ep.MaxRPCVersion, err = parseRPCVersion(parts[5]); err != nil {
- return fmt.Errorf("invalid RPC version: %v", err)
- }
- return nil
-}
-
-func (ep *Endpoint) parseV3(parts []string) error {
- var err error
- if len(parts) != 7 {
- return errInvalidEndpointString
- }
- if err = ep.parseV2(parts[:6]); err != nil {
- return err
- }
- if ep.IsMountTable, ep.IsLeaf, err = parseMountTableFlag(parts[6]); err != nil {
- return fmt.Errorf("invalid mount table flag: %v", err)
- }
- return nil
-}
-
-func (ep *Endpoint) parseV4(parts []string) error {
- if len(parts) < 7 {
- return errInvalidEndpointString
- }
- if err := ep.parseV3(parts[:7]); err != nil {
- return err
- }
- // Join the remaining and re-split.
- if str := strings.Join(parts[7:], separator); len(str) > 0 {
- ep.Blessings = strings.Split(str, blessingsSeparator)
- }
- return nil
-}
-
func (ep *Endpoint) parseV5(parts []string) error {
if len(parts) < 5 {
return errInvalidEndpointString
}
- var err error
- if err = ep.parseV1(parts[:4]); err != nil {
- return err
+
+ ep.Protocol = parts[1]
+ if len(ep.Protocol) == 0 {
+ ep.Protocol = naming.UnknownProtocol
}
+
+ ep.Address = parts[2]
+ if len(ep.Address) == 0 {
+ ep.Address = net.JoinHostPort("", "0")
+ }
+
+ if err := ep.RID.FromString(parts[3]); err != nil {
+ return fmt.Errorf("invalid routing id: %v", err)
+ }
+
+ var err error
if ep.IsMountTable, ep.IsLeaf, err = parseMountTableFlag(parts[4]); err != nil {
return fmt.Errorf("invalid mount table flag: %v", err)
}
@@ -218,8 +134,6 @@
if str := strings.Join(parts[5:], separator); len(str) > 0 {
ep.Blessings = strings.Split(str, blessingsSeparator)
}
- ep.MinRPCVersion = version.DeprecatedRPCVersion
- ep.MaxRPCVersion = version.DeprecatedRPCVersion
return nil
}
@@ -238,34 +152,6 @@
switch version {
default:
return ep.VersionedString(defaultVersion)
- case 1:
- return fmt.Sprintf("@1@%s@%s@@", ep.Protocol, ep.Address)
- case 2:
- return fmt.Sprintf("@2@%s@%s@%s@%s@%s@@",
- ep.Protocol, ep.Address, ep.RID,
- printRPCVersion(ep.MinRPCVersion), printRPCVersion(ep.MaxRPCVersion))
- case 3:
- mt := "s"
- if ep.IsMountTable {
- mt = "m"
- }
- return fmt.Sprintf("@3@%s@%s@%s@%s@%s@%s@@",
- ep.Protocol, ep.Address, ep.RID,
- printRPCVersion(ep.MinRPCVersion), printRPCVersion(ep.MaxRPCVersion),
- mt)
- case 4:
- mt := "s"
- switch {
- case ep.IsLeaf:
- mt = "l"
- case ep.IsMountTable:
- mt = "m"
- }
- blessings := strings.Join(ep.Blessings, blessingsSeparator)
- return fmt.Sprintf("@4@%s@%s@%s@%s@%s@%s@%s@@",
- ep.Protocol, ep.Address, ep.RID,
- printRPCVersion(ep.MinRPCVersion), printRPCVersion(ep.MaxRPCVersion),
- mt, blessings)
case 5:
mt := "s"
switch {
@@ -282,12 +168,7 @@
func (ep *Endpoint) String() string {
//nologcall
- // Use version 4 if blessings are present, otherwise there is a loss of information.
- v := defaultVersion
- if len(ep.Blessings) > 0 && v < 4 {
- v = 4
- }
- return ep.VersionedString(v)
+ return ep.VersionedString(defaultVersion)
}
func (ep *Endpoint) Name() string {
@@ -315,11 +196,6 @@
return ep.Blessings
}
-func (ep *Endpoint) RPCVersionRange() version.RPCVersionRange {
- //nologcall
- return version.RPCVersionRange{Min: ep.MinRPCVersion, Max: ep.MaxRPCVersion}
-}
-
type addr struct {
network, address string
}
diff --git a/profiles/internal/naming/endpoint_test.go b/profiles/internal/naming/endpoint_test.go
index cd91fee..6c4fdb6 100644
--- a/profiles/internal/naming/endpoint_test.go
+++ b/profiles/internal/naming/endpoint_test.go
@@ -10,7 +10,6 @@
"testing"
"v.io/v23/naming"
- "v.io/v23/rpc/version"
)
func TestEndpoint(t *testing.T) {
@@ -18,115 +17,53 @@
defer func() {
defaultVersion = defver
}()
- v1 := &Endpoint{
+ v5a := &Endpoint{
Protocol: naming.UnknownProtocol,
Address: "batman.com:1234",
RID: naming.FixedRoutingID(0xdabbad00),
IsMountTable: true,
}
- v2 := &Endpoint{
- Protocol: naming.UnknownProtocol,
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0xdabbad00),
- MinRPCVersion: 1,
- MaxRPCVersion: 10,
- IsMountTable: true,
- }
- v2hp := &Endpoint{
- Protocol: naming.UnknownProtocol,
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0x0),
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
- IsMountTable: true,
- }
- v3s := &Endpoint{
- Protocol: naming.UnknownProtocol,
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0x0),
- MinRPCVersion: 2,
- MaxRPCVersion: 3,
- IsMountTable: false,
- }
- v3m := &Endpoint{
- Protocol: naming.UnknownProtocol,
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0xdabbad00),
- MinRPCVersion: 2,
- MaxRPCVersion: 3,
- IsMountTable: true,
- }
- v3tcp := &Endpoint{
- Protocol: "tcp",
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0x0),
- MinRPCVersion: 2,
- MaxRPCVersion: 3,
- IsMountTable: false,
- }
- v3ws6 := &Endpoint{
- Protocol: "ws6",
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0x0),
- MinRPCVersion: 2,
- MaxRPCVersion: 3,
- IsMountTable: false,
- }
- v4 := &Endpoint{
- Protocol: "tcp",
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0xba77),
- MinRPCVersion: 4,
- MaxRPCVersion: 5,
- IsMountTable: true,
- Blessings: []string{"dev.v.io/foo@bar.com", "dev.v.io/bar@bar.com/delegate"},
- }
- v4b := &Endpoint{
- Protocol: "tcp",
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0xba77),
- MinRPCVersion: 4,
- MaxRPCVersion: 5,
- IsMountTable: true,
- // Blessings that look similar to other parts of the endpoint.
- Blessings: []string{"@@", "@s", "@m"},
- }
- v5 := &Endpoint{
- Protocol: "tcp",
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0xba77),
- IsMountTable: true,
- Blessings: []string{"dev.v.io/foo@bar.com", "dev.v.io/bar@bar.com/delegate"},
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
- }
v5b := &Endpoint{
+ Protocol: naming.UnknownProtocol,
+ Address: "batman.com:2345",
+ RID: naming.FixedRoutingID(0xdabbad00),
+ IsMountTable: false,
+ }
+ v5c := &Endpoint{
+ Protocol: "tcp",
+ Address: "batman.com:2345",
+ RID: naming.FixedRoutingID(0x0),
+ IsMountTable: false,
+ }
+ v5d := &Endpoint{
+ Protocol: "ws6",
+ Address: "batman.com:2345",
+ RID: naming.FixedRoutingID(0x0),
+ IsMountTable: false,
+ }
+ v5e := &Endpoint{
+ Protocol: "tcp",
+ Address: "batman.com:2345",
+ RID: naming.FixedRoutingID(0xba77),
+ IsMountTable: true,
+ Blessings: []string{"dev.v.io/foo@bar.com", "dev.v.io/bar@bar.com/delegate"},
+ }
+ v5f := &Endpoint{
Protocol: "tcp",
Address: "batman.com:2345",
RID: naming.FixedRoutingID(0xba77),
IsMountTable: true,
// Blessings that look similar to other parts of the endpoint.
- Blessings: []string{"@@", "@s", "@m"},
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
- }
- v5c := &Endpoint{
- Protocol: "tcp",
- Address: "batman.com:2345",
- RID: naming.FixedRoutingID(0xba77),
- IsMountTable: false,
- Blessings: []string{"dev.v.io/foo@bar.com", "dev.v.io/bar@bar.com/delegate"},
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
+ Blessings: []string{"@@", "@s", "@m"},
}
testcasesA := []struct {
endpoint naming.Endpoint
address string
}{
- {v1, "batman.com:1234"},
- {v2, "batman.com:2345"},
- {v2hp, "batman.com:2345"},
+ {v5a, "batman.com:1234"},
+ {v5b, "batman.com:2345"},
+ {v5c, "batman.com:2345"},
}
for _, test := range testcasesA {
addr := test.endpoint.Addr()
@@ -135,73 +72,31 @@
}
}
- // Test v3, v4, v5 endpoints.
+ // Test v5 endpoints.
testcasesC := []struct {
Endpoint naming.Endpoint
String string
Version int
}{
- {v3s, "@3@@batman.com:2345@00000000000000000000000000000000@2@3@s@@", 3},
- {v3m, "@3@@batman.com:2345@000000000000000000000000dabbad00@2@3@m@@", 3},
- {v3tcp, "@3@tcp@batman.com:2345@00000000000000000000000000000000@2@3@s@@", 3},
- {v3ws6, "@3@ws6@batman.com:2345@00000000000000000000000000000000@2@3@s@@", 3},
- {v3s, "@4@@batman.com:2345@00000000000000000000000000000000@2@3@s@@@", 4},
- {v4, "@4@tcp@batman.com:2345@0000000000000000000000000000ba77@4@5@m@dev.v.io/foo@bar.com,dev.v.io/bar@bar.com/delegate@@", 4},
- {v4b, "@4@tcp@batman.com:2345@0000000000000000000000000000ba77@4@5@m@@@,@s,@m@@", 4},
- {v5, "@5@tcp@batman.com:2345@0000000000000000000000000000ba77@m@dev.v.io/foo@bar.com,dev.v.io/bar@bar.com/delegate@@", 5},
- {v5b, "@5@tcp@batman.com:2345@0000000000000000000000000000ba77@m@@@,@s,@m@@", 5},
- {v5c, "@5@tcp@batman.com:2345@0000000000000000000000000000ba77@s@dev.v.io/foo@bar.com,dev.v.io/bar@bar.com/delegate@@", 5},
+ {v5a, "@5@@batman.com:1234@000000000000000000000000dabbad00@m@@@", 5},
+ {v5b, "@5@@batman.com:2345@000000000000000000000000dabbad00@s@@@", 5},
+ {v5c, "@5@tcp@batman.com:2345@00000000000000000000000000000000@s@@@", 5},
+ {v5d, "@5@ws6@batman.com:2345@00000000000000000000000000000000@s@@@", 5},
+ {v5e, "@5@tcp@batman.com:2345@0000000000000000000000000000ba77@m@dev.v.io/foo@bar.com,dev.v.io/bar@bar.com/delegate@@", 5},
+ {v5f, "@5@tcp@batman.com:2345@0000000000000000000000000000ba77@m@@@,@s,@m@@", 5},
}
- for _, test := range testcasesC {
+ for i, test := range testcasesC {
if got, want := test.Endpoint.VersionedString(test.Version), test.String; got != want {
- t.Errorf("Got %q want %q for endpoint (v%d): %#v", got, want, test.Version, test.Endpoint)
+ t.Errorf("Test %d: Got %q want %q for endpoint (v%d): %#v", i, got, want, test.Version, test.Endpoint)
}
ep, err := NewEndpoint(test.String)
if err != nil {
- t.Errorf("Endpoint(%q) failed with %v", test.String, err)
+ t.Errorf("Test %d: Endpoint(%q) failed with %v", i, test.String, err)
continue
}
if !reflect.DeepEqual(ep, test.Endpoint) {
- t.Errorf("Got endpoint %#v, want %#v for string %q", ep, test.Endpoint, test.String)
- }
- }
-
- // Make sure we can continue to parse and create v2 endpoints.
- defaultVersion = 2
- testcasesB := []struct {
- Endpoint naming.Endpoint
- String string
- Input string
- min, max version.RPCVersion
- servesMT bool
- }{
- {v1, "@2@@batman.com:1234@000000000000000000000000dabbad00@@@@", "", version.UnknownRPCVersion, version.UnknownRPCVersion, true},
- {v2, "@2@@batman.com:2345@000000000000000000000000dabbad00@1@10@@", "", 1, 10, true},
- {v2hp, "@2@@batman.com:2345@00000000000000000000000000000000@1@1@@", "batman.com:2345", 2, 3, true},
- }
-
- for _, test := range testcasesB {
- if got, want := test.Endpoint.String(), test.String; got != want {
- t.Errorf("Got %q want %q for endpoint %T = %#v", got, want, test.Endpoint, test.Endpoint)
- }
- str := test.Input
- var ep naming.Endpoint
- var err error
- if str == "" {
- str = test.String
- ep, err = NewEndpoint(str)
- } else {
- ep, err = NewEndpoint(naming.FormatEndpoint(naming.UnknownProtocol, str,
- version.RPCVersionRange{test.min, test.max},
- naming.ServesMountTable(test.servesMT)))
- }
- if err != nil {
- t.Errorf("Endpoint(%q) failed with %v", str, err)
- continue
- }
- if !reflect.DeepEqual(ep, test.Endpoint) {
- t.Errorf("Got endpoint %T = %#v, want %T = %#v for string %q", ep, ep, test.Endpoint, test.Endpoint, str)
+ t.Errorf("Test %d: Got endpoint %#v, want %#v for string %q", i, ep, test.Endpoint, test.String)
}
}
}
@@ -211,22 +106,6 @@
err error
}
-func TestEndpointDefaults(t *testing.T) {
- testcases := []endpointTest{
- {"@1@tcp@batman@@@", "@5@tcp@batman@00000000000000000000000000000000@m@@@", nil},
- {"@2@tcp@robin@@@@@", "@5@tcp@robin@00000000000000000000000000000000@m@@@", nil},
- {"@1@@@@@", "@5@@:0@00000000000000000000000000000000@m@@@", nil},
- {"@2@@@@@@@", "@5@@:0@00000000000000000000000000000000@m@@@", nil},
- {"@1@tcp@batman:12@@@", "@5@tcp@batman:12@00000000000000000000000000000000@m@@@", nil},
- {"@2@tcp@foo:12@@9@@@", "@5@tcp@foo:12@00000000000000000000000000000000@m@@@", nil},
- {"@2@tcp@foo:12@@@4@@", "@5@tcp@foo:12@00000000000000000000000000000000@m@@@", nil},
- {"@2@tcp@foo:12@@2@4@@", "@5@tcp@foo:12@00000000000000000000000000000000@m@@@", nil},
- {"@3@@host:11@@@@m@@", "@5@@host:11@00000000000000000000000000000000@m@@@", nil},
- {"@3@@host:12@@@@@@", "@5@@host:12@00000000000000000000000000000000@m@@@", nil},
- }
- runEndpointTests(t, testcases)
-}
-
func runEndpointTests(t *testing.T, testcases []endpointTest) {
for _, test := range testcases {
ep, err := NewEndpoint(test.input)
@@ -252,39 +131,32 @@
defer func() {
defaultVersion = defver
}()
- defaultVersion = 4
testcases := []endpointTest{
- {"localhost:10", "@4@@localhost:10@00000000000000000000000000000000@@@m@@@", nil},
- {"localhost:", "@4@@localhost:@00000000000000000000000000000000@@@m@@@", nil},
+ {"localhost:10", "@5@@localhost:10@00000000000000000000000000000000@m@@@", nil},
+ {"localhost:", "@5@@localhost:@00000000000000000000000000000000@m@@@", nil},
{"localhost", "", errInvalidEndpointString},
- {"(dev.v.io/service/mounttabled)@ns.dev.v.io:8101", "@4@@ns.dev.v.io:8101@00000000000000000000000000000000@@@m@dev.v.io/service/mounttabled@@", nil},
- {"(dev.v.io/users/foo@bar.com)@ns.dev.v.io:8101", "@4@@ns.dev.v.io:8101@00000000000000000000000000000000@@@m@dev.v.io/users/foo@bar.com@@", nil},
- {"(@1@tcp)@ns.dev.v.io:8101", "@4@@ns.dev.v.io:8101@00000000000000000000000000000000@@@m@@1@tcp@@", nil},
+ {"(dev.v.io/service/mounttabled)@ns.dev.v.io:8101", "@5@@ns.dev.v.io:8101@00000000000000000000000000000000@m@dev.v.io/service/mounttabled@@", nil},
+ {"(dev.v.io/users/foo@bar.com)@ns.dev.v.io:8101", "@5@@ns.dev.v.io:8101@00000000000000000000000000000000@m@dev.v.io/users/foo@bar.com@@", nil},
+ {"(@1@tcp)@ns.dev.v.io:8101", "@5@@ns.dev.v.io:8101@00000000000000000000000000000000@m@@1@tcp@@", nil},
}
runEndpointTests(t, testcases)
}
func TestParseHostPort(t *testing.T) {
dns := &Endpoint{
- Protocol: "tcp",
- Address: "batman.com:4444",
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
- IsMountTable: true,
+ Protocol: "tcp",
+ Address: "batman.com:4444",
+ IsMountTable: true,
}
ipv4 := &Endpoint{
- Protocol: "tcp",
- Address: "192.168.1.1:4444",
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
- IsMountTable: true,
+ Protocol: "tcp",
+ Address: "192.168.1.1:4444",
+ IsMountTable: true,
}
ipv6 := &Endpoint{
- Protocol: "tcp",
- Address: "[01:02::]:4444",
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
- IsMountTable: true,
+ Protocol: "tcp",
+ Address: "[01:02::]:4444",
+ IsMountTable: true,
}
testcases := []struct {
Endpoint naming.Endpoint
diff --git a/profiles/internal/rpc/client.go b/profiles/internal/rpc/client.go
index f963e1d..dec6ba3 100644
--- a/profiles/internal/rpc/client.go
+++ b/profiles/internal/rpc/client.go
@@ -31,7 +31,6 @@
inaming "v.io/x/ref/profiles/internal/naming"
"v.io/x/ref/profiles/internal/rpc/stream"
"v.io/x/ref/profiles/internal/rpc/stream/vc"
- "v.io/x/ref/profiles/internal/rpc/version"
)
const pkgPath = "v.io/x/ref/profiles/internal/rpc"
@@ -389,10 +388,6 @@
status.serverErr = suberr(verror.New(errInvalidEndpoint, ctx))
return
}
- if err = version.CheckCompatibility(ep); err != nil {
- status.serverErr = suberr(verror.New(errIncompatibleEndpoint, ctx))
- return
- }
if status.flow, status.serverErr = c.createFlow(ctx, principal, ep, append(vcOpts, &vc.ServerAuthorizer{Suffix: status.suffix, Method: method, Policy: auth})); status.serverErr != nil {
status.serverErr.Name = suberrName(server, name, method)
vlog.VI(2).Infof("rpc: Failed to create Flow with %v: %v", server, status.serverErr.Err)
diff --git a/profiles/internal/rpc/sort_endpoints.go b/profiles/internal/rpc/sort_endpoints.go
index 57409e7..49db0bc 100644
--- a/profiles/internal/rpc/sort_endpoints.go
+++ b/profiles/internal/rpc/sort_endpoints.go
@@ -16,7 +16,6 @@
"v.io/x/lib/netstate"
inaming "v.io/x/ref/profiles/internal/naming"
- "v.io/x/ref/profiles/internal/rpc/version"
)
var (
@@ -105,11 +104,6 @@
adderr(name, verror.New(errMalformedEndpoint, nil, err))
continue
}
- if err = version.CheckCompatibility(ep); err != nil {
- // TODO(cnicolaou): convert rpc/version to verror.
- adderr(name, verror.New(errIncompatibleEndpointVersions, nil, err))
- continue
- }
rank, err := protocol2rank(ep.Addr().Network(), protoRanks)
if err != nil {
adderr(name, err)
diff --git a/profiles/internal/rpc/sort_internal_test.go b/profiles/internal/rpc/sort_internal_test.go
index 3cfe452..2d0d545 100644
--- a/profiles/internal/rpc/sort_internal_test.go
+++ b/profiles/internal/rpc/sort_internal_test.go
@@ -11,7 +11,6 @@
"testing"
"v.io/v23/naming"
- inaming "v.io/x/ref/profiles/internal/naming"
)
func servers2names(servers []naming.MountedServer) []string {
@@ -27,23 +26,6 @@
t.Errorf("expected a different error: %v", err)
}
- for _, a := range []string{"127.0.0.1", "127.0.0.2"} {
- ep := inaming.Endpoint{
- Protocol: "tcp",
- Address: a,
- MinRPCVersion: 100,
- MaxRPCVersion: 200,
- }
- addr := ep.VersionedString(4)
- name := naming.JoinAddressName(addr, "")
- servers = append(servers, naming.MountedServer{Server: name})
- }
-
- _, err = filterAndOrderServers(servers, []string{"tcp"}, nil)
- if err == nil || (!strings.HasPrefix(err.Error(), "failed to find any compatible servers:") && !strings.Contains(err.Error(), "No compatible RPC versions available")) {
- t.Errorf("expected a different error to: %v", err)
- }
-
for _, a := range []string{"127.0.0.3", "127.0.0.4"} {
name := naming.JoinAddressName(naming.FormatEndpoint("tcp", a), "")
servers = append(servers, naming.MountedServer{Server: name})
diff --git a/profiles/internal/rpc/stream/manager/manager.go b/profiles/internal/rpc/stream/manager/manager.go
index 4b9c4b8..371f86a 100644
--- a/profiles/internal/rpc/stream/manager/manager.go
+++ b/profiles/internal/rpc/stream/manager/manager.go
@@ -26,7 +26,6 @@
"v.io/x/ref/profiles/internal/rpc/stream/crypto"
"v.io/x/ref/profiles/internal/rpc/stream/vc"
"v.io/x/ref/profiles/internal/rpc/stream/vif"
- "v.io/x/ref/profiles/internal/rpc/version"
)
const pkgPath = "v.io/x/ref/profiles/internal/rpc/stream/manager"
@@ -135,15 +134,9 @@
conn.Close()
return vf, nil
}
- vRange := version.SupportedRange
- if ep, ok := remote.(*inaming.Endpoint); ok {
- epRange := &version.Range{Min: ep.MinRPCVersion, Max: ep.MaxRPCVersion}
- if r, err := vRange.Intersect(epRange); err == nil {
- vRange = r
- }
- }
+
opts = append([]stream.VCOpt{vc.StartTimeout{defaultStartTimeout}}, opts...)
- vf, err := vif.InternalNewDialedVIF(conn, m.rid, principal, vRange, m.deleteVIF, opts...)
+ vf, err := vif.InternalNewDialedVIF(conn, m.rid, principal, nil, m.deleteVIF, opts...)
if err != nil {
conn.Close()
return nil, err
@@ -233,7 +226,12 @@
ln := newNetListener(m, netln, principal, blessings, opts)
m.listeners[ln] = true
m.muListeners.Unlock()
- return ln, version.Endpoint(protocol, netln.Addr().String(), m.rid), nil
+ ep := &inaming.Endpoint{
+ Protocol: protocol,
+ Address: netln.Addr().String(),
+ RID: m.rid,
+ }
+ return ln, ep, nil
}
func (m *manager) remoteListen(proxy naming.Endpoint, principal security.Principal, listenerOpts []stream.ListenerOpt) (stream.Listener, *inaming.Endpoint, error) {
diff --git a/profiles/internal/rpc/stream/manager/manager_test.go b/profiles/internal/rpc/stream/manager/manager_test.go
index b8cc61c..e28f505 100644
--- a/profiles/internal/rpc/stream/manager/manager_test.go
+++ b/profiles/internal/rpc/stream/manager/manager_test.go
@@ -31,7 +31,6 @@
"v.io/x/ref/profiles/internal/rpc/stream"
"v.io/x/ref/profiles/internal/rpc/stream/vc"
"v.io/x/ref/profiles/internal/rpc/stream/vif"
- "v.io/x/ref/profiles/internal/rpc/version"
"v.io/x/ref/test"
"v.io/x/ref/test/expect"
"v.io/x/ref/test/modules"
@@ -634,7 +633,11 @@
// the address encoded in the endpoint (e.g. "0.0.0.0:55324") is different
// from the address of the connection (e.g. "127.0.0.1:55324").
_, port, _ := net.SplitHostPort(ep.Addr().String())
- nep := version.Endpoint(ep.Addr().Network(), net.JoinHostPort("", port), ep.RoutingID())
+ nep := &inaming.Endpoint{
+ Protocol: ep.Addr().Network(),
+ Address: net.JoinHostPort("", port),
+ RID: ep.RoutingID(),
+ }
// Dial multiple VCs
for i := 0; i < 2; i++ {
diff --git a/profiles/internal/rpc/stream/message/control.go b/profiles/internal/rpc/stream/message/control.go
index cb03ddc..6fdde05 100644
--- a/profiles/internal/rpc/stream/message/control.go
+++ b/profiles/internal/rpc/stream/message/control.go
@@ -37,13 +37,14 @@
writeTo(w io.Writer) error
}
-// OpenVC is a Control implementation requesting the creation of a new virtual
-// circuit.
-type OpenVC struct {
- VCI id.VC
- DstEndpoint naming.Endpoint
- SrcEndpoint naming.Endpoint
- Counters Counters
+// SetupVC is a Control implementation containing information to setup a new
+// virtual circuit.
+type SetupVC struct {
+ VCI id.VC
+ LocalEndpoint naming.Endpoint // Endpoint of the sender (as seen by the sender), can be nil.
+ RemoteEndpoint naming.Endpoint // Endpoint of the receiver (as seen by the sender), can be nil.
+ Counters Counters
+ Setup Setup // Negotiate versioning and encryption.
}
// CloseVC is a Control implementation notifying the closure of an established
@@ -56,17 +57,6 @@
Error string
}
-// SetupVC is a Control implementation containing information to setup a new
-// virtual circuit. This message is expected to replace OpenVC and allow for
-// the two ends of a VC to establish a protocol version.
-type SetupVC struct {
- VCI id.VC
- LocalEndpoint naming.Endpoint // Endpoint of the sender (as seen by the sender), can be nil.
- RemoteEndpoint naming.Endpoint // Endpoint of the receiver (as seen by the sender), can be nil.
- Counters Counters
- Setup Setup // Negotiate versioning and encryption.
-}
-
// AddReceiveBuffers is a Control implementation used by the sender of the
// message to inform the other end of a virtual circuit that it is ready to
// receive more bytes of data (specified per flow).
@@ -132,7 +122,7 @@
type command uint8
const (
- openVCCommand command = 0
+ deprecatedOpenVCCommand command = 0
closeVCCommand command = 1
addReceiveBuffersCommand command = 2
openFlowCommand command = 3
@@ -144,8 +134,6 @@
func writeControl(w io.Writer, m Control) error {
var command command
switch m.(type) {
- case *OpenVC:
- command = openVCCommand
case *CloseVC:
command = closeVCCommand
case *AddReceiveBuffers:
@@ -181,8 +169,6 @@
command := command(header)
var m Control
switch command {
- case openVCCommand:
- m = new(OpenVC)
case closeVCCommand:
m = new(CloseVC)
case addReceiveBuffersCommand:
@@ -204,47 +190,6 @@
return m, nil
}
-func (m *OpenVC) writeTo(w io.Writer) (err error) {
- if err = writeInt(w, m.VCI); err != nil {
- return
- }
- // Note that when we send OpenVC we always use v4 endpoints because
- // the server needs to get version information from them.
- if err = writeString(w, m.DstEndpoint.VersionedString(4)); err != nil {
- return
- }
- if err = writeString(w, m.SrcEndpoint.VersionedString(4)); err != nil {
- return
- }
- if err = writeCounters(w, m.Counters); err != nil {
- return
- }
- return nil
-}
-
-func (m *OpenVC) readFrom(r *bytes.Buffer) (err error) {
- if err = readInt(r, &m.VCI); err != nil {
- return
- }
- var ep string
- if err = readString(r, &ep); err != nil {
- return
- }
- if m.DstEndpoint, err = inaming.NewEndpoint(ep); err != nil {
- return
- }
- if err = readString(r, &ep); err != nil {
- return
- }
- if m.SrcEndpoint, err = inaming.NewEndpoint(ep); err != nil {
- return
- }
- if m.Counters, err = readCounters(r); err != nil {
- return
- }
- return nil
-}
-
func (m *CloseVC) writeTo(w io.Writer) (err error) {
if err = writeInt(w, m.VCI); err != nil {
return
diff --git a/profiles/internal/rpc/stream/message/message_test.go b/profiles/internal/rpc/stream/message/message_test.go
index 8bb99c7..8a05efc 100644
--- a/profiles/internal/rpc/stream/message/message_test.go
+++ b/profiles/internal/rpc/stream/message/message_test.go
@@ -11,7 +11,6 @@
"testing"
"v.io/v23/naming"
- "v.io/v23/rpc/version"
"v.io/x/ref/profiles/internal/lib/iobuf"
inaming "v.io/x/ref/profiles/internal/naming"
"v.io/x/ref/profiles/internal/rpc/stream/crypto"
@@ -70,35 +69,20 @@
counters := NewCounters()
counters.Add(12, 13, 10240)
tests := []Control{
- &OpenVC{VCI: 2,
- DstEndpoint: iversion.Endpoint("tcp", "batman.com:1990", naming.FixedRoutingID(0xba7)),
- SrcEndpoint: iversion.Endpoint("tcp", "google.com:80", naming.FixedRoutingID(0xba6)),
- },
- &OpenVC{
- VCI: 4,
- DstEndpoint: iversion.Endpoint("tcp", "batman.com:1990", naming.FixedRoutingID(0xba7)),
- SrcEndpoint: iversion.Endpoint("tcp", "google.com:80", naming.FixedRoutingID(0xba6)),
- Counters: counters,
- },
-
&CloseVC{VCI: 1},
&CloseVC{VCI: 2, Error: "some error"},
&SetupVC{
VCI: 1,
LocalEndpoint: &inaming.Endpoint{
- Protocol: "tcp",
- Address: "batman.com:1990",
- RID: naming.FixedRoutingID(0xba7),
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
+ Protocol: "tcp",
+ Address: "batman.com:1990",
+ RID: naming.FixedRoutingID(0xba7),
},
RemoteEndpoint: &inaming.Endpoint{
- Protocol: "tcp",
- Address: "bugsbunny.com:1940",
- RID: naming.FixedRoutingID(0xbb),
- MinRPCVersion: version.DeprecatedRPCVersion,
- MaxRPCVersion: version.DeprecatedRPCVersion,
+ Protocol: "tcp",
+ Address: "bugsbunny.com:1940",
+ RID: naming.FixedRoutingID(0xbb),
},
Counters: counters,
Setup: Setup{
diff --git a/profiles/internal/rpc/stream/proxy/proxy.go b/profiles/internal/rpc/stream/proxy/proxy.go
index f74428b..3944e13 100644
--- a/profiles/internal/rpc/stream/proxy/proxy.go
+++ b/profiles/internal/rpc/stream/proxy/proxy.go
@@ -16,7 +16,6 @@
"v.io/v23/context"
"v.io/v23/naming"
"v.io/v23/rpc"
- "v.io/v23/rpc/version"
"v.io/v23/security"
"v.io/v23/verror"
"v.io/v23/vom"
@@ -27,6 +26,7 @@
"v.io/x/ref/profiles/internal/lib/iobuf"
"v.io/x/ref/profiles/internal/lib/publisher"
"v.io/x/ref/profiles/internal/lib/upcqueue"
+ inaming "v.io/x/ref/profiles/internal/naming"
"v.io/x/ref/profiles/internal/rpc/stream"
"v.io/x/ref/profiles/internal/rpc/stream/crypto"
"v.io/x/ref/profiles/internal/rpc/stream/id"
@@ -51,7 +51,7 @@
// message visible to the user.
errNoRoutingTableEntry = reg(".errNoRoutingTableEntry", "routing table has no entry for the VC")
errProcessVanished = reg(".errProcessVanished", "remote process vanished")
- errDuplicateOpenVC = reg(".errDuplicateOpenVC", "duplicate OpenVC request")
+ errDuplicateSetupVC = reg(".errDuplicateSetupVC", "duplicate SetupVC request")
errVomDecoder = reg(".errVomDecoder", "failed to create vom decoder{:3}")
errVomEncoder = reg(".errVomEncoder", "failed to create vom encoder{:3}")
errVomEncodeResponse = reg(".errVomEncodeResponse", "failed to encode response from proxy{:3}")
@@ -345,13 +345,13 @@
response.Error = verror.Convert(verror.ErrUnknown, nil, err)
} else {
defer p.servers.Remove(server)
- ep, err := iversion.ProxiedEndpoint(server.VC.RemoteEndpoint().RoutingID(), p.endpoint())
- if err != nil {
- response.Error = verror.Convert(verror.ErrInternal, nil, err)
+ proxyEP := p.endpoint()
+ ep := &inaming.Endpoint{
+ Protocol: proxyEP.Protocol,
+ Address: proxyEP.Address,
+ RID: server.VC.RemoteEndpoint().RoutingID(),
}
- if ep != nil {
- response.Endpoint = ep.String()
- }
+ response.Endpoint = ep.String()
}
enc, err := vom.NewEncoder(conn)
if err != nil {
@@ -409,8 +409,13 @@
// Endpoint returns the endpoint of the proxy service. By Dialing a VC to this
// endpoint, processes can have their services exported through the proxy.
-func (p *Proxy) endpoint() naming.Endpoint {
- ep := iversion.Endpoint(p.ln.Addr().Network(), p.pubAddress, p.rid)
+func (p *Proxy) endpoint() *inaming.Endpoint {
+
+ ep := &inaming.Endpoint{
+ Protocol: p.ln.Addr().Network(),
+ Address: p.pubAddress,
+ RID: p.rid,
+ }
if prncpl := p.principal; prncpl != nil {
for b, _ := range prncpl.BlessingsInfo(prncpl.BlessingStore().Default()) {
ep.Blessings = append(ep.Blessings, b)
@@ -577,7 +582,7 @@
if naming.Compare(dstrid, p.proxy.rid) || naming.Compare(dstrid, naming.NullRoutingID) {
// VC that terminates at the proxy.
// See protocol.vdl for details on the protocol between the server and the proxy.
- vcObj := p.NewServerSetupVC(m)
+ vcObj := p.NewServerVC(m)
// route counters after creating the VC so counters to vc are not lost.
p.proxy.routeCounters(p, m.Counters)
if vcObj != nil {
@@ -654,44 +659,6 @@
d.Process.queue.Put(m)
p.proxy.routeCounters(p, counters)
- case *message.OpenVC:
- dstrid := m.DstEndpoint.RoutingID()
- if naming.Compare(dstrid, p.proxy.rid) || naming.Compare(dstrid, naming.NullRoutingID) {
- // VC that terminates at the proxy.
- // See protocol.vdl for details on the protocol between the server and the proxy.
- vcObj, vers := p.NewServerVC(m)
- // route counters after creating the VC so counters to vc are not lost.
- p.proxy.routeCounters(p, m.Counters)
- if vcObj != nil {
- server := &server{Process: p, VC: vcObj}
- go p.proxy.runServer(server, vcObj.HandshakeAcceptedVC(vers, p.proxy.principal, p.proxy.blessings, nil))
- }
- break
- }
- dstprocess := p.proxy.servers.Process(dstrid)
- if dstprocess == nil {
- p.SendCloseVC(m.VCI, verror.New(stream.ErrProxy, nil, verror.New(errServerNotBeingProxied, nil, dstrid)))
- p.proxy.routeCounters(p, m.Counters)
- break
- }
- srcVCI := m.VCI
- dstVCI := dstprocess.AllocVCI()
- startRoutingVC(srcVCI, dstVCI, p, dstprocess)
- // Forward the OpenVC message.
- // Typically, an OpenVC message is accompanied with Counters for the new VC.
- // Keep that in the forwarded message and route the remaining counters separately.
- counters := m.Counters
- m.Counters = message.NewCounters()
- for cid, bytes := range counters {
- if cid.VCI() == srcVCI {
- m.Counters.Add(dstVCI, cid.Flow(), bytes)
- delete(counters, cid)
- }
- }
- m.VCI = dstVCI
- dstprocess.queue.Put(m)
- p.proxy.routeCounters(p, counters)
-
default:
processLog().Infof("Closing %v because of invalid message %T", p, m)
return
@@ -768,36 +735,11 @@
return p.servers[vci]
}
-func (p *process) NewServerVC(m *message.OpenVC) (*vc.VC, version.RPCVersion) {
+func (p *process) NewServerVC(m *message.SetupVC) *vc.VC {
p.mu.Lock()
defer p.mu.Unlock()
if vc := p.servers[m.VCI]; vc != nil {
- vc.Close(verror.New(stream.ErrProxy, nil, verror.New(errDuplicateOpenVC, nil)))
- return nil, version.UnknownRPCVersion
- }
- vers, err := iversion.CommonVersion(m.DstEndpoint, m.SrcEndpoint)
- if err != nil {
- p.SendCloseVC(m.VCI, verror.New(stream.ErrProxy, nil, verror.New(errIncompatibleVersions, nil, err)))
- return nil, vers
- }
- vc := vc.InternalNew(vc.Params{
- VCI: m.VCI,
- LocalEP: m.DstEndpoint,
- RemoteEP: m.SrcEndpoint,
- Pool: p.pool,
- ReserveBytes: message.HeaderSizeBytes,
- Helper: p,
- })
- p.servers[m.VCI] = vc
- proxyLog().Infof("Registered VC %v from server on process %v", vc, p)
- return vc, vers
-}
-
-func (p *process) NewServerSetupVC(m *message.SetupVC) *vc.VC {
- p.mu.Lock()
- defer p.mu.Unlock()
- if vc := p.servers[m.VCI]; vc != nil {
- vc.Close(verror.New(stream.ErrProxy, nil, verror.New(errDuplicateOpenVC, nil)))
+ vc.Close(verror.New(stream.ErrProxy, nil, verror.New(errDuplicateSetupVC, nil)))
return nil
}
vc := vc.InternalNew(vc.Params{
diff --git a/profiles/internal/rpc/stream/vc/vc.go b/profiles/internal/rpc/stream/vc/vc.go
index 8f4a5eb..5889cc6 100644
--- a/profiles/internal/rpc/stream/vc/vc.go
+++ b/profiles/internal/rpc/stream/vc/vc.go
@@ -475,92 +475,60 @@
// from another goroutine.
// TODO(mattr): vers can be removed as a parameter when we get rid of TLS and
// the version is always obtained via the Setup call.
-func (vc *VC) HandshakeDialedVC(principal security.Principal, vers version.RPCVersion, sendKey func(*crypto.BoxKey) error, opts ...stream.VCOpt) error {
- var remotePubKeyChan chan *crypto.BoxKey
- if sendKey != nil {
- remotePubKeyChan = make(chan *crypto.BoxKey, 1)
- vc.mu.Lock()
- vc.remotePubKeyChan = remotePubKeyChan
- vc.mu.Unlock()
- }
+func (vc *VC) HandshakeDialedVC(principal security.Principal, sendKey func(*crypto.BoxKey) error, opts ...stream.VCOpt) error {
+ remotePubKeyChan := make(chan *crypto.BoxKey, 1)
+ vc.mu.Lock()
+ vc.remotePubKeyChan = remotePubKeyChan
+ vc.mu.Unlock()
// principal = nil means that we are running in SecurityNone and we don't need
// to authenticate the VC. We still need to negotiate versioning information,
// so we still set remotePubKeyChan and call sendKey, though we don't care about
// the resulting key.
if principal == nil {
- if sendKey != nil {
- if err := sendKey(nil); err != nil {
- return err
- }
- // TODO(mattr): Error on some timeout so a non-responding server doesn't
- // cause this to hang forever.
- select {
- case <-remotePubKeyChan:
- case <-vc.closeCh:
- return verror.New(stream.ErrNetwork, nil, verror.New(errClosedDuringHandshake, nil, vc.VCI))
- }
+ if err := sendKey(nil); err != nil {
+ return err
+ }
+ // TODO(mattr): Error on some timeout so a non-responding server doesn't
+ // cause this to hang forever.
+ select {
+ case <-remotePubKeyChan:
+ case <-vc.closeCh:
+ return verror.New(stream.ErrNetwork, nil, verror.New(errClosedDuringHandshake, nil, vc.VCI))
}
return nil
}
- var (
- tlsSessionCache crypto.TLSClientSessionCache
- auth *ServerAuthorizer
- )
+ var auth *ServerAuthorizer
for _, o := range opts {
switch v := o.(type) {
- case crypto.TLSClientSessionCache:
- tlsSessionCache = v
case *ServerAuthorizer:
auth = v
}
}
- var crypter crypto.Crypter
-
- if sendKey != nil {
- exchange := func(pubKey *crypto.BoxKey) (*crypto.BoxKey, error) {
- if err := sendKey(pubKey); err != nil {
- return nil, err
- }
- // TODO(mattr): Error on some timeout so a non-responding server doesn't
- // cause this to hang forever.
- select {
- case theirKey := <-remotePubKeyChan:
- return theirKey, nil
- case <-vc.closeCh:
- return nil, verror.New(stream.ErrNetwork, nil, verror.New(errClosedDuringHandshake, nil, vc.VCI))
- }
+ exchange := func(pubKey *crypto.BoxKey) (*crypto.BoxKey, error) {
+ if err := sendKey(pubKey); err != nil {
+ return nil, err
}
- var err error
- crypter, err = crypto.NewBoxCrypter(exchange, vc.pool)
- if err != nil {
- return vc.appendCloseReason(verror.New(stream.ErrSecurity, nil,
- verror.New(errFailedToSetupEncryption, nil, err)))
- }
- // The version is set by FinishHandshakeDialedVC and exchange (called by
- // NewBoxCrypter) will block until FinishHandshakeDialedVC is called, so we
- // should look up the version now.
- vers = vc.Version()
- } else {
- // Establish TLS
- handshakeConn, err := vc.connectFID(HandshakeFlowID, systemFlowPriority)
- if err != nil {
- return vc.appendCloseReason(verror.New(stream.ErrSecurity, nil, verror.New(errFailedToCreateTLSFlow, nil, err)))
- }
- crypter, err = crypto.NewTLSClient(handshakeConn,
- handshakeConn.LocalEndpoint(), handshakeConn.RemoteEndpoint(),
- tlsSessionCache, vc.pool)
- if err != nil {
- // Assume that we don't trust the server if the TLS handshake fails for any
- // reason other than EOF.
- if err == io.EOF {
- return vc.appendCloseReason(verror.New(stream.ErrNetwork, nil, verror.New(errFailedToSetupEncryption, nil, err)))
- }
- return vc.appendCloseReason(verror.New(stream.ErrNotTrusted, nil, verror.New(errFailedToSetupEncryption, nil, err)))
+ // TODO(mattr): Error on some timeout so a non-responding server doesn't
+ // cause this to hang forever.
+ select {
+ case theirKey := <-remotePubKeyChan:
+ return theirKey, nil
+ case <-vc.closeCh:
+ return nil, verror.New(stream.ErrNetwork, nil, verror.New(errClosedDuringHandshake, nil, vc.VCI))
}
}
+ crypter, err := crypto.NewBoxCrypter(exchange, vc.pool)
+ if err != nil {
+ return vc.appendCloseReason(verror.New(stream.ErrSecurity, nil,
+ verror.New(errFailedToSetupEncryption, nil, err)))
+ }
+ // The version is set by FinishHandshakeDialedVC and exchange (called by
+ // NewBoxCrypter) will block until FinishHandshakeDialedVC is called, so we
+ // should look up the version now.
+ vers := vc.Version()
// Authenticate (exchange identities)
// Unfortunately, handshakeConn cannot be used for the authentication protocol.
@@ -580,9 +548,6 @@
LocalEndpoint: vc.localEP,
RemoteEndpoint: vc.remoteEP,
}
- vc.mu.Lock()
- vc.version = vers
- vc.mu.Unlock()
rBlessings, lBlessings, rDischarges, err := AuthenticateAsClient(authConn, crypter, params, auth, vers)
if err != nil || len(rBlessings.ThirdPartyCaveats()) == 0 {
@@ -665,12 +630,9 @@
// using SetupVC.
vc.helper.AddReceiveBuffers(vc.VCI(), SharedFlowID, DefaultBytesBufferedPerFlow)
- // principal = nil means that we are running in SecurityNone and we don't need
+ // principal == nil means that we are running in SecurityNone and we don't need
// to authenticate the VC.
if principal == nil {
- if exchange == nil {
- return finish(ln, nil)
- }
go func() {
_, err = exchange(nil)
result <- HandshakeResult{ln, err}
@@ -690,34 +652,10 @@
vc.acceptHandshakeDone = make(chan struct{})
vc.mu.Unlock()
- if exchange != nil {
- crypter, err = crypto.NewBoxCrypter(exchange, vc.pool)
- if err != nil {
- sendErr(verror.New(stream.ErrSecurity, nil, verror.New(errFailedToSetupEncryption, nil, err)))
- return
- }
- } else {
- // TODO(ashankar): There should be a timeout on this Accept
- // call. Otherwise, a malicious (or incompetent) client can
- // consume server resources by sending many OpenVC messages but
- // not following up with the handshake protocol. Same holds for
- // the identity exchange protocol.
- handshakeConn, err := ln.Accept()
- if err != nil {
- sendErr(verror.New(stream.ErrNetwork, nil, verror.New(errTLSFlowNotAccepted, nil, err)))
- return
- }
- if vc.findFlow(handshakeConn) != HandshakeFlowID {
- // This should have been the handshake flow, but it isn't. We can't establish
- // TLS, so send an error back.
- sendErr(verror.New(stream.ErrSecurity, nil, verror.New(errFailedToCreateTLSFlow, nil, err)))
- }
- // Establish TLS
- crypter, err = crypto.NewTLSServer(handshakeConn, handshakeConn.LocalEndpoint(), handshakeConn.RemoteEndpoint(), vc.pool)
- if err != nil {
- sendErr(verror.New(stream.ErrSecurity, nil, verror.New(errFailedToSetupEncryption, nil, err)))
- return
- }
+ crypter, err = crypto.NewBoxCrypter(exchange, vc.pool)
+ if err != nil {
+ sendErr(verror.New(stream.ErrSecurity, nil, verror.New(errFailedToSetupEncryption, nil, err)))
+ return
}
// Authenticate (exchange identities)
@@ -854,9 +792,6 @@
}
func (vc *VC) connectSystemFlows() error {
- if vc.Version() < version.RPCVersion8 {
- return nil
- }
conn, err := vc.connectFID(TypeFlowID, systemFlowPriority)
if err != nil {
return verror.New(stream.ErrSecurity, nil, verror.New(errFailedToCreateFlowForWireType, nil, err))
@@ -877,9 +812,6 @@
}
func (vc *VC) acceptSystemFlows(ln stream.Listener) error {
- if vc.Version() < version.RPCVersion8 {
- return nil
- }
conn, err := ln.Accept()
if err != nil {
return verror.New(errFlowForWireTypeNotAccepted, nil, err)
diff --git a/profiles/internal/rpc/stream/vc/vc_test.go b/profiles/internal/rpc/stream/vc/vc_test.go
index 9908261..2fe9918 100644
--- a/profiles/internal/rpc/stream/vc/vc_test.go
+++ b/profiles/internal/rpc/stream/vc/vc_test.go
@@ -285,14 +285,6 @@
}
func TestConnect_SmallNoSecurity(t *testing.T) { testConnect_Small(t, LatestVersion, SecurityNone) }
func TestConnect_Small(t *testing.T) { testConnect_Small(t, LatestVersion, SecurityDefault) }
-func TestConnect_Small7NoSecurity(t *testing.T) {
- testConnect_Small(t, version.RPCVersion7, SecurityNone)
-}
-func TestConnect_Small7(t *testing.T) { testConnect_Small(t, version.RPCVersion7, SecurityDefault) }
-func TestConnect_Small8NoSecurity(t *testing.T) {
- testConnect_Small(t, version.RPCVersion8, SecurityNone)
-}
-func TestConnect_Small8(t *testing.T) { testConnect_Small(t, version.RPCVersion8, SecurityDefault) }
func testConnect(t *testing.T, securityLevel options.SecurityLevel) {
h, vc, err := NewSimple(LatestVersion, securityLevel)
@@ -513,20 +505,19 @@
var clientExchanger func(*crypto.BoxKey) error
var serverExchanger func(*crypto.BoxKey) (*crypto.BoxKey, error)
- if v >= version.RPCVersion9 {
- server, client := make(chan *crypto.BoxKey, 1), make(chan *crypto.BoxKey, 1)
- clientExchanger = func(pubKey *crypto.BoxKey) error {
- client <- pubKey
- return clientH.VC.FinishHandshakeDialedVC(v, <-server)
- }
- serverExchanger = func(pubKey *crypto.BoxKey) (*crypto.BoxKey, error) {
- server <- pubKey
- return <-client, nil
- }
+
+ serverch, clientch := make(chan *crypto.BoxKey, 1), make(chan *crypto.BoxKey, 1)
+ clientExchanger = func(pubKey *crypto.BoxKey) error {
+ clientch <- pubKey
+ return clientH.VC.FinishHandshakeDialedVC(v, <-serverch)
+ }
+ serverExchanger = func(pubKey *crypto.BoxKey) (*crypto.BoxKey, error) {
+ serverch <- pubKey
+ return <-clientch, nil
}
c := serverH.VC.HandshakeAcceptedVC(v, server, bserver, serverExchanger, lopts...)
- if err := clientH.VC.HandshakeDialedVC(client, v, clientExchanger, vcopts...); err != nil {
+ if err := clientH.VC.HandshakeDialedVC(client, clientExchanger, vcopts...); err != nil {
go func() { <-c }()
return nil, nil, err
}
diff --git a/profiles/internal/rpc/stream/vif/vif.go b/profiles/internal/rpc/stream/vif/vif.go
index 4298040..d20b63e 100644
--- a/profiles/internal/rpc/stream/vif/vif.go
+++ b/profiles/internal/rpc/stream/vif/vif.go
@@ -20,7 +20,6 @@
"v.io/v23/context"
"v.io/v23/naming"
- "v.io/v23/rpc/version"
"v.io/v23/security"
"v.io/v23/verror"
"v.io/v23/vtrace"
@@ -32,6 +31,7 @@
"v.io/x/ref/profiles/internal/lib/pcqueue"
vsync "v.io/x/ref/profiles/internal/lib/sync"
"v.io/x/ref/profiles/internal/lib/upcqueue"
+ inaming "v.io/x/ref/profiles/internal/naming"
"v.io/x/ref/profiles/internal/rpc/stream"
"v.io/x/ref/profiles/internal/rpc/stream/crypto"
"v.io/x/ref/profiles/internal/rpc/stream/id"
@@ -316,51 +316,28 @@
counters := message.NewCounters()
counters.Add(vc.VCI(), sharedFlowID, defaultBytesBufferedPerFlow)
- ver, err := vif.versions.CommonVersion(vif.localEP, remoteEP)
-
- switch {
- case verror.ErrorID(err) == iversion.ErrDeprecatedVersion.ID || ver >= version.RPCVersion9:
- sendPublicKey := func(pubKey *crypto.BoxKey) error {
- var options []message.SetupOption
- if pubKey != nil {
- options = []message.SetupOption{&message.NaclBox{PublicKey: *pubKey}}
- }
- err := vif.sendOnExpressQ(&message.SetupVC{
- VCI: vc.VCI(),
- RemoteEndpoint: remoteEP,
- LocalEndpoint: vif.localEP,
- Counters: counters,
- Setup: message.Setup{
- Versions: *vif.versions,
- Options: options,
- },
- })
- if err != nil {
- err = verror.New(stream.ErrNetwork, nil,
- verror.New(errSendOnExpressQFailed, nil, err))
- }
- return err
+ sendPublicKey := func(pubKey *crypto.BoxKey) error {
+ var options []message.SetupOption
+ if pubKey != nil {
+ options = []message.SetupOption{&message.NaclBox{PublicKey: *pubKey}}
}
- if err = vc.HandshakeDialedVC(principal, ver, sendPublicKey, opts...); err != nil {
- break
- }
- case err != nil:
- break
- default:
- err = vif.sendOnExpressQ(&message.OpenVC{
- VCI: vc.VCI(),
- DstEndpoint: remoteEP,
- SrcEndpoint: vif.localEP,
- Counters: counters})
+ err := vif.sendOnExpressQ(&message.SetupVC{
+ VCI: vc.VCI(),
+ RemoteEndpoint: remoteEP,
+ LocalEndpoint: vif.localEP,
+ Counters: counters,
+ Setup: message.Setup{
+ Versions: *vif.versions,
+ Options: options,
+ },
+ })
if err != nil {
- err = verror.New(stream.ErrNetwork, nil, verror.New(errSendOnExpressQFailed, nil, err))
- break
+ err = verror.New(stream.ErrNetwork, nil,
+ verror.New(errSendOnExpressQFailed, nil, err))
}
- if err = vc.HandshakeDialedVC(principal, ver, nil, opts...); err != nil {
- break
- }
+ return err
}
- if err != nil {
+ if err = vc.HandshakeDialedVC(principal, sendPublicKey, opts...); err != nil {
vif.deleteVC(vc.VCI())
vc.Close(err)
return nil, err
@@ -545,45 +522,6 @@
m.Release()
}
- case *message.OpenVC:
- vif.muListen.Lock()
- closed := vif.acceptor == nil || vif.acceptor.IsClosed()
- lopts := vif.listenerOpts
- vif.muListen.Unlock()
- if closed {
- vlog.VI(2).Infof("Ignoring OpenVC message %+v as VIF %s does not accept VCs", m, vif)
- vif.sendOnExpressQ(&message.CloseVC{
- VCI: m.VCI,
- Error: "VCs not accepted",
- })
- return nil
- }
- var idleTimeout time.Duration
- for _, o := range lopts {
- switch v := o.(type) {
- case vc.IdleTimeout:
- idleTimeout = v.Duration
- }
- }
- vc, err := vif.newVC(m.VCI, m.DstEndpoint, m.SrcEndpoint, idleTimeout, false)
- vif.distributeCounters(m.Counters)
- if err != nil {
- vif.sendOnExpressQ(&message.CloseVC{
- VCI: m.VCI,
- Error: err.Error(),
- })
- return nil
- }
- vers, err := vif.versions.CommonVersion(m.DstEndpoint, m.SrcEndpoint)
- if err != nil {
- vif.sendOnExpressQ(&message.CloseVC{
- VCI: m.VCI,
- Error: err.Error(),
- })
- return nil
- }
- go vif.acceptFlowsLoop(vc, vc.HandshakeAcceptedVC(vers, vif.principal, vif.blessings, nil, lopts...))
-
case *message.SetupVC:
// First, find the public key we need out of the message.
var theirPK *crypto.BoxKey
@@ -1159,7 +1097,7 @@
// localEP creates a naming.Endpoint from the provided parameters.
//
// It intentionally does not include any blessings (present in endpoints in the
-// v4 format). At this point it is not clear whether the endpoint is being
+// v5 format). At this point it is not clear whether the endpoint is being
// created for a "client" or a "server". If the endpoint is used for clients
// (i.e., for those sending an OpenVC message for example), then we do NOT want
// to include the blessings in the endpoint to ensure client privacy.
@@ -1173,9 +1111,10 @@
// clearer.
func localEP(conn net.Conn, rid naming.RoutingID, versions *iversion.Range) naming.Endpoint {
localAddr := conn.LocalAddr()
- ep := iversion.Endpoint(localAddr.Network(), localAddr.String(), rid)
- if versions != nil {
- ep = versions.Endpoint(localAddr.Network(), localAddr.String(), rid)
+ ep := &inaming.Endpoint{
+ Protocol: localAddr.Network(),
+ Address: localAddr.String(),
+ RID: rid,
}
return ep
}
diff --git a/profiles/internal/rpc/stream/vif/vif_test.go b/profiles/internal/rpc/stream/vif/vif_test.go
index 32ccc74..ba97c3d 100644
--- a/profiles/internal/rpc/stream/vif/vif_test.go
+++ b/profiles/internal/rpc/stream/vif/vif_test.go
@@ -23,6 +23,7 @@
"v.io/v23/naming"
"v.io/v23/rpc/version"
+ inaming "v.io/x/ref/profiles/internal/naming"
"v.io/x/ref/profiles/internal/rpc/stream"
"v.io/x/ref/profiles/internal/rpc/stream/vc"
"v.io/x/ref/profiles/internal/rpc/stream/vif"
@@ -620,7 +621,11 @@
}
defer client.Close()
- ep := tc.ep.Endpoint("test", "addr", naming.FixedRoutingID(0x5))
+ ep := &inaming.Endpoint{
+ Protocol: "test",
+ Address: "addr",
+ RID: naming.FixedRoutingID(0x5),
+ }
clientVC, _, err := createVC(client, server, ep)
if (err != nil) != tc.expectError {
t.Errorf("Error mismatch. Wanted error: %v, got %v (client:%v, server:%v ep:%v)", tc.expectError, err, tc.client, tc.server, tc.ep)
@@ -689,7 +694,11 @@
}
func makeEP(rid uint64) naming.Endpoint {
- return iversion.Endpoint("test", "addr", naming.FixedRoutingID(rid))
+ return &inaming.Endpoint{
+ Protocol: "test",
+ Address: "addr",
+ RID: naming.FixedRoutingID(rid),
+ }
}
// pipeAddr provides a more descriptive String implementation than provided by net.Pipe.
diff --git a/profiles/internal/rpc/version/version.go b/profiles/internal/rpc/version/version.go
index 157ed01..2d3119d 100644
--- a/profiles/internal/rpc/version/version.go
+++ b/profiles/internal/rpc/version/version.go
@@ -5,11 +5,6 @@
package version
import (
- "fmt"
-
- inaming "v.io/x/ref/profiles/internal/naming"
-
- "v.io/v23/naming"
"v.io/v23/rpc/version"
"v.io/v23/verror"
)
@@ -26,21 +21,7 @@
// change that's not both forward and backward compatible.
// Min should be incremented whenever we want to remove
// support for old protocol versions.
- SupportedRange = &Range{Min: version.RPCVersion6, Max: version.RPCVersion9}
-
- // Export the methods on supportedRange.
- Endpoint = SupportedRange.Endpoint
- ProxiedEndpoint = SupportedRange.ProxiedEndpoint
- CommonVersion = SupportedRange.CommonVersion
- CheckCompatibility = SupportedRange.CheckCompatibility
-
- // Which version to guess servers support if it's unknown.
- // TODO(mattr): This is a hack. Once RPCVersion9 is released and versions
- // are negotiated, we wont have to guess anymore and this code should
- // be removed. This is required until version 9 is live.
- // In fact, once version9 is the minimum supported version, much of the
- // code in this file can be eliminated.
- maxVersionGuess = version.RPCVersion8
+ SupportedRange = &Range{Min: version.RPCVersion9, Max: version.RPCVersion9}
)
const pkgPath = "v.io/x/ref/profiles/internal/rpc/version"
@@ -54,28 +35,15 @@
// level errors and hence {1}{2} is omitted from their format
// strings to avoid repeating these n-times in the final error
// message visible to the user.
- ErrNoCompatibleVersion = reg(".errNoCompatibleVersionErr", "no compatible RPC version available{:3} not in range {4}..{5}")
- ErrUnknownVersion = reg(".errUnknownVersionErr", "there was not enough information to determine a version")
- ErrDeprecatedVersion = reg(".errDeprecatedVersionError", "some of the provided version information is deprecated")
- errInternalTypeConversionError = reg(".errInternalTypeConversionError", "failed to convert {3} to v.io/ref/profiles/internal/naming.Endpoint {3}")
+ ErrNoCompatibleVersion = reg(".errNoCompatibleVersionErr", "no compatible RPC version available{:3} not in range {4}..{5}")
+ ErrUnknownVersion = reg(".errUnknownVersionErr", "there was not enough information to determine a version")
+ ErrDeprecatedVersion = reg(".errDeprecatedVersionError", "some of the provided version information is deprecated")
)
// IsVersionError returns true if err is a versioning related error.
func IsVersionError(err error) bool {
id := verror.ErrorID(err)
- return id == ErrNoCompatibleVersion.ID || id == ErrUnknownVersion.ID
-}
-
-// Endpoint returns an endpoint with the Min/MaxRPCVersion properly filled in
-// to match this implementations supported protocol versions.
-func (r *Range) Endpoint(protocol, address string, rid naming.RoutingID) *inaming.Endpoint {
- return &inaming.Endpoint{
- Protocol: protocol,
- Address: address,
- RID: rid,
- MinRPCVersion: r.Min,
- MaxRPCVersion: r.Max,
- }
+ return id == ErrNoCompatibleVersion.ID || id == ErrUnknownVersion.ID || id == ErrDeprecatedVersion.ID
}
// intersectRanges finds the intersection between ranges
@@ -105,12 +73,6 @@
if max == u || (bmax != u && bmax < max) {
max = bmax
}
- // TODO(mattr): This is a hack. Once RPCVersion9 is released and versions
- // are negotiated, we wont have to guess anymore and this code should
- // be removed. This is required until version 9 is live.
- if max > maxVersionGuess && (amax == u || bmax == u) {
- max = maxVersionGuess
- }
if min == u || max == u {
err = verror.New(ErrUnknownVersion, nil)
@@ -120,10 +82,6 @@
return
}
-func intersectEndpoints(a, b *inaming.Endpoint) (min, max version.RPCVersion, err error) {
- return intersectRanges(a.MinRPCVersion, a.MaxRPCVersion, b.MinRPCVersion, b.MaxRPCVersion)
-}
-
func (r1 *Range) Intersect(r2 *Range) (*Range, error) {
min, max, err := intersectRanges(r1.Min, r1.Max, r2.Min, r2.Max)
if err != nil {
@@ -132,77 +90,3 @@
r := &Range{Min: min, Max: max}
return r, nil
}
-
-// ProxiedEndpoint returns an endpoint with the Min/MaxRPCVersion properly filled in
-// to match the intersection of capabilities of this process and the proxy.
-func (r *Range) ProxiedEndpoint(rid naming.RoutingID, proxy naming.Endpoint) (*inaming.Endpoint, error) {
- proxyEP, ok := proxy.(*inaming.Endpoint)
- if !ok {
- return nil, verror.New(errInternalTypeConversionError, nil, fmt.Sprintf("%T", proxy))
- }
-
- ep := &inaming.Endpoint{
- Protocol: proxyEP.Protocol,
- Address: proxyEP.Address,
- RID: rid,
- MinRPCVersion: r.Min,
- MaxRPCVersion: r.Max,
- }
-
- // This is the endpoint we are going to advertise. It should only claim to support versions in
- // the intersection of those we support and those the proxy supports.
- var err error
- ep.MinRPCVersion, ep.MaxRPCVersion, err = intersectEndpoints(ep, proxyEP)
- if err != nil {
- return nil, fmt.Errorf("attempting to register with incompatible proxy: %s", proxy)
- }
- return ep, nil
-}
-
-// CommonVersion determines which version of the RPC protocol should be used
-// between two endpoints. Returns an error if the resulting version is incompatible
-// with this RPC implementation.
-func (r *Range) CommonVersion(a, b naming.Endpoint) (version.RPCVersion, error) {
- aEP, ok := a.(*inaming.Endpoint)
- if !ok {
- return 0, verror.New(errInternalTypeConversionError, nil, fmt.Sprintf("%T", a))
- }
- bEP, ok := b.(*inaming.Endpoint)
- if !ok {
- return 0, verror.New(errInternalTypeConversionError, nil, fmt.Sprintf("%T", b))
- }
-
- _, max, err := intersectEndpoints(aEP, bEP)
- if err != nil {
- return 0, err
- }
-
- // We want to use the maximum common version of the protocol. We just
- // need to make sure that it is supported by this RPC implementation.
- if max < r.Min || max > r.Max {
- return version.UnknownRPCVersion, verror.New(ErrNoCompatibleVersion, nil, max, r.Min, r.Max)
- }
- return max, nil
-}
-
-// CheckCompatibility returns an error if the given endpoint is incompatible
-// with this RPC implementation. It returns nil otherwise.
-func (r *Range) CheckCompatibility(remote naming.Endpoint) error {
- remoteEP, ok := remote.(*inaming.Endpoint)
- if !ok {
- return verror.New(errInternalTypeConversionError, nil, fmt.Sprintf("%T", remote))
- }
-
- if remoteEP.MinRPCVersion == version.DeprecatedRPCVersion &&
- remoteEP.MaxRPCVersion == version.DeprecatedRPCVersion {
- // If the remote endpoint no longer contains version information
- // then compatibility wont be decided here. We simply return
- // true and allow the version negotiation to figure it out.
- return nil
- }
-
- _, _, err := intersectRanges(r.Min, r.Max,
- remoteEP.MinRPCVersion, remoteEP.MaxRPCVersion)
-
- return err
-}
diff --git a/profiles/internal/rpc/version/version_test.go b/profiles/internal/rpc/version/version_test.go
index a22e6cc..652baf8 100644
--- a/profiles/internal/rpc/version/version_test.go
+++ b/profiles/internal/rpc/version/version_test.go
@@ -6,118 +6,43 @@
import (
"testing"
- inaming "v.io/x/ref/profiles/internal/naming"
-
- "v.io/v23/naming"
"v.io/v23/rpc/version"
"v.io/v23/verror"
)
-func TestCommonVersion(t *testing.T) {
- r := &Range{Min: 2, Max: 4}
-
+func TestIntersect(t *testing.T) {
type testCase struct {
localMin, localMax version.RPCVersion
remoteMin, remoteMax version.RPCVersion
- expectedVer version.RPCVersion
+ expected *Range
expectedErr verror.IDAction
}
tests := []testCase{
- {0, 0, 0, 0, 0, ErrUnknownVersion},
- {0, 2, 3, 4, 0, ErrNoCompatibleVersion},
- {3, 4, 0, 2, 0, ErrNoCompatibleVersion},
- {0, 6, 6, 7, 0, ErrNoCompatibleVersion},
- {0, 3, 3, 5, 3, verror.ErrUnknown},
- {0, 3, 2, 4, 3, verror.ErrUnknown},
- {2, 4, 2, 4, 4, verror.ErrUnknown},
- {4, 4, 4, 4, 4, verror.ErrUnknown},
+ {0, 0, 0, 0, nil, ErrUnknownVersion},
+ {0, 2, 3, 4, nil, ErrNoCompatibleVersion},
+ {3, 4, 0, 2, nil, ErrNoCompatibleVersion},
+ {0, 6, 6, 7, nil, ErrNoCompatibleVersion},
+ {0, 3, 3, 5, &Range{3, 3}, verror.ErrUnknown},
+ {0, 3, 2, 4, &Range{2, 3}, verror.ErrUnknown},
+ {2, 4, 2, 4, &Range{2, 4}, verror.ErrUnknown},
+ {4, 4, 4, 4, &Range{4, 4}, verror.ErrUnknown},
}
for _, tc := range tests {
- local := &inaming.Endpoint{
- MinRPCVersion: tc.localMin,
- MaxRPCVersion: tc.localMax,
+ local := &Range{
+ Min: tc.localMin,
+ Max: tc.localMax,
}
- remote := &inaming.Endpoint{
- MinRPCVersion: tc.remoteMin,
- MaxRPCVersion: tc.remoteMax,
+ remote := &Range{
+ Min: tc.remoteMin,
+ Max: tc.remoteMax,
}
- ver, err := r.CommonVersion(local, remote)
- if ver != tc.expectedVer || (err != nil && verror.ErrorID(err) != tc.expectedErr.ID) {
- t.Errorf("Unexpected result for local: %v, remote: %v. Got (%d, %v) wanted (%d, %v)",
- local, remote, ver, err, tc.expectedVer, tc.expectedErr)
- }
- if err != nil {
- t.Logf("%s", err)
- }
- }
-}
+ intersection, err := local.Intersect(remote)
-func TestProxiedEndpoint(t *testing.T) {
- type testCase struct {
- supportMin, supportMax version.RPCVersion
- proxyMin, proxyMax version.RPCVersion
- outMin, outMax version.RPCVersion
- expectError bool
- }
- tests := []testCase{
- {2, 4, 2, 3, 2, 3, false},
- {2, 4, 4, 6, 4, 4, false},
- {2, 4, 0, 2, 2, 2, false},
- {2, 4, 0, 2, 2, 2, false},
- {0, 0, 0, 0, 0, 0, true},
- {3, 4, 0, 2, 0, 0, true},
- {3, 6, 7, 8, 0, 0, true},
- }
-
- rid := naming.FixedRoutingID(1)
- for _, tc := range tests {
- r := &Range{Min: tc.supportMin, Max: tc.supportMax}
- proxy := &inaming.Endpoint{
- MinRPCVersion: tc.proxyMin,
- MaxRPCVersion: tc.proxyMax,
- }
- if ep, err := r.ProxiedEndpoint(rid, proxy); err != nil {
- if !tc.expectError {
- t.Errorf("Unexpected error for case %+v: %v", tc, err)
- }
- } else {
- if tc.expectError {
- t.Errorf("Expected Error, but got result for test case %+v", tc)
- continue
- }
- if ep.MinRPCVersion != tc.outMin || ep.MaxRPCVersion != tc.outMax {
- t.Errorf("Unexpected range for case %+v. Got (%d, %d) want (%d, %d)",
- tc, ep.MinRPCVersion, ep.MaxRPCVersion, tc.outMin, tc.outMax)
- }
- }
- }
-}
-
-func TestCheckCompatibility(t *testing.T) {
- type testCase struct {
- supportMin, supportMax version.RPCVersion
- remoteMin, remoteMax version.RPCVersion
- expectedError verror.IDAction
- }
- tests := []testCase{
- {0, 0, 0, 0, ErrUnknownVersion},
- {6, 11, 2, 5, ErrNoCompatibleVersion},
- {2, 5, 6, 11, ErrNoCompatibleVersion},
- {2, 11, 3, 10, verror.ErrUnknown},
- {4, 9, 2, 5, verror.ErrUnknown},
- {4, 9, 8, 10, verror.ErrUnknown},
- }
-
- for _, tc := range tests {
- r := &Range{Min: tc.supportMin, Max: tc.supportMax}
- remote := &inaming.Endpoint{
- MinRPCVersion: tc.remoteMin,
- MaxRPCVersion: tc.remoteMax,
- }
- err := r.CheckCompatibility(remote)
- if err != nil && verror.ErrorID(err) != tc.expectedError.ID {
- t.Errorf("Unexpected error for case %+v: got %v, wanted %v",
- tc, err, tc.expectedError)
+ if (tc.expected != nil && *tc.expected != *intersection) ||
+ (err != nil && verror.ErrorID(err) != tc.expectedErr.ID) {
+ t.Errorf("Unexpected result for local: %v, remote: %v. Got (%v, %v) wanted (%v, %v)",
+ local, remote, intersection, err,
+ tc.expected, tc.expectedErr)
}
if err != nil {
t.Logf("%s", err)