| @@ 12-39 (lines=28) @@ | ||
| 9 | from .interfaces import INISerializable |
|
| 10 | ||
| 11 | ||
| 12 | @zope.interface.implementer(INISerializable) |
|
| 13 | class Connection(Model): |
|
| 14 | port = IntType( |
|
| 15 | min_value=0, |
|
| 16 | max_value=65000, |
|
| 17 | default=0, |
|
| 18 | required=True, |
|
| 19 | ) |
|
| 20 | allowed_hosts = ListType( |
|
| 21 | field=StringType, |
|
| 22 | min_size=0, |
|
| 23 | required=True, |
|
| 24 | min_length=1, |
|
| 25 | ) |
|
| 26 | ||
| 27 | @classmethod |
|
| 28 | def from_ini(cls, ini): |
|
| 29 | return cls({ |
|
| 30 | 'port': ini.getint( |
|
| 31 | 'Console', 'IP', |
|
| 32 | fallback=cls.port.default, |
|
| 33 | ), |
|
| 34 | 'allowed_hosts': [ |
|
| 35 | x.strip() |
|
| 36 | for x in |
|
| 37 | ( |
|
| 38 | ini |
|
| 39 | .get('Console', 'IPS', fallback="") |
|
| 40 | .split() |
|
| 41 | ) |
|
| 42 | ], |
|
| @@ 88-112 (lines=25) @@ | ||
| 85 | }) |
|
| 86 | ||
| 87 | ||
| 88 | @zope.interface.implementer(INISerializable) |
|
| 89 | class HistorySize(Model): |
|
| 90 | commands = IntType( |
|
| 91 | min_value=0, |
|
| 92 | max_value=10000, |
|
| 93 | default=128, |
|
| 94 | required=True, |
|
| 95 | ) |
|
| 96 | records = IntType( |
|
| 97 | min_value=0, |
|
| 98 | max_value=10000, |
|
| 99 | default=128, |
|
| 100 | required=True, |
|
| 101 | ) |
|
| 102 | ||
| 103 | @classmethod |
|
| 104 | def from_ini(cls, ini): |
|
| 105 | return cls({ |
|
| 106 | 'commands': ini.getint( |
|
| 107 | 'Console', 'HISTORYCMD', |
|
| 108 | fallback=cls.commands.default, |
|
| 109 | ), |
|
| 110 | 'records': ini.getint( |
|
| 111 | 'Console', 'HISTORY', |
|
| 112 | fallback=cls.records.default, |
|
| 113 | ), |
|
| 114 | }) |
|
| 115 | ||
| @@ 14-39 (lines=26) @@ | ||
| 11 | from .speedhack import Speedhack |
|
| 12 | ||
| 13 | ||
| 14 | @zope.interface.implementer(INISerializable) |
|
| 15 | class Anticheat(Model): |
|
| 16 | version_check_level = IntType( |
|
| 17 | min_value=0, |
|
| 18 | max_value=2, |
|
| 19 | default=0, |
|
| 20 | required=True, |
|
| 21 | ) |
|
| 22 | lags = ModelType( |
|
| 23 | model_spec=Lags, |
|
| 24 | required=True, |
|
| 25 | ) |
|
| 26 | speedhack = ModelType( |
|
| 27 | model_spec=Speedhack, |
|
| 28 | required=True, |
|
| 29 | ) |
|
| 30 | ||
| 31 | @classmethod |
|
| 32 | def from_ini(cls, ini): |
|
| 33 | return cls({ |
|
| 34 | 'version_check_level': ini.getint( |
|
| 35 | 'NET', 'checkRuntime', |
|
| 36 | fallback=cls.version_check_level.default, |
|
| 37 | ), |
|
| 38 | 'lags': Lags.from_ini(ini), |
|
| 39 | 'speedhack': Speedhack.from_ini(ini), |
|
| 40 | }) |
|
| 41 | ||