Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
106ed0be
Commit
106ed0be
authored
Mar 14, 2024
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proto/msgpack: Fix handshake magic
This fixes the basic NEO handshake in msgpack encoding.
parent
8effc6be
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
go/neo/neonet/newlink.go
go/neo/neonet/newlink.go
+6
-10
No files found.
go/neo/neonet/newlink.go
View file @
106ed0be
...
...
@@ -216,7 +216,7 @@ func _handshakeServer(ctx context.Context, conn net.Conn, version uint32) (enc p
// handshake hello:
//
// - 00 00 00 <ver> for 'N' encoding, and
// - 92
c4 0
3 NEO ... for 'M' encoding (= msgpack of (b"NEO", <ver>))
// - 92
a
3 NEO ... for 'M' encoding (= msgpack of (b"NEO", <ver>))
//
// the first byte is different from TLS handshake (0x16).
...
...
@@ -234,9 +234,9 @@ func txHello(errctx string, conn net.Conn, version uint32, enc proto.Encoding) (
b
[
3
]
=
uint8
(
version
)
case
'M'
:
// (b"NEO", <V>) encoded as msgpack (= 92
c4 0
3 NEO int(<V>))
// (b"NEO", <V>) encoded as msgpack (= 92
a
3 NEO int(<V>))
b
=
msgp
.
AppendArrayHeader
(
b
,
2
)
// 92
b
=
msgp
.
Append
Bytes
(
b
,
[]
byte
(
"NEO"
))
// c4 0
3 NEO
b
=
msgp
.
Append
String
(
b
,
"NEO"
)
// a
3 NEO
b
=
msgp
.
AppendUint32
(
b
,
version
)
// u?intX version
default
:
...
...
@@ -269,24 +269,20 @@ func rxHello(errctx string, rx *xbufReader) (enc proto.Encoding, version uint32,
peerEnc
=
'N'
peerVer
=
uint32
(
b
[
3
])
case
bytes
.
Equal
(
b
,
[]
byte
{
0x92
,
0x
c4
,
3
,
'N'
})
:
// start of "fixarray<2> bin8 'N | E
O' ...
case
bytes
.
Equal
(
b
,
[]
byte
{
0x92
,
0x
a3
,
'N'
,
'E'
})
:
// start of "fixarray<2> bin8 'NE |
O' ...
b
=
append
(
b
,
[]
byte
{
0
,
0
}
...
)
_
,
err
=
io
.
ReadFull
(
rx
,
b
[
4
:
])
err
=
xio
.
NoEOF
(
err
)
if
err
!=
nil
{
return
0
,
0
,
err
}
if
!
bytes
.
Equal
(
b
[
4
:
],
[]
byte
{
'E'
,
'O'
})
{
if
!
bytes
.
Equal
(
b
[
4
:
5
],
[]
byte
{
'O'
})
{
badMagic
=
true
break
}
peerEnc
=
'M'
rxM
:=
msgp
.
Reader
{
R
:
rx
.
Reader
}
peerVer
,
err
=
rxM
.
ReadUint32
()
if
err
!=
nil
{
return
0
,
0
,
fmt
.
Errorf
(
"M: recv peer version: %s"
,
err
)
// XXX + "read magic" ctx
}
peerVer
=
uint32
(
b
[
5
])
default
:
badMagic
=
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment