Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IoT Capstone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cooper Little
IoT Capstone
Commits
dab4e40d
Commit
dab4e40d
authored
1 year ago
by
Capstone 2023
Browse files
Options
Downloads
Patches
Plain Diff
Lowered frame size for initial websocket frame.
parent
ab5e8314
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
threeamigosrpc.py
+8
-3
8 additions, 3 deletions
threeamigosrpc.py
with
8 additions
and
3 deletions
threeamigosrpc.py
+
8
−
3
View file @
dab4e40d
...
...
@@ -24,7 +24,7 @@ def construct_frame_header(kind='text', final=False, length=0, use_mask=True):
B1
=
(
final
<<
7
)
|
opcode
frame_extra_length
=
b
''
small_length
=
length
if
length
>
2
**
6
4
-
1
:
if
length
>
2
**
6
3
-
1
:
raise
Exception
(
f
'
Frames cannot have a payload this big, max is a 64 bit unsigned integer, and this number is:
{
length
}
'
)
elif
length
>
2
**
16
-
1
:
frame_extra_length
=
struct
.
pack
(
'
!Q
'
,
length
)
...
...
@@ -54,11 +54,13 @@ def get_frame_header(data, ):
return
header
,
data
length_data
,
rest_of_data
=
rest_of_data
[:
2
],
rest_of_data
[
2
:]
length
=
struct
.
unpack
(
'
!H
'
,
length_data
)[
0
]
length
-=
2
elif
small_length
==
127
:
if
len
(
rest_of_data
)
<
8
:
return
header
,
data
length_data
,
rest_of_data
=
rest_of_data
[:
8
],
rest_of_data
[
8
:]
length
=
struct
.
unpack
(
'
!Q
'
,
length_data
)[
0
]
length
-=
8
else
:
length
=
small_length
...
...
@@ -67,6 +69,7 @@ def get_frame_header(data, ):
if
len
(
rest_of_data
)
<
4
:
return
header
,
data
mask
,
rest_of_data
=
rest_of_data
[:
4
],
rest_of_data
[
4
:]
length
-=
4
header
=
{
'
length
'
:
length
,
'
finish
'
:
finish
,
'
opcode
'
:
opcode
,
'
mask
'
:
mask
}
...
...
@@ -76,6 +79,8 @@ def get_frame_header(data, ):
return
header
,
rest_of_data
# About 3GB:
FRAME_LENGTH
=
(
2
**
34
//
5
)
# 2**63-1
class
AmigosConnectionClosed
(
Exception
):
pass
...
...
@@ -142,7 +147,7 @@ class AmigosRPC:
# Pretent this is pretty much an infinitely long frame (amigos rpc)
head
=
self
.
_recieve_http_header
()
frame_header
,
mask
=
construct_frame_header
(
kind
=
'
binary
'
,
final
=
True
,
length
=
2
**
64
-
1
)
frame_header
,
mask
=
construct_frame_header
(
kind
=
'
binary
'
,
final
=
True
,
length
=
FRAME_LENGTH
)
self
.
sock
.
send
(
frame_header
)
self
.
_recieve_websock_header
()
...
...
@@ -168,7 +173,7 @@ class AmigosRPC:
self
.
sock
.
send
(
send_this
)
self
.
_recieve_websock_header
()
frame_header
,
mask
=
construct_frame_header
(
kind
=
'
binary
'
,
final
=
True
,
length
=
2
**
64
-
1
)
frame_header
,
mask
=
construct_frame_header
(
kind
=
'
binary
'
,
final
=
True
,
length
=
FRAME_LENGTH
)
self
.
sock
.
send
(
frame_header
)
def
accept
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment