Im trying to make a proxy and forward it to my ip, but it don't work. I tried normal server and it worked (i have antivirus firewall and when i tried doing with proxy it didnt show connection, but with normal server it connected).
My code:
`from twisted.internet import reactor
from quarry.net.proxy import DownstreamFactory, Bridge
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()
print("up >" + p_text)
return p_text
elif direction == "downstream":
p_text = str(buff.unpack_chat())
p_pos = str(buff.unpack_position())
print("down >" + p_text + " > pos > " + p_pos)
# 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 QuietDownstreamFactory(DownstreamFactory):
bridge_class = QuietBridge
motd = "skyland budowanie"
Im trying to make a proxy and forward it to my ip, but it don't work. I tried normal server and it worked (i have antivirus firewall and when i tried doing with proxy it didnt show connection, but with normal server it connected).
My code: `from twisted.internet import reactor from quarry.net.proxy import DownstreamFactory, Bridge
class QuietBridge(Bridge): quiet_mode = False
class QuietDownstreamFactory(DownstreamFactory): bridge_class = QuietBridge motd = "skyland budowanie"
def main(argv):
Parse options
if name == "main": import sys main(sys.argv[1:])`