2020-03-26 22:10:58 +00:00
|
|
|
import argparse
|
2019-03-01 19:41:40 +00:00
|
|
|
import asyncio
|
2019-05-29 21:44:13 +00:00
|
|
|
import logging
|
2019-03-01 19:41:40 +00:00
|
|
|
|
2020-03-26 22:10:58 +00:00
|
|
|
from houdini.constants import ClientType, ConflictResolution, Language
|
2019-06-04 00:33:28 +00:00
|
|
|
from houdini.houdini import Houdini
|
2019-03-01 19:41:40 +00:00
|
|
|
|
2019-06-04 00:33:28 +00:00
|
|
|
if __name__ == '__main__':
|
2019-05-29 21:44:13 +00:00
|
|
|
logger = logging.getLogger('houdini')
|
2019-06-04 00:33:28 +00:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Boot a Houdini server')
|
2019-12-02 23:11:46 +00:00
|
|
|
parser.add_argument('type', action='store', default='login',
|
|
|
|
choices=['login', 'world'], help='Name of the server to boot')
|
|
|
|
|
|
|
|
parser.add_argument('-id', action='store', default=3100, type=int, help='Houdini server ID')
|
|
|
|
parser.add_argument('-n', '--name', action='store', help='Houdini server name')
|
|
|
|
parser.add_argument('-a', '--address', action='store', default='0.0.0.0',
|
|
|
|
help='Houdini server address')
|
|
|
|
parser.add_argument('-p', '--port', action='store', help='Houdini server port', default=None, type=int)
|
|
|
|
parser.add_argument('-c', '--capacity', action='store', default=200,
|
|
|
|
help='Houdini server capacity', type=int)
|
|
|
|
parser.add_argument('-C', '--cache-expiry', dest='cache_expiry', action='store', default=3600,
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Cache expiry (seconds)', type=int)
|
2019-12-02 23:11:46 +00:00
|
|
|
parser.add_argument('-P', '--plugins', action='store', default='*',
|
2019-06-04 00:33:28 +00:00
|
|
|
nargs='*', help='Plugins to load')
|
2019-12-02 23:11:46 +00:00
|
|
|
parser.add_argument('-l', '--lang', action='store', default='en', help='Houdini language',
|
|
|
|
choices=['en', 'fr', 'pt', 'es', 'de', 'ru'])
|
2020-02-14 21:23:07 +00:00
|
|
|
parser.add_argument('-tz', '--timezone', action='store', default='America/Vancouver',
|
|
|
|
help='Server timezone')
|
2019-06-04 00:33:28 +00:00
|
|
|
|
2019-12-02 23:11:46 +00:00
|
|
|
login_group = parser.add_argument_group('login')
|
|
|
|
login_group.add_argument('--login-failure-limit', action='store', default=5, help='Limit before flood limit',
|
|
|
|
type=int)
|
|
|
|
login_group.add_argument('--login-failure-timer', action='store', default=3600, help='Timeout after flood limit',
|
|
|
|
type=int)
|
2020-06-12 14:15:29 +00:00
|
|
|
login_group.add_argument('--preactivation-days', action='store', default=7, help='Preactivation trial days',
|
|
|
|
type=int)
|
2020-01-02 23:03:34 +00:00
|
|
|
login_group.add_argument('-S', '--staff', action='store_true', help='Staff-only server mode')
|
2019-06-04 00:33:28 +00:00
|
|
|
|
|
|
|
logging_group = parser.add_argument_group('logging')
|
|
|
|
logging_group.add_argument('-lg', '--logging-general', action='store',
|
|
|
|
dest='logging_general_path',
|
|
|
|
help='General log path')
|
|
|
|
logging_group.add_argument('-le', '--logging-error', action='store',
|
|
|
|
dest='logging_error_path',
|
|
|
|
help='Error log path')
|
|
|
|
logging_group.add_argument('-ll', '--logging-level', action='store',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='INFO',
|
2019-06-04 00:33:28 +00:00
|
|
|
dest='logging_level',
|
|
|
|
help='Logging level')
|
|
|
|
|
|
|
|
database_group = parser.add_argument_group('database')
|
|
|
|
database_group.add_argument('-da', '--database-address', action='store',
|
|
|
|
dest='database_address',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='localhost',
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Postgresql database address')
|
|
|
|
database_group.add_argument('-du', '--database-username', action='store',
|
|
|
|
dest='database_username',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='postgres',
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Postgresql database username')
|
|
|
|
database_group.add_argument('-dp', '--database-password', action='store',
|
|
|
|
dest='database_password',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='password',
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Postgresql database password')
|
|
|
|
database_group.add_argument('-dn', '--database-name', action='store',
|
|
|
|
dest='database_name',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='postgres',
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Postgresql database name')
|
|
|
|
|
|
|
|
redis_group = parser.add_argument_group('redis')
|
|
|
|
redis_group.add_argument('-ra', '--redis-address', action='store',
|
|
|
|
dest='redis_address',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='localhost',
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Redis server address')
|
|
|
|
redis_group.add_argument('-rp', '--redis-port', action='store',
|
|
|
|
dest='redis_port',
|
|
|
|
type=int,
|
2019-12-02 23:11:46 +00:00
|
|
|
default=6379,
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Redis server port')
|
|
|
|
|
|
|
|
command_group = parser.add_argument_group('commands')
|
|
|
|
command_group.add_argument('-cp', '--command-prefix', action='store', dest='command_prefix',
|
|
|
|
nargs='*',
|
2019-12-02 23:11:46 +00:00
|
|
|
default=['!', '?', '.'],
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Command prefixes')
|
|
|
|
command_group.add_argument('-csd', '--command-string-delimiters', action='store', dest='command_string_delimiters',
|
|
|
|
nargs='*',
|
2019-12-02 23:11:46 +00:00
|
|
|
default=['"', "'"],
|
2019-06-04 00:33:28 +00:00
|
|
|
help='Command string delimiters')
|
|
|
|
command_group.add_argument('-ccm', '--command-conflict-mode', action='store', dest='command_conflict_mode',
|
2019-12-02 23:11:46 +00:00
|
|
|
default='silent',
|
|
|
|
help='Command conflict mode', choices=['silent', 'append', 'exception'])
|
|
|
|
|
|
|
|
games_group = parser.add_argument_group('games')
|
|
|
|
games_group.add_argument('--max-coins', action='store',
|
|
|
|
default=1000000, type=int, help='Max coins earnable')
|
|
|
|
games_group.add_argument('--max-coins-per-min', action='store',
|
2020-06-05 21:48:21 +00:00
|
|
|
default=800, type=int, help='Max coins per min')
|
2019-08-06 21:55:11 +00:00
|
|
|
|
|
|
|
client_group = parser.add_argument_group('client')
|
|
|
|
client_mode = client_group.add_mutually_exclusive_group()
|
|
|
|
client_mode.add_argument('--single-client-mode', action='store_true',
|
2019-12-02 23:11:46 +00:00
|
|
|
help='Run server with support for default client only')
|
2019-08-06 21:55:11 +00:00
|
|
|
client_group.add_argument('--legacy-version', action='store',
|
|
|
|
type=int,
|
2019-12-02 23:11:46 +00:00
|
|
|
default=153,
|
2019-08-06 21:55:11 +00:00
|
|
|
help='Legacy client version to identify legacy clients')
|
|
|
|
client_group.add_argument('--vanilla-version', action='store',
|
|
|
|
type=int,
|
2019-12-02 23:11:46 +00:00
|
|
|
default=253,
|
2019-08-06 21:55:11 +00:00
|
|
|
help='Vanilla client version to identify vanilla clients')
|
|
|
|
client_group.add_argument('--default-version', action='store',
|
|
|
|
type=int,
|
2019-12-02 23:11:46 +00:00
|
|
|
default=153,
|
2019-08-06 21:55:11 +00:00
|
|
|
help='Default version to identify clients when multi-client is off')
|
|
|
|
client_group.add_argument('--default-client', action='store',
|
2019-12-02 23:11:46 +00:00
|
|
|
choices=['legacy', 'vanilla'],
|
|
|
|
default='legacy',
|
2019-08-06 21:55:11 +00:00
|
|
|
help='Default client when multi-client is off')
|
|
|
|
client_group.add_argument('-k', '--auth-key', action='store',
|
|
|
|
default='houdini',
|
|
|
|
help='Static key to use in place of the deprecated random key')
|
2019-12-02 23:11:46 +00:00
|
|
|
client_group.add_argument('-kt', '--auth-ttl', action='store', type=int, default=3000,
|
|
|
|
help='Auth key TTL (seconds)')
|
2019-08-06 21:55:11 +00:00
|
|
|
|
2020-01-02 23:11:27 +00:00
|
|
|
membership_group = parser.add_argument_group('membership')
|
|
|
|
membership_group.add_argument('--expire-membership', action='store_true', help='Should membership expire?')
|
|
|
|
|
2019-06-04 00:33:28 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2019-12-02 23:11:46 +00:00
|
|
|
args.port = args.port if args.port else 9875 if args.type == 'world' else 6112
|
|
|
|
args.name = args.name if args.name else 'World' if args.type == 'world' else 'Login'
|
|
|
|
args.lang = dict(en=Language.En, fr=Language.Fr, pt=Language.Pt,
|
|
|
|
es=Language.Es, de=Language.De, ru=Language.Ru).get(args.lang)
|
|
|
|
args.command_conflict_mode = dict(silent=ConflictResolution.Silent, append=ConflictResolution.Append,
|
|
|
|
exception=ConflictResolution.Exception).get(args.command_conflict_mode)
|
|
|
|
args.default_client = dict(legacy=ClientType.Legacy, vanilla=ClientType.Vanilla).get(args.default_client)
|
2019-06-04 00:33:28 +00:00
|
|
|
|
2019-12-02 23:11:46 +00:00
|
|
|
factory_instance = Houdini(args)
|
2019-05-29 21:44:13 +00:00
|
|
|
try:
|
|
|
|
asyncio.run(factory_instance.start())
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
logger.info('Shutting down...')
|