Added: Configuration Module/File

This commit is contained in:
payet_s
2015-08-12 16:56:04 +02:00
committed by Sepalani
parent f7877ced40
commit dfa269c71d
15 changed files with 134 additions and 19 deletions

View File

@@ -29,8 +29,10 @@ import collections
import json
import os.path
import logging
import other.utils as utils
import gamespy.gs_utility as gs_utils
import dwc_config
logger_output_to_console = True
logger_output_to_file = True
@@ -478,7 +480,7 @@ class AdminPage(resource.Resource):
else:
return self.get_header() + self.get_footer()
port = 9009
_, port = dwc_config.get_ip_port('AdminPage')
class AdminPageServer(object):

51
altwfc.cfg Executable file
View File

@@ -0,0 +1,51 @@
# ALTWFC - Configuration File
[StorageServer]
IP = 127.0.0.1
Port = 8000
[NasServer]
IP = 127.0.0.1
Port = 9000
# Port = 80
[InternalStatsServer]
IP = 127.0.0.1
Port = 9001
[GameStatsServerHttp]
IP = 127.0.0.1
Port = 9002
[AdminPage]
IP = 127.0.0.1
Port = 9009
[GameSpyManager]
# GamespyBackendServer
IP = 127.0.0.1
Port = 27500
[GameSpyQRServer]
IP = 0.0.0.0
Port = 27900
[GameSpyNatNegServer]
IP = 0.0.0.0
Port = 27901
[GameSpyServerBrowserServer]
IP = 0.0.0.0
Port = 28910
[GameSpyProfileServer]
IP = 0.0.0.0
Port = 29900
[GameSpyPlayerSearchServer]
IP = 0.0.0.0
Port = 29901
[GameSpyGamestatsServer]
IP = 0.0.0.0
Port = 29920

50
dwc_config.py Executable file
View File

@@ -0,0 +1,50 @@
"""DWC Network Server Emulator
Copyright (C) 2014 SMTDDR
Copyright (C) 2014 kyle95wm
Copyright (C) 2014 AdmiralCurtiss
Copyright (C) 2015 Sepalani
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Configuration module.
"""
try:
# Python 2
import ConfigParser
except ImportError:
# Python 3
import configparser as ConfigParser
def get_ip_port(section, filename='altwfc.cfg'):
"""Return a tuple (IP, Port) of the corresponding section."""
config = ConfigParser.RawConfigParser(allow_no_value=True)
config.read(filename)
return (config.get(section, 'IP'), config.getint(section, 'Port'))
def get_ip(section, filename='altwfc.cfg'):
"""Return the IP of the corresponding section."""
config = ConfigParser.RawConfigParser(allow_no_value=True)
config.read(filename)
return config.get(section, 'IP')
def get_port(section, filename='altwfc.cfg'):
"""Return the port of the corresponding section."""
config = ConfigParser.RawConfigParser(allow_no_value=True)
config.read(filename)
return config.getint(section, 'Port')

View File

@@ -30,6 +30,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="admin_page_server.py" />
<Compile Include="dwc_config.py" />
<Compile Include="gamespy_backend_server.py" />
<Compile Include="gamespy_gamestats_server.py" />
<Compile Include="gamespy_natneg_server.py" />

View File

@@ -54,6 +54,7 @@ import ast
from multiprocessing.managers import BaseManager
from multiprocessing import freeze_support
import other.utils as utils
import dwc_config
class TokenType:
@@ -119,7 +120,7 @@ class GameSpyBackendServer(object):
)
def start(self):
address = ("127.0.0.1", 27500)
address = dwc_config.get_ip_port('GameSpyManager')
password = ""
logger.log(logging.INFO,

View File

@@ -35,6 +35,7 @@ import gamespy.gs_database as gs_database
import gamespy.gs_query as gs_query
import gamespy.gs_utility as gs_utils
import other.utils as utils
import dwc_config
# Logger settings
logger_output_to_console = True
@@ -44,7 +45,7 @@ logger_filename = "gamespy_gamestats_server.log"
logger = utils.create_logger(logger_name, logger_filename, -1,
logger_output_to_console, logger_output_to_file)
address = ("0.0.0.0", 29920)
address = dwc_config.get_ip_port('GameSpyGamestatsServer')
class GameSpyGamestatsServer(object):

View File

@@ -34,6 +34,7 @@ import other.utils as utils
import traceback
from multiprocessing.managers import BaseManager
import dwc_config
# Logger settings
logger_output_to_console = True
@@ -64,7 +65,7 @@ class GameSpyNatNegServer(object):
self.secret_key_list = gs_utils.generate_secret_keys("gslist.cfg")
self.server_manager = GameSpyServerDatabase(
address=("127.0.0.1", 27500),
address=dwc_config.get_ip_port('GameSpyManager'),
authkey=""
)
self.server_manager.connect()
@@ -74,7 +75,7 @@ class GameSpyNatNegServer(object):
# Start natneg server
# Accessible to outside connections (use this if you don't know
# what you're doing)
address = ('0.0.0.0', 27901)
address = dwc_config.get_ip_port('GameSpyNatNegServer')
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.bind(address)

View File

@@ -30,6 +30,7 @@ from twisted.internet.error import ReactorAlreadyRunning
import gamespy.gs_database as gs_database
import gamespy.gs_query as gs_query
import other.utils as utils
import dwc_config
# Logger settings
logger_output_to_console = True
@@ -39,7 +40,7 @@ logger_filename = "gamespy_player_search_server.log"
logger = utils.create_logger(logger_name, logger_filename, -1,
logger_output_to_console, logger_output_to_file)
address = ("0.0.0.0", 29901)
address = dwc_config.get_ip_port('GameSpyPlayerSearchServer')
class GameSpyPlayerSearchServer(object):

View File

@@ -34,7 +34,7 @@ import gamespy.gs_database as gs_database
import gamespy.gs_query as gs_query
import gamespy.gs_utility as gs_utils
import other.utils as utils
import dwc_config
# Logger settings
logger_output_to_console = True
@@ -44,7 +44,7 @@ logger_filename = "gamespy_profile_server.log"
logger = utils.create_logger(logger_name, logger_filename, -1,
logger_output_to_console, logger_output_to_file)
address = ("0.0.0.0", 29900)
address = dwc_config.get_ip_port('GameSpyProfileServer')
class GameSpyProfileServer(object):

View File

@@ -38,6 +38,7 @@ from multiprocessing.managers import BaseManager
import gamespy.gs_utility as gs_utils
import gamespy.gs_database as gs_database
import other.utils as utils
import dwc_config
from gamespy_server_browser_server import GameSpyServerBrowserServer
# Logger settings
@@ -98,7 +99,7 @@ class GameSpyQRServer(object):
def start(self):
try:
manager_address = ("127.0.0.1", 27500)
manager_address = dwc_config.get_ip_port('GameSpyManager')
manager_password = ""
self.server_manager = GameSpyServerDatabase(
@@ -110,7 +111,7 @@ class GameSpyQRServer(object):
# Start QR server
# Accessible to outside connections (use this if you don't know
# what you're doing)
address = ('0.0.0.0', 27900)
address = dwc_config.get_ip_port('GameSpyQRServer')
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.bind(address)

View File

@@ -34,6 +34,7 @@ from twisted.internet.error import ReactorAlreadyRunning
import gamespy.gs_utility as gs_utils
import other.utils as utils
import dwc_config
from multiprocessing.managers import BaseManager
@@ -68,7 +69,7 @@ GameSpyServerDatabase.register("add_natneg_server")
GameSpyServerDatabase.register("get_natneg_server")
GameSpyServerDatabase.register("delete_natneg_server")
address = ("0.0.0.0", 28910)
address = dwc_config.get_ip_port('GameSpyServerBrowserServer')
class GameSpyServerBrowserServer(object):
@@ -117,7 +118,7 @@ class Session(LineReceiver):
self.own_server = None
self.buffer = []
manager_address = ("127.0.0.1", 27500)
manager_address = dwc_config.get_ip_port('GameSpyManager')
manager_password = ""
self.server_manager = GameSpyServerDatabase(address=manager_address,
authkey=manager_password)

View File

@@ -32,6 +32,7 @@ import base64
import gamespy.gs_database as gs_database
import gamespy.gs_utility as gs_utils
import other.utils as utils
import dwc_config
logger_output_to_console = True
logger_output_to_file = True
@@ -40,8 +41,7 @@ logger_filename = "gamestats_server_http.log"
logger = utils.create_logger(logger_name, logger_filename, -1,
logger_output_to_console, logger_output_to_file)
# address = ("0.0.0.0", 80)
address = ("127.0.0.1", 9002)
address = dwc_config.get_ip_port('GameStatsServerHttp')
class GameStatsBase(object):

View File

@@ -26,7 +26,9 @@ import time
import datetime
import json
import logging
import other.utils as utils
import dwc_config
logger_output_to_console = True
logger_output_to_file = True
@@ -118,14 +120,14 @@ class InternalStatsServer(object):
self.seconds_per_update = 60
def start(self):
manager_address = ("127.0.0.1", 27500)
manager_address = dwc_config.get_ip_port('GameSpyManager')
manager_password = ""
self.server_manager = GameSpyServerDatabase(address=manager_address,
authkey=manager_password)
self.server_manager.connect()
site = server.Site(StatsPage(self))
reactor.listenTCP(9001, site)
reactor.listenTCP(dwc_config.get_port('InternalStatsServer'), site)
try:
if not reactor.running:

View File

@@ -33,6 +33,7 @@ import traceback
import gamespy.gs_database as gs_database
import other.utils as utils
import dwc_config
logger_output_to_console = True
logger_output_to_file = True
@@ -68,7 +69,7 @@ gamecodes_return_random_file = [
'IPGS'
]
address = ("127.0.0.1", 9000)
address = dwc_config.get_ip_port('NasServer')
class NasServer(object):
@@ -363,7 +364,8 @@ class NasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
ret,
post["token"]
)
elif post["gamecd"] in gamecodes_return_random_file:
elif post["gamecd"] in \
gamecodes_return_random_file:
# Pokemon Gen 4 Mystery Gifts, same here
ret = self.filter_list(
safeloadfi("_list.txt"),

View File

@@ -29,6 +29,7 @@ import xml.dom.minidom as minidom
import other.utils as utils
import gamespy.gs_database as gs_database
import dwc_config
logger_output_to_console = True
logger_output_to_file = True
@@ -37,7 +38,7 @@ logger_filename = "storage_server.log"
logger = utils.create_logger(logger_name, logger_filename, -1, logger_output_to_console, logger_output_to_file)
# Paths to ProxyPass: /SakeStorageServer, /SakeFileServer
address = ("127.0.0.1", 8000)
address = dwc_config.get_ip_port('StorageServer')
def escape_xml(s):
s = s.replace( "&", "&amp;" )