Skip to content
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

[WIP] Make PSO2Proxy work in 2021 #220

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 3 additions & 5 deletions proxy/PSO2Proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
import locale
import os

import plugins.plugins as plugin_manager
import plugins.proxyplugins as plugin_manager

from queryProtocols import BlockScraperFactory
from queryProtocols import ShipAdvertiserFactoryPC
from queryProtocols import ShipAdvertiserFactoryVita

import sys

sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout, 'replace')

import time
import traceback
from twisted.internet import endpoints
Expand All @@ -47,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:
Expand All @@ -68,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():
Expand Down
2 changes: 1 addition & 1 deletion proxy/ShipProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion proxy/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import config
import packetFactory
import plugins.plugins as plugin_manager
import plugins.proxyplugins as plugin_manager
from ShipProxy import ShipProxy


Expand Down
6 changes: 3 additions & 3 deletions proxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions proxy/data/clients.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import blocks
from . import blocks
import config
import packetFactory
import sqlite3
from threading import Lock
import twisted
import yaml

from ships import get_ship_from_port
from .ships import get_ship_from_port

connectedClients = {}
"""
Expand Down
2 changes: 1 addition & 1 deletion proxy/data/ships.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import blocks
from . import blocks
from config import bindIp
from config import brokenlist
from config import myIpAddress as myIp
Expand Down
2 changes: 1 addition & 1 deletion proxy/packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions proxy/plugins/EQ_Alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion proxy/plugins/GlobalChat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion proxy/plugins/LoginMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion proxy/plugins/maint.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import commands
import packetFactory
from packetFactory import SystemMessagePacket
import plugins
import plugins.proxyplugins as plugins
maintmode = False


Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions proxy/queryProtocols.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()


Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Twisted >= 14.0.0
pycrypto >= 2.6.1
pyyaml
faulthandler