-
Notifications
You must be signed in to change notification settings - Fork 37
OpenStarbound Support #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
453af6b
Bump version to v1.4.2
c06ebeb
use a secret to control image name
0f0be59
Merge branch 'hotfix/v1.4.2'
196d335
Merge tag 'v1.4.2' into develop
32080a2
Bump version to v1.4.3
a1b37d7
remove testing discord kill command
bc6ebf0
Merge branch 'hotfix/v1.4.3'
5760988
Merge tag 'v1.4.3' into develop
bbfb882
Merge branch 'StarryPy:master' into main
evonzee 849aaec
Merge branch 'StarryPy:master' into develop
evonzee 384c0ee
Bump version to 2.0.0
5468a6e
Merge branch 'release/2.0.0'
f581959
Merge tag '2.0.0' into develop
07cca33
fix version file
12c0275
Bump version to v2.0.1
416c2a6
Merge branch 'hotfix/v2.0.1'
8e58fc0
Merge tag 'v2.0.1' into develop
025b7fa
update dependencies
74cccdd
print traceback of exceptions
3d3dffb
add starjson, add it to protocolresponse
9845d29
add opensb detector plugin
b0e5773
working (if slow) zstd reader and writer
98e5937
read larger chunks
2a413d8
working proxy on vanilla opensb
c4da682
don't debuglog the protocol response packet
80a7ece
remove starjson as it is redundant with variant
151265d
eliminate error message in opensb detector
eefe6f4
add dependabot configuration
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v1.4.3 | ||
| v2.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| """ | ||
| StarryPy OpenSB Detector Plugin | ||
|
|
||
| Detects zstd compression for the stream and sets server configuration accordingly | ||
| """ | ||
|
|
||
| import asyncio | ||
|
|
||
| from base_plugin import SimpleCommandPlugin | ||
| from utilities import send_message, Command | ||
|
|
||
|
|
||
| class OpenSBDetector(SimpleCommandPlugin): | ||
| name = "opensb_detector" | ||
|
|
||
| def __init__(self): | ||
| super().__init__() | ||
|
|
||
| async def activate(self): | ||
| await super().activate() | ||
|
|
||
| async def on_protocol_response(self, data, connection): | ||
| # self.logger.debug("Received protocol response: {} from connection {}".format(data, connection)) | ||
| if data["parsed"]["info"]["compression"] == "Zstd": | ||
|
evonzee marked this conversation as resolved.
Outdated
|
||
| self.logger.info("Detected Zstd compression. Setting server configuration.") | ||
| connection.start_zstd() | ||
| return True | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| aiohttp==3.8.4 | ||
| aiohappyeyeballs==2.3.7 | ||
| aiohttp==3.10.4 | ||
| aiosignal==1.3.1 | ||
| async-timeout==4.0.2 | ||
| attrs==23.1.0 | ||
| charset-normalizer==3.1.0 | ||
| discord.py==2.3.1 | ||
| async-timeout==4.0.3 | ||
| attrs==24.2.0 | ||
| charset-normalizer==3.3.2 | ||
| discord.py==2.4.0 | ||
| docopt==0.6.2 | ||
| frozenlist==1.3.3 | ||
| idna==3.4 | ||
| frozenlist==1.4.1 | ||
| idna==3.7 | ||
| irc3==1.1.10 | ||
| multidict==6.0.4 | ||
| venusian==3.0.0 | ||
| yarl==1.9.2 | ||
| multidict==6.0.5 | ||
| venusian==3.1.0 | ||
| yarl==1.9.4 | ||
| zstandard==0.23.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import asyncio | ||
| from io import BufferedReader | ||
| import io | ||
| import zstandard as zstd | ||
|
|
||
| from utilities import Direction | ||
|
|
||
| class ZstdFrameReader: | ||
| def __init__(self, reader: asyncio.StreamReader, direction: Direction): | ||
| self.outputbuffer = NonSeekableMemoryStream() | ||
| self.decompressor = zstd.ZstdDecompressor().stream_writer(self.outputbuffer) | ||
| self.raw_reader = reader | ||
| self.direction = direction | ||
|
|
||
| async def readexactly(self, count): | ||
| # print(f"Reading exactly {count} bytes") | ||
|
|
||
| while True: | ||
| # if there are enough bytes, return them | ||
| if self.outputbuffer.remaining() >= count: | ||
| # print (f"Returning {count} bytes from buffer {self.direction}") | ||
| return self.outputbuffer.read(count) | ||
|
|
||
| # print(f"Reading from network since there are only {self.remaining} bytes in buffer") | ||
| await self.read_from_network(count) | ||
|
|
||
| async def read_from_network(self, target_count): | ||
| while self.outputbuffer.remaining() < target_count: | ||
|
|
||
| chunk = await self.raw_reader.read(32768) # Read in chunks; we'll only get what's available | ||
| # print(f"Read {len(chunk)} bytes from network") | ||
| if not chunk: | ||
| raise asyncio.CancelledError("Connection closed") | ||
| try: | ||
| self.decompressor.write(chunk) | ||
| except zstd.ZstdError: | ||
| print("Zstd error, dropping connection") | ||
| raise asyncio.CancelledError("Error in compressed data stream!") | ||
|
|
||
| class NonSeekableMemoryStream(io.RawIOBase): | ||
| def __init__(self): | ||
| self.buffer = bytearray() | ||
| self.read_pos = 0 | ||
| self.write_pos = 0 | ||
|
|
||
| def write(self, b): | ||
| self.buffer.extend(b) | ||
| self.write_pos += len(b) | ||
| return len(b) | ||
|
|
||
| def read(self, size=-1): | ||
| if size == -1 or size > self.write_pos - self.read_pos: | ||
| size = self.write_pos - self.read_pos | ||
| if size == 0: | ||
| return b'' | ||
| data = self.buffer[self.read_pos:self.read_pos + size] | ||
| self.read_pos += size | ||
| if self.read_pos == self.write_pos: | ||
| self.buffer = bytearray() | ||
| self.read_pos = 0 | ||
| self.write_pos = 0 | ||
| return bytes(data) | ||
|
|
||
| def remaining(self): | ||
| return self.write_pos - self.read_pos | ||
|
|
||
| def readable(self): | ||
| return True | ||
|
|
||
| def writable(self): | ||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import asyncio | ||
| from io import BufferedReader, BytesIO | ||
| import zstandard as zstd | ||
|
|
||
| class ZstdFrameWriter: | ||
| def __init__(self, raw_writer: asyncio.StreamWriter, skip_packets=0): | ||
| self.compressor = zstd.ZstdCompressor() | ||
| self.raw_writer = raw_writer | ||
| self.skip_packets = skip_packets | ||
|
|
||
| async def drain(self): | ||
| await self.raw_writer.drain() | ||
|
|
||
| def close(self): | ||
| self.raw_writer.close() | ||
| self.compressor = None | ||
|
|
||
| def write(self, data): | ||
|
|
||
| if self.skip_packets > 0: | ||
| self.skip_packets -= 1 | ||
| self.raw_writer.write(data) | ||
| return | ||
|
|
||
| self.raw_writer.write(self.compressor.compress(data)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.