refactor: make protocol message tags a separate type
This commit is contained in:
1 parent
a1ef2def2b
commit
644697977b
2 files changed
+11
-9
No files matched your search
@@ -530,7 +530,7 @@ func (conn *LocalConnection) receiveTCP(decoder *gob.Decoder) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
payload := msg[1:]
|
payload := msg[1:]
|
||||||
switch msg[0] {
|
switch ProtocolMsg(msg[0]) {
|
||||||
case ProtocolConnectionEstablished:
|
case ProtocolConnectionEstablished:
|
||||||
// We sent fast heartbeats to the remote peer, which has
|
// We sent fast heartbeats to the remote peer, which has
|
||||||
// now received at least one of them and told us via this
|
// now received at least one of them and told us via this
|
||||||
|
|||||||
+10
-8
@@ -5,8 +5,10 @@ const (
|
|||||||
ProtocolVersion = 10
|
ProtocolVersion = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ProtocolMsg byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ProtocolConnectionEstablished = iota
|
ProtocolConnectionEstablished ProtocolMsg = iota
|
||||||
ProtocolFragmentationReceived
|
ProtocolFragmentationReceived
|
||||||
ProtocolStartFragmentationTest
|
ProtocolStartFragmentationTest
|
||||||
ProtocolNonce
|
ProtocolNonce
|
||||||
@@ -16,11 +18,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ProtocolConnectionEstablishedByte = []byte{ProtocolConnectionEstablished}
|
ProtocolConnectionEstablishedByte = []byte{byte(ProtocolConnectionEstablished)}
|
||||||
ProtocolFragmentationReceivedByte = []byte{ProtocolFragmentationReceived}
|
ProtocolFragmentationReceivedByte = []byte{byte(ProtocolFragmentationReceived)}
|
||||||
ProtocolStartFragmentationTestByte = []byte{ProtocolStartFragmentationTest}
|
ProtocolStartFragmentationTestByte = []byte{byte(ProtocolStartFragmentationTest)}
|
||||||
ProtocolNonceByte = []byte{ProtocolNonce}
|
ProtocolNonceByte = []byte{byte(ProtocolNonce)}
|
||||||
ProtocolFetchAllByte = []byte{ProtocolFetchAll}
|
ProtocolFetchAllByte = []byte{byte(ProtocolFetchAll)}
|
||||||
ProtocolUpdateByte = []byte{ProtocolUpdate}
|
ProtocolUpdateByte = []byte{byte(ProtocolUpdate)}
|
||||||
ProtocolPMTUVerifiedByte = []byte{ProtocolPMTUVerified}
|
ProtocolPMTUVerifiedByte = []byte{byte(ProtocolPMTUVerified)}
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user