2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-06-15 13:16:16 +00:00
|
|
|
package pool
|
|
|
|
|
|
|
|
type RPCType byte
|
|
|
|
|
2020-03-09 20:59:02 +00:00
|
|
|
func (t RPCType) ALPNString() string {
|
|
|
|
switch t {
|
|
|
|
case RPCConsul:
|
|
|
|
return ALPN_RPCConsul
|
|
|
|
case RPCRaft:
|
|
|
|
return ALPN_RPCRaft
|
|
|
|
case RPCMultiplex:
|
|
|
|
return "" // unsupported
|
|
|
|
case RPCTLS:
|
|
|
|
return "" // unsupported
|
|
|
|
case RPCMultiplexV2:
|
|
|
|
return ALPN_RPCMultiplexV2
|
|
|
|
case RPCSnapshot:
|
|
|
|
return ALPN_RPCSnapshot
|
|
|
|
case RPCGossip:
|
|
|
|
return ALPN_RPCGossip
|
|
|
|
case RPCTLSInsecure:
|
|
|
|
return "" // unsupported
|
2021-08-24 21:28:44 +00:00
|
|
|
case RPCGRPC:
|
|
|
|
return ALPN_RPCGRPC
|
2020-03-09 20:59:02 +00:00
|
|
|
default:
|
|
|
|
return "" // unsupported
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-15 13:16:16 +00:00
|
|
|
const (
|
|
|
|
// keep numbers unique.
|
|
|
|
RPCConsul RPCType = 0
|
2021-08-24 21:28:44 +00:00
|
|
|
RPCRaft RPCType = 1
|
|
|
|
RPCMultiplex RPCType = 2 // Old Muxado byte, no longer supported.
|
|
|
|
RPCTLS RPCType = 3
|
|
|
|
RPCMultiplexV2 RPCType = 4
|
|
|
|
RPCSnapshot RPCType = 5
|
|
|
|
RPCGossip RPCType = 6
|
2019-06-27 20:22:07 +00:00
|
|
|
// RPCTLSInsecure is used to flag RPC calls that require verify
|
|
|
|
// incoming to be disabled, even when it is turned on in the
|
2020-03-09 20:59:02 +00:00
|
|
|
// configuration. At the time of writing there is only AutoEncrypt.Sign
|
2019-06-27 20:22:07 +00:00
|
|
|
// that is supported and it might be the only one there
|
|
|
|
// ever is.
|
2021-08-24 21:28:44 +00:00
|
|
|
RPCTLSInsecure RPCType = 7
|
|
|
|
RPCGRPC RPCType = 8
|
2019-10-30 13:24:30 +00:00
|
|
|
|
2020-07-22 23:57:29 +00:00
|
|
|
// RPCMaxTypeValue is the maximum rpc type byte value currently used for the
|
|
|
|
// various protocols riding over our "rpc" port.
|
2020-03-09 20:59:02 +00:00
|
|
|
//
|
2020-07-22 23:57:29 +00:00
|
|
|
// Currently our 0-8 values are mutually exclusive with any valid first byte
|
|
|
|
// of a TLS header. The first TLS header byte will begin with a TLS content
|
|
|
|
// type and the values 0-19 are all explicitly unassigned and marked as
|
|
|
|
// requiring coordination. RFC 7983 does the marking and goes into some
|
|
|
|
// details about multiplexing connections and identifying TLS.
|
2020-03-09 20:59:02 +00:00
|
|
|
//
|
|
|
|
// We use this value to determine if the incoming request is actual real
|
2020-07-22 23:57:29 +00:00
|
|
|
// native TLS (where we can de-multiplex based on ALPN protocol) or our older
|
|
|
|
// type-byte system when new connections are established.
|
2020-03-09 20:59:02 +00:00
|
|
|
//
|
|
|
|
// NOTE: if you add new RPCTypes beyond this value, you must similarly bump
|
|
|
|
// this value.
|
2020-07-22 23:57:29 +00:00
|
|
|
RPCMaxTypeValue = 8
|
2017-06-15 13:16:16 +00:00
|
|
|
)
|
2020-03-09 20:59:02 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
// regular old rpc (note there is no equivalent of RPCMultiplex, RPCTLS, or RPCTLSInsecure)
|
|
|
|
ALPN_RPCConsul = "consul/rpc-single" // RPCConsul
|
|
|
|
ALPN_RPCRaft = "consul/raft" // RPCRaft
|
|
|
|
ALPN_RPCMultiplexV2 = "consul/rpc-multi" // RPCMultiplexV2
|
|
|
|
ALPN_RPCSnapshot = "consul/rpc-snapshot" // RPCSnapshot
|
|
|
|
ALPN_RPCGossip = "consul/rpc-gossip" // RPCGossip
|
2020-07-22 23:57:29 +00:00
|
|
|
ALPN_RPCGRPC = "consul/rpc-grpc" // RPCGRPC
|
2020-03-09 20:59:02 +00:00
|
|
|
// wan federation additions
|
|
|
|
ALPN_WANGossipPacket = "consul/wan-gossip/packet"
|
|
|
|
ALPN_WANGossipStream = "consul/wan-gossip/stream"
|
|
|
|
)
|
|
|
|
|
|
|
|
var RPCNextProtos = []string{
|
|
|
|
ALPN_RPCConsul,
|
|
|
|
ALPN_RPCRaft,
|
|
|
|
ALPN_RPCMultiplexV2,
|
|
|
|
ALPN_RPCSnapshot,
|
|
|
|
ALPN_RPCGossip,
|
2021-08-24 21:28:44 +00:00
|
|
|
ALPN_RPCGRPC,
|
2020-03-09 20:59:02 +00:00
|
|
|
ALPN_WANGossipPacket,
|
|
|
|
ALPN_WANGossipStream,
|
|
|
|
}
|