mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
The game now allows you in, and pulled Jumble's ssl, ban, and chat changes.
This commit is contained in:
parent
5f431480d2
commit
5018215e74
4 changed files with 90 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from toontown.uberdog.ClientServicesManagerUD import executeHttpRequest
|
from toontown.uberdog.ClientServicesManagerUD import executeHttpRequest
|
||||||
import datetime
|
import time
|
||||||
from direct.fsm.FSM import FSM
|
from direct.fsm.FSM import FSM
|
||||||
from direct.distributed.PyDatagram import PyDatagram
|
from direct.distributed.PyDatagram import PyDatagram
|
||||||
from direct.distributed.MsgTypes import *
|
from direct.distributed.MsgTypes import *
|
||||||
|
@ -22,9 +22,9 @@ class BanFSM(FSM):
|
||||||
self.accountId = None
|
self.accountId = None
|
||||||
self.avName = None
|
self.avName = None
|
||||||
|
|
||||||
def performBan(self, bannedUntil):
|
def performBan(self, duration):
|
||||||
executeHttpRequest('accounts/ban/', Id=self.accountId, Release=bannedUntil,
|
executeHttpRequest('ban', username=self.accountId, start=int(time.time()),
|
||||||
Reason=self.comment)
|
duration=duration, reason=self.comment, bannedby='todo')
|
||||||
|
|
||||||
def ejectPlayer(self):
|
def ejectPlayer(self):
|
||||||
av = self.air.doId2do.get(self.avId)
|
av = self.air.doId2do.get(self.avId)
|
||||||
|
@ -49,15 +49,9 @@ class BanFSM(FSM):
|
||||||
if not self.accountId:
|
if not self.accountId:
|
||||||
return
|
return
|
||||||
|
|
||||||
date = datetime.date.today()
|
|
||||||
if simbase.config.GetBool('want-bans', True):
|
if simbase.config.GetBool('want-bans', True):
|
||||||
if self.duration == 0:
|
self.performBan(self.duration)
|
||||||
bannedUntil = "0000-00-00" # Terminated.
|
|
||||||
else:
|
|
||||||
bannedUntil = date + datetime.timedelta(days=self.duration)
|
|
||||||
|
|
||||||
self.duration = None
|
self.duration = None
|
||||||
self.performBan(bannedUntil)
|
|
||||||
|
|
||||||
def getAvatarDetails(self):
|
def getAvatarDetails(self):
|
||||||
av = self.air.doId2do.get(self.avId)
|
av = self.air.doId2do.get(self.avId)
|
||||||
|
@ -143,4 +137,4 @@ def ban(reason, duration):
|
||||||
if reason not in ('hacking', 'language', 'other'):
|
if reason not in ('hacking', 'language', 'other'):
|
||||||
return "'%s' is not a valid reason." % reason
|
return "'%s' is not a valid reason." % reason
|
||||||
simbase.air.banManager.ban(target.doId, duration, reason)
|
simbase.air.banManager.ban(target.doId, duration, reason)
|
||||||
return "Banned %s from the game server!" % target.getName()
|
return "Banned %s from the game server!" % target.getName()
|
|
@ -773,9 +773,34 @@ class ToontownRPCHandler(ToontownRPCHandlerBase):
|
||||||
oldFields = {'setWishNameState': 'PENDING'}
|
oldFields = {'setWishNameState': 'PENDING'}
|
||||||
return self.rpc_updateObject(
|
return self.rpc_updateObject(
|
||||||
avId, 'DistributedToonUD', newFields, oldFields=oldFields)
|
avId, 'DistributedToonUD', newFields, oldFields=oldFields)
|
||||||
|
|
||||||
@rpcmethod(accessLevel=MODERATOR)
|
@rpcmethod(accessLevel=MODERATOR)
|
||||||
def rpc_setChatSettings(self, accId, chatSettings):
|
def rpc_getChatSettings(self, accId):
|
||||||
|
"""
|
||||||
|
Summary:
|
||||||
|
Retrieves the chat settings of the account associated with the provided
|
||||||
|
[accId].
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
[int accId] = The ID of the account whose chat settings
|
||||||
|
are to be retreived.
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
On success: [uint8[sp+, tf]]
|
||||||
|
On failure: False
|
||||||
|
"""
|
||||||
|
dclassName, fields = self.rpc_queryObject(int(accId))
|
||||||
|
if dclassName == 'Account':
|
||||||
|
if 'CHAT_SETTINGS' in fields:
|
||||||
|
return fields['CHAT_SETTINGS']
|
||||||
|
# The chat settings haven't been set yet, so we'll
|
||||||
|
# want to do that now.
|
||||||
|
self.rpc_setChatSettings(accId)
|
||||||
|
return [1, 1]
|
||||||
|
return False
|
||||||
|
|
||||||
|
@rpcmethod(accessLevel=MODERATOR)
|
||||||
|
def rpc_setChatSettings(self, accId, speedChatPlus = 1, trueFriends = 1):
|
||||||
"""
|
"""
|
||||||
Summary:
|
Summary:
|
||||||
Sets the chat settings of the account associated with the provided
|
Sets the chat settings of the account associated with the provided
|
||||||
|
@ -791,4 +816,5 @@ class ToontownRPCHandler(ToontownRPCHandlerBase):
|
||||||
On success: True
|
On success: True
|
||||||
On failure: False
|
On failure: False
|
||||||
"""
|
"""
|
||||||
return self.rpc_updateObject(accId, 'AccountUD', {'CHAT_SETTINGS': chatSettings})
|
return self.rpc_updateObject(accId, 'AccountUD', {'CHAT_SETTINGS':
|
||||||
|
[int(speedChatPlus), int(trueFriends)]})
|
|
@ -1,22 +1,31 @@
|
||||||
import json
|
import json, os, sys
|
||||||
import os
|
import urllib, urllib2, cookielib, socket
|
||||||
import requests
|
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
|
||||||
|
|
||||||
|
req_version = (2,7,9)
|
||||||
|
cur_version = sys.version_info
|
||||||
|
if cur_version < req_version:
|
||||||
|
print 'Your version of python is too old. Please upgrade to 2.7.9.'
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
username = os.environ['ttsUsername']
|
username = os.environ['ttsUsername']
|
||||||
password = os.environ['ttsPassword']
|
password = os.environ['ttsPassword']
|
||||||
|
distribution = 'qa'
|
||||||
|
|
||||||
accountServerEndpoint = 'http://www.toontownstride.com/api/'
|
accountServerEndpoint = 'https://toontownstride.com/api/'
|
||||||
session = requests.Session()
|
|
||||||
csrf_query = session.get(accountServerEndpoint + 'login/')
|
data = urllib.urlencode({'username': username, 'password': password, 'distribution': distribution})
|
||||||
csrf = session.cookies.get_dict().get('csrftoken', '')
|
cookie_jar = cookielib.LWPCookieJar()
|
||||||
request = session.post(
|
cookie = urllib2.HTTPCookieProcessor(cookie_jar)
|
||||||
accountServerEndpoint + 'login/',
|
opener = urllib2.build_opener(cookie)
|
||||||
data={'username': username, 'password': password, 'csrfmiddlewaretoken': csrf})
|
req = urllib2.Request(accountServerEndpoint + 'login', data,
|
||||||
|
headers={"Content-Type" : "application/x-www-form-urlencoded"})
|
||||||
|
req.get_method = lambda: "POST"
|
||||||
|
_response = opener.open(req).read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = json.loads('{'+request.text.split('{', 1)[1]) # so that we ignore the csrf token
|
response = json.loads(_response)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print "Couldn't verify account credentials."
|
print "Couldn't verify account credentials."
|
||||||
else:
|
else:
|
||||||
|
@ -27,4 +36,4 @@ else:
|
||||||
os.environ['TTS_GAMESERVER'] = response['gameserver']
|
os.environ['TTS_GAMESERVER'] = response['gameserver']
|
||||||
|
|
||||||
# Start the game:
|
# Start the game:
|
||||||
import toontown.toonbase.ToontownStart
|
import toontown.toonbase.ToontownStart
|
|
@ -16,6 +16,7 @@ from panda3d.core import *
|
||||||
import hashlib, hmac, json
|
import hashlib, hmac, json
|
||||||
import anydbm, math, os
|
import anydbm, math, os
|
||||||
import urllib2, time, urllib
|
import urllib2, time, urllib
|
||||||
|
import cookielib, socket
|
||||||
|
|
||||||
def rejectConfig(issue, securityIssue=True, retarded=True):
|
def rejectConfig(issue, securityIssue=True, retarded=True):
|
||||||
print
|
print
|
||||||
|
@ -72,16 +73,21 @@ minAccessLevel = config.GetInt('min-access-level', 100)
|
||||||
def executeHttpRequest(url, **extras):
|
def executeHttpRequest(url, **extras):
|
||||||
# TO DO: THIS IS QUITE DISGUSTING
|
# TO DO: THIS IS QUITE DISGUSTING
|
||||||
# MOVE THIS TO ToontownInternalRepository (this might be interesting for AI)
|
# MOVE THIS TO ToontownInternalRepository (this might be interesting for AI)
|
||||||
|
##### USE PYTHON 2.7.9 ON PROD WITH SSL AND CLOUDFLARE #####
|
||||||
_data = {}
|
_data = {}
|
||||||
if len(extras.items()) != 0:
|
if len(extras.items()) != 0:
|
||||||
for k, v in extras.items():
|
for k, v in extras.items():
|
||||||
_data[k] = v
|
_data[k] = v
|
||||||
signature = hashlib.sha512(json.dumps(_data) + apiSecret).hexdigest()
|
signature = hashlib.sha512(json.dumps(_data) + apiSecret).hexdigest()
|
||||||
data = urllib.urlencode({'data': json.dumps(_data), 'hmac': signature})
|
data = urllib.urlencode({'data': json.dumps(_data), 'hmac': signature})
|
||||||
req = urllib2.Request('http://www.toontownstride.com/api/' + url, data)
|
cookie_jar = cookielib.LWPCookieJar()
|
||||||
|
cookie = urllib2.HTTPCookieProcessor(cookie_jar)
|
||||||
|
opener = urllib2.build_opener(cookie)
|
||||||
|
req = urllib2.Request('https://toontownstride.com/api/' + url, data,
|
||||||
|
headers={"Content-Type" : "application/x-www-form-urlencoded"})
|
||||||
req.get_method = lambda: "POST"
|
req.get_method = lambda: "POST"
|
||||||
try:
|
try:
|
||||||
return urllib2.urlopen(req).read()
|
return opener.open(req).read()
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -182,7 +188,7 @@ class DeveloperAccountDB(AccountDB):
|
||||||
'notAfter': 0},
|
'notAfter': 0},
|
||||||
callback)
|
callback)
|
||||||
|
|
||||||
class RemoteAccountDB(AccountDB):
|
class RemoteAccountDB:
|
||||||
# TO DO FOR NAMES:
|
# TO DO FOR NAMES:
|
||||||
# CURRENTLY IT MAKES n REQUESTS FOR EACH AVATAR
|
# CURRENTLY IT MAKES n REQUESTS FOR EACH AVATAR
|
||||||
# IN THE FUTURE, MAKE ONLY 1 REQUEST
|
# IN THE FUTURE, MAKE ONLY 1 REQUEST
|
||||||
|
@ -190,6 +196,8 @@ class RemoteAccountDB(AccountDB):
|
||||||
# ^ done, check before removing todo note
|
# ^ done, check before removing todo note
|
||||||
notify = directNotify.newCategory('RemoteAccountDB')
|
notify = directNotify.newCategory('RemoteAccountDB')
|
||||||
|
|
||||||
|
def __init__(self, csm):
|
||||||
|
self.csm = csm
|
||||||
|
|
||||||
def addNameRequest(self, avId, name, accountID = None):
|
def addNameRequest(self, avId, name, accountID = None):
|
||||||
username = avId
|
username = avId
|
||||||
|
@ -248,13 +256,34 @@ class RemoteAccountDB(AccountDB):
|
||||||
raise ValueError('Invalid hash.')
|
raise ValueError('Invalid hash.')
|
||||||
|
|
||||||
token = json.loads(token.decode('base64')[::-1].decode('rot13'))
|
token = json.loads(token.decode('base64')[::-1].decode('rot13'))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
resp = {'success': False}
|
resp = {'success': False}
|
||||||
callback(resp)
|
callback(resp)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
return AccountDB.lookup(self, token, callback)
|
return self.account_lookup(token, callback)
|
||||||
|
|
||||||
|
def account_lookup(self, data, callback):
|
||||||
|
data['success'] = True
|
||||||
|
data['accessLevel'] = max(data['accessLevel'], minAccessLevel)
|
||||||
|
data['accountId'] = int(data['accountId'])
|
||||||
|
|
||||||
|
callback(data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def storeAccountID(self, userId, accountId, callback):
|
||||||
|
r = executeHttpRequest('associateuser', username=str(userId), accountId=str(accountId))
|
||||||
|
try:
|
||||||
|
r = json.loads(r)
|
||||||
|
print r
|
||||||
|
if r['success']:
|
||||||
|
callback(True)
|
||||||
|
else:
|
||||||
|
self.notify.warning('Unable to associate user %s with account %d, got the return message of %s!' % (userId, accountId, r['error']))
|
||||||
|
callback(False)
|
||||||
|
except:
|
||||||
|
self.notify.warning('Unable to associate user %s with account %d!' % (userId, accountId))
|
||||||
|
callback(False)
|
||||||
|
|
||||||
|
|
||||||
# --- FSMs ---
|
# --- FSMs ---
|
||||||
|
|
Loading…
Add table
Reference in a new issue