From 5002cccedb1ba8599323e8f517b16bc81b0e864b Mon Sep 17 00:00:00 2001 From: CyberKitsune Date: Tue, 15 Jun 2021 14:46:52 -0700 Subject: [PATCH 1/5] Faulthandler is a built-in module since python 3.3 --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f0528cf..5694fdc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ Twisted >= 14.0.0 pycrypto >= 2.6.1 pyyaml -faulthandler \ No newline at end of file From 4dd85a41b1b79a8eed9df23da6b348a2f7966364 Mon Sep 17 00:00:00 2001 From: CyberKitsune Date: Tue, 15 Jun 2021 14:54:52 -0700 Subject: [PATCH 2/5] Packaging issues --- README.md | 1 - proxy/data/clients.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c93f1db..2aef4d6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ PSO2Proxy is a open source protocol proxy for the Japanese MMORPG, Phantasy Star This program allows you to host your own PSO2Proxy on a server you have access to. **If you just want to play the game via the proxy, a public PSO2Proxy server is available for users who can't connect to PSO2 and users who want to contribute data for packet analysis. This server can be found at [pso2proxy.cyberkitsune.net](http://pso2proxy.cyberkitsune.net/). Below are the instructions for installing and setting up your own PSO2Proxy server.** -If you require assistance, feel free to contact us on [IRC](irc://irc.badnik.zone/pso2proxypublic): irc.badnik.zone, #pso2proxypublic ## Installing PSO2Proxy uses the [Twisted Framework](https://twistedmatrix.com/trac/) and [PyCrypto](https://www.dlitz.net/software/pycrypto/). Please install these from their respective websites or use the commands below depending on your distribution. diff --git a/proxy/data/clients.py b/proxy/data/clients.py index 1368361..aabe63f 100644 --- a/proxy/data/clients.py +++ b/proxy/data/clients.py @@ -1,4 +1,4 @@ -import blocks +from . import blocks import config import packetFactory import sqlite3 From 23b1dfff3211e6fcd5a0ce0b13068751f0244a67 Mon Sep 17 00:00:00 2001 From: CyberKitsune Date: Tue, 15 Jun 2021 14:59:13 -0700 Subject: [PATCH 3/5] We don't need this in python3 anymore --- proxy/PSO2Proxy.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/proxy/PSO2Proxy.py b/proxy/PSO2Proxy.py index 3dfcecf..1024172 100755 --- a/proxy/PSO2Proxy.py +++ b/proxy/PSO2Proxy.py @@ -25,8 +25,6 @@ import sys -sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout, 'replace') - import time import traceback from twisted.internet import endpoints From b15f31ce1d6fd2dc65baacf24df2d8e41412c3d9 Mon Sep 17 00:00:00 2001 From: CyberKitsune Date: Tue, 15 Jun 2021 15:03:27 -0700 Subject: [PATCH 4/5] Packaging and type fixes --- proxy/config.py | 6 +++--- proxy/data/clients.py | 2 +- proxy/data/ships.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proxy/config.py b/proxy/config.py index cfff0a9..35241d4 100644 --- a/proxy/config.py +++ b/proxy/config.py @@ -102,7 +102,7 @@ def __setitem__(self, key, value): blockNames = {} ShipLabel = {} -proxy_ver = subprocess.Popen(["git", "describe", "--always"], stdout=subprocess.PIPE).communicate()[0].rstrip("\n") +proxy_ver = str(str(subprocess.Popen(["git", "describe", "--always"], stdout=subprocess.PIPE).communicate()[0]).rstrip("\n")) def is_admin(sega_id): @@ -117,9 +117,9 @@ def load_block_names(): if globalConfig['blockNameMode'] == 0: return "[ShipProxy] Blocks are not renamed" if os.path.exists("cfg/blocknames.resources.json"): - f = open("cfg/blocknames.resources.json", 'r') + f = open("cfg/blocknames.resources.json", 'r', encoding='utf-8') try: - blockNames = json.load(f, encoding='utf-8') + blockNames = json.load(f) f.close() return ("[ShipProxy] %s Block names loaded!" % len(blockNames)) except ValueError: diff --git a/proxy/data/clients.py b/proxy/data/clients.py index aabe63f..2645d66 100644 --- a/proxy/data/clients.py +++ b/proxy/data/clients.py @@ -6,7 +6,7 @@ import twisted import yaml -from ships import get_ship_from_port +from .ships import get_ship_from_port connectedClients = {} """ diff --git a/proxy/data/ships.py b/proxy/data/ships.py index 8c295c7..6f74bc0 100644 --- a/proxy/data/ships.py +++ b/proxy/data/ships.py @@ -1,4 +1,4 @@ -import blocks +from . import blocks from config import bindIp from config import brokenlist from config import myIpAddress as myIp From b16aef1c3647f856d0d2bce3b33b0649a0895fd3 Mon Sep 17 00:00:00 2001 From: CyberKitsune Date: Tue, 15 Jun 2021 15:21:12 -0700 Subject: [PATCH 5/5] Bunch more stuff --- proxy/PSO2Proxy.py | 6 +++--- proxy/ShipProxy.py | 2 +- proxy/commands.py | 2 +- proxy/packets.py | 2 +- proxy/plugins/EQ_Alert.py | 4 ++-- proxy/plugins/GlobalChat.py | 2 +- proxy/plugins/LoginMessage.py | 2 +- proxy/plugins/maint.py | 2 +- proxy/plugins/{plugins.py => proxyplugins.py} | 0 proxy/queryProtocols.py | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) rename proxy/plugins/{plugins.py => proxyplugins.py} (100%) diff --git a/proxy/PSO2Proxy.py b/proxy/PSO2Proxy.py index 1024172..3364711 100755 --- a/proxy/PSO2Proxy.py +++ b/proxy/PSO2Proxy.py @@ -17,7 +17,7 @@ import locale import os -import plugins.plugins as plugin_manager +import plugins.proxyplugins as plugin_manager from queryProtocols import BlockScraperFactory from queryProtocols import ShipAdvertiserFactoryPC @@ -45,7 +45,7 @@ def __init__(self): self.delimiter = os.linesep def connectionMade(self): - self.transport.write('>>> '.encode("utf-8")) + self.transport.write(b'>>> ') def lineReceived(self, line): try: @@ -66,7 +66,7 @@ def lineReceived(self, line): except Exception as e: e = traceback.format_exc() print("[ShipProxy] Error Occurred: %s" % e) - self.transport.write('>>> ') + self.transport.write(b'>>> ') def main(): diff --git a/proxy/ShipProxy.py b/proxy/ShipProxy.py index beb9147..80ab0a2 100644 --- a/proxy/ShipProxy.py +++ b/proxy/ShipProxy.py @@ -4,7 +4,7 @@ from data import clients import datetime import packets -import plugins.plugins as plugin_manager +import plugins.proxyplugins as plugin_manager import struct from twisted.internet import protocol from twisted.internet import reactor diff --git a/proxy/commands.py b/proxy/commands.py index 708df22..8e9b86f 100644 --- a/proxy/commands.py +++ b/proxy/commands.py @@ -19,7 +19,7 @@ import config import packetFactory -import plugins.plugins as plugin_manager +import plugins.proxyplugins as plugin_manager from ShipProxy import ShipProxy diff --git a/proxy/packets.py b/proxy/packets.py index 7f26201..0d0b42e 100644 --- a/proxy/packets.py +++ b/proxy/packets.py @@ -10,7 +10,7 @@ import data.players as players import io import packetFactory -import plugins.plugins as plugin_manager +import plugins.proxyplugins as plugin_manager from PSO2DataTools import replace_with_table from PSOCryptoUtils import PSO2RC4 from PSOCryptoUtils import PSO2RSADecrypt diff --git a/proxy/plugins/EQ_Alert.py b/proxy/plugins/EQ_Alert.py index 6175e46..72915a0 100644 --- a/proxy/plugins/EQ_Alert.py +++ b/proxy/plugins/EQ_Alert.py @@ -5,7 +5,7 @@ from datetime import datetime import json import packetFactory -import plugins +import plugins.proxyplugins as plugins from pprint import pformat from twisted.internet import defer from twisted.internet import protocol @@ -205,7 +205,7 @@ def CheckupURL(): HTTPHeaderX.addRawHeader('If-None-Match', ETag_Header) if Modified_Header: HTTPHeaderX.addRawHeader('If-Modified-Since', Modified_Header) - EQ0 = agent.request('GET', eq_URL, HTTPHeaderX) + EQ0 = agent.request(bytes('GET', encoding='utf8'), bytes(eq_URL, encoding='utf8'), HTTPHeaderX) EQ0.addCallback(EQResponse) EQ0.addErrback(log.err) diff --git a/proxy/plugins/GlobalChat.py b/proxy/plugins/GlobalChat.py index 34efa76..6580f42 100644 --- a/proxy/plugins/GlobalChat.py +++ b/proxy/plugins/GlobalChat.py @@ -5,7 +5,7 @@ import data.players import json import packetFactory -import plugins +import plugins.proxyplugins as plugins from PSO2DataTools import check_irc_with_pso2 from PSO2DataTools import check_pso2_with_irc from PSO2DataTools import replace_irc_with_pso2 diff --git a/proxy/plugins/LoginMessage.py b/proxy/plugins/LoginMessage.py index 8b8a23b..a3652bf 100644 --- a/proxy/plugins/LoginMessage.py +++ b/proxy/plugins/LoginMessage.py @@ -2,7 +2,7 @@ import config import data.clients import packetFactory -import plugins +import plugins.proxyplugins as plugins login_config = config.YAMLConfig( "cfg/loginmessage.config.yml", diff --git a/proxy/plugins/maint.py b/proxy/plugins/maint.py index a931848..25b9550 100644 --- a/proxy/plugins/maint.py +++ b/proxy/plugins/maint.py @@ -1,7 +1,7 @@ import commands import packetFactory from packetFactory import SystemMessagePacket -import plugins +import plugins.proxyplugins as plugins maintmode = False diff --git a/proxy/plugins/plugins.py b/proxy/plugins/proxyplugins.py similarity index 100% rename from proxy/plugins/plugins.py rename to proxy/plugins/proxyplugins.py diff --git a/proxy/queryProtocols.py b/proxy/queryProtocols.py index 458b502..12ca95c 100644 --- a/proxy/queryProtocols.py +++ b/proxy/queryProtocols.py @@ -1,7 +1,7 @@ from config import myIpAddress from config import noisy as verbose import data.ships as ships -import plugins.plugins +import plugins.proxyplugins from twisted.internet import protocol from twisted.internet import threads @@ -24,7 +24,7 @@ def connectionMade(self): ships.get_first_block(port, myIpAddress) def send_block_scrape(self, data): - self.transport.write(data) + self.transport.write(bytes(data)) self.transport.loseConnection()