@@ 13-49 (lines=37) @@ | ||
10 | from .helpers import field_from_ini |
|
11 | ||
12 | ||
13 | @zope.interface.implementer(INISerializable) |
|
14 | @zope.interface.implementer(DefaultProvider) |
|
15 | class Connection(Model): |
|
16 | port = IntType( |
|
17 | min_value=0, |
|
18 | max_value=65000, |
|
19 | default=0, |
|
20 | required=True, |
|
21 | ) |
|
22 | allowed_hosts = ListType( |
|
23 | field=StringType, |
|
24 | min_size=0, |
|
25 | required=True, |
|
26 | min_length=1, |
|
27 | ) |
|
28 | ||
29 | @classmethod |
|
30 | def from_ini(cls, ini): |
|
31 | return cls({ |
|
32 | 'port': field_from_ini( |
|
33 | cls.port, ini, |
|
34 | 'Console', 'IP', |
|
35 | ), |
|
36 | 'allowed_hosts': ( |
|
37 | field_from_ini( |
|
38 | cls.allowed_hosts, ini, |
|
39 | 'Console', 'IPS', default="", |
|
40 | ) |
|
41 | .split() |
|
42 | ), |
|
43 | }) |
|
44 | ||
45 | @classmethod |
|
46 | def default(cls): |
|
47 | return cls({ |
|
48 | 'port': cls.port.default, |
|
49 | 'allowed_hosts': [], |
|
50 | }) |
|
51 | ||
52 | ||
@@ 103-136 (lines=34) @@ | ||
100 | }) |
|
101 | ||
102 | ||
103 | @zope.interface.implementer(INISerializable) |
|
104 | @zope.interface.implementer(DefaultProvider) |
|
105 | class HistorySize(Model): |
|
106 | commands = IntType( |
|
107 | min_value=0, |
|
108 | max_value=10000, |
|
109 | default=128, |
|
110 | required=True, |
|
111 | ) |
|
112 | records = IntType( |
|
113 | min_value=0, |
|
114 | max_value=10000, |
|
115 | default=128, |
|
116 | required=True, |
|
117 | ) |
|
118 | ||
119 | @classmethod |
|
120 | def from_ini(cls, ini): |
|
121 | return cls({ |
|
122 | 'commands': field_from_ini( |
|
123 | cls.commands, ini, |
|
124 | 'Console', 'HISTORYCMD', |
|
125 | ), |
|
126 | 'records': field_from_ini( |
|
127 | cls.records, ini, |
|
128 | 'Console', 'HISTORY', |
|
129 | ), |
|
130 | }) |
|
131 | ||
132 | @classmethod |
|
133 | def default(cls): |
|
134 | return cls({ |
|
135 | field_name: field.default |
|
136 | for field_name, field in cls.fields.items() |
|
137 | }) |
|
138 | ||
139 | ||
@@ 140-169 (lines=30) @@ | ||
137 | }) |
|
138 | ||
139 | ||
140 | @zope.interface.implementer(INISerializable) |
|
141 | @zope.interface.implementer(DefaultProvider) |
|
142 | class Console(Model): |
|
143 | connection = ModelType( |
|
144 | model_spec=Connection, |
|
145 | required=True, |
|
146 | ) |
|
147 | logging = ModelType( |
|
148 | model_spec=Logging, |
|
149 | required=True, |
|
150 | ) |
|
151 | history_size = ModelType( |
|
152 | model_spec=HistorySize, |
|
153 | required=True, |
|
154 | ) |
|
155 | ||
156 | @classmethod |
|
157 | def from_ini(cls, ini): |
|
158 | return cls({ |
|
159 | 'connection': Connection.from_ini(ini), |
|
160 | 'logging': Logging.from_ini(ini), |
|
161 | 'history_size': HistorySize.from_ini(ini), |
|
162 | }) |
|
163 | ||
164 | @classmethod |
|
165 | def default(cls): |
|
166 | return cls({ |
|
167 | 'connection': Connection.default(), |
|
168 | 'logging': Logging.default(), |
|
169 | 'history_size': HistorySize.default(), |
|
170 | }) |
|
171 |
@@ 15-49 (lines=35) @@ | ||
12 | from .speedhack import Speedhack |
|
13 | ||
14 | ||
15 | @zope.interface.implementer(INISerializable) |
|
16 | @zope.interface.implementer(DefaultProvider) |
|
17 | class Anticheat(Model): |
|
18 | version_check_level = IntType( |
|
19 | min_value=0, |
|
20 | max_value=2, |
|
21 | default=0, |
|
22 | required=True, |
|
23 | ) |
|
24 | lags = ModelType( |
|
25 | model_spec=Lags, |
|
26 | required=True, |
|
27 | ) |
|
28 | speedhack = ModelType( |
|
29 | model_spec=Speedhack, |
|
30 | required=True, |
|
31 | ) |
|
32 | ||
33 | @classmethod |
|
34 | def from_ini(cls, ini): |
|
35 | return cls({ |
|
36 | 'version_check_level': field_from_ini( |
|
37 | cls.version_check_level, ini, |
|
38 | 'NET', 'checkRuntime', |
|
39 | ), |
|
40 | 'lags': Lags.from_ini(ini), |
|
41 | 'speedhack': Speedhack.from_ini(ini), |
|
42 | }) |
|
43 | ||
44 | @classmethod |
|
45 | def default(cls): |
|
46 | return cls({ |
|
47 | 'version_check_level': cls.version_check_level.default, |
|
48 | 'lags': Lags.default(), |
|
49 | 'speedhack': Speedhack.default(), |
|
50 | }) |
|
51 |
@@ 119-151 (lines=33) @@ | ||
116 | }) |
|
117 | ||
118 | ||
119 | @zope.interface.implementer(INISerializable) |
|
120 | @zope.interface.implementer(DefaultProvider) |
|
121 | class Statistics(Model): |
|
122 | is_disabled = BooleanType( |
|
123 | default=False, |
|
124 | required=True, |
|
125 | ) |
|
126 | users = ModelType( |
|
127 | model_spec=Users, |
|
128 | required=True, |
|
129 | ) |
|
130 | belligerents = ModelType( |
|
131 | model_spec=Belligerents, |
|
132 | required=True, |
|
133 | ) |
|
134 | ||
135 | @classmethod |
|
136 | def from_ini(cls, ini): |
|
137 | return cls({ |
|
138 | 'is_disabled': field_from_ini( |
|
139 | cls.is_disabled, ini, |
|
140 | 'NET', 'disableNetStatStatistics', |
|
141 | ), |
|
142 | 'users': Users.from_ini(ini), |
|
143 | 'belligerents': Belligerents.from_ini(ini), |
|
144 | }) |
|
145 | ||
146 | @classmethod |
|
147 | def default(cls): |
|
148 | return cls({ |
|
149 | 'is_disabled': cls.is_disabled.default, |
|
150 | 'users': Users.default(), |
|
151 | 'belligerents': Belligerents.default(), |
|
152 | }) |
|
153 |
@@ 55-83 (lines=29) @@ | ||
52 | }) |
|
53 | ||
54 | ||
55 | @zope.interface.implementer(INISerializable) |
|
56 | @zope.interface.implementer(DefaultProvider) |
|
57 | class Events(Model): |
|
58 | chat_level = IntType( |
|
59 | min_value=0, |
|
60 | max_value=3, |
|
61 | default=0, |
|
62 | required=True, |
|
63 | ) |
|
64 | logging = ModelType( |
|
65 | model_spec=Logging, |
|
66 | required=True, |
|
67 | ) |
|
68 | ||
69 | @classmethod |
|
70 | def from_ini(cls, ini): |
|
71 | return cls({ |
|
72 | 'chat_level': field_from_ini( |
|
73 | cls.chat_level, ini, |
|
74 | 'chat', 'autoLogDetail', |
|
75 | ), |
|
76 | 'logging': Logging.from_ini(ini), |
|
77 | }) |
|
78 | ||
79 | @classmethod |
|
80 | def default(cls): |
|
81 | return cls({ |
|
82 | 'chat_level': cls.chat_level.default, |
|
83 | 'logging': Logging.default(), |
|
84 | }) |
|
85 |