Comments (2)
Actually, I tried to turn the Proxy into offline mode, then I created a profile in a new QuietUpstreamFactory instead of in QuietBridge, and now I get this:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\twisted\python\log.py", line 101, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "C:\Python34\lib\site-packages\twisted\python\log.py", line 84, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "C:\Python34\lib\site-packages\twisted\python\context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "C:\Python34\lib\site-packages\twisted\python\context.py", line 81, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "C:\Python34\lib\site-packages\twisted\internet\selectreactor.py", line 149, in _doReadOrWrite
why = getattr(selectable, method)()
File "C:\Python34\lib\site-packages\twisted\internet\tcp.py", line 209, in doRead
return self._dataReceived(data)
File "C:\Python34\lib\site-packages\twisted\internet\tcp.py", line 215, in _dataReceived
rval = self.protocol.dataReceived(data)
File "C:\Python34\lib\site-packages\quarry\net\protocol.py", line 98, in dataReceived
return self.data_received(data)
File "C:\Python34\lib\site-packages\quarry\net\protocol.py", line 264, in data_received
self.packet_received(packet_buff, name)
File "C:\Python34\lib\site-packages\quarry\net\protocol.py", line 284, in packet_received
dispatched = self.dispatch((name,), buff)
File "C:\Python34\lib\site-packages\quarry\net\protocol.py", line 28, in dispatch
handler(buff)
File "C:\Python34\lib\site-packages\quarry\net\server.py", line 151, in packet_login_start
self.uuid = types.UUID.from_offline_player(self.username)
File "C:\Python34\lib\site-packages\quarry\util\types.py", line 16, in from_offline_player
base_uuid = uuid.uuid3(FakeNamespace(), username)
File "C:\Python34\lib\uuid.py", line 561, in uuid3
hash = md5(namespace.bytes + bytes(name, "utf-8")).digest()
builtins.TypeError: Can't convert 'bytes' object to str implicitly
probably because of python 3.
from quarry.
Here's my changed proxy.py:
"""
"Quiet mode" example proxy
Allows a client to turn on "quiet mode" which hides chat messages
"""
from quarry.net.proxy import UpstreamFactory, DownstreamFactory, Bridge
from quarry.mojang.profile import Profile
import getpass
class QuietBridge(Bridge):
quiet_mode = False
def packet_upstream_chat_message(self, buff):
buff.save()
chat_message = self.read_chat(buff, "upstream")
self.logger.info(" >> %s" % chat_message)
if chat_message.startswith("/quiet"):
# Switch mode
self.quiet_mode = not self.quiet_mode
action = self.quiet_mode and "enabled" or "disabled"
msg = "Quiet mode %s" % action
self.downstream.send_packet("chat_message",
self.write_chat(msg, "downstream"))
elif self.quiet_mode and not chat_message.startswith("/"):
# Don't let the player send chat messages in quiet mode
msg = "Can't send messages while in quiet mode"
self.downstream.send_packet("chat_message",
self.write_chat(msg, "downstream"))
else:
# Pass to upstream
buff.restore()
self.upstream.send_packet("chat_message", buff.read())
def packet_downstream_chat_message(self, buff):
chat_message = self.read_chat(buff, "downstream")
self.logger.info(" :: %s" % chat_message)
if self.quiet_mode and chat_message.startswith("<"):
# Ignore message we're in quiet mode and it looks like chat
pass
else:
# Pass to downstream
buff.restore()
self.downstream.send_packet("chat_message", buff.read())
def read_chat(self, buff, direction):
buff.save()
if direction == "upstream":
p_text = buff.unpack_string()
return p_text
elif direction == "downstream":
p_text = buff.unpack_chat()
# 1.7.x
if self.upstream.protocol_version <= 5:
p_position = 0
# 1.8.x
else:
p_position = buff.unpack('B')
if p_position in (0, 1):
return p_text
def write_chat(self, text, direction):
if direction == "upstream":
return self.buff_type.pack_string(text)
elif direction == "downstream":
data = self.buff_type.pack_chat(text)
# 1.7.x
if self.downstream.protocol_version <= 5:
pass
# 1.8.x
else:
data += self.buff_type.pack('B', 0)
return data
class QuietUpstreamFactory(UpstreamFactory):
profile = Profile()
profile.username = "MyUsername"
profile.login("[email protected]", getpass.getpass())
class QuietDownstreamFactory(DownstreamFactory):
bridge_class = QuietBridge
upstream_factory_class = QuietUpstreamFactory
motd = "Proxy Server"
online_mode = False
def main(args):
# Parse options
import optparse
parser = optparse.OptionParser(
usage="usage: %prog [options] <connect-host> <connect-port>")
parser.add_option("-a", "--listen-host",
dest="listen_host", default="",
help="address to listen on")
parser.add_option("-p", "--listen-port",
dest="listen_port", default="25565", type="int",
help="port to listen on")
(options, args) = parser.parse_args(args)
if len(args) != 2:
return parser.print_usage()
# Create factory
factory = QuietDownstreamFactory()
factory.motd = "Proxy Server"
factory.connect_host = args[0]
factory.connect_port = int(args[1])
# Listen
factory.listen(options.listen_host, options.listen_port)
factory.run()
if __name__ == "__main__":
import sys
main(sys.argv[1:])
from quarry.
Related Issues (20)
- Possible to get block player placed? HOT 2
- Examples issues HOT 2
- Port Forwarding a proxy HOT 2
- I got this error
- fcntl not found HOT 1
- According to wiki.vg this data type is wrong. And how to respond to tab completes? HOT 7
- import quarry.net.proxy could not be resolved HOT 1
- The chat logger example doesn't work, microsoft login. HOT 3
- 1.19.3 is not supported HOT 2
- Issue with spoofing client messages HOT 2
- errors when using client_player_list.py HOT 2
- The skeleton client from readthedocs does not work for me HOT 3
- How to create a dynamic proxy? HOT 1
- Support for 1.19 is purely fictional. HOT 5
- 1.20
- How do i get "quarry" to run (E:\quarry-master\examples\proxy_hide_chat.py) HOT 2
- quarry.net.protocol.ProtocolError: Packet is too long: chat_message
- 到1.20.2
- Why is this project called "quarry"? What is the name backstory?
- Readme should clarify if quarry can act as a client, a server, or both.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quarry.