1 | #define MODULE_LOG_PREFIX "config"
|
---|
2 |
|
---|
3 | #include "globals.h"
|
---|
4 | #include "module-dvbapi.h"
|
---|
5 | #include "module-gbox.h"
|
---|
6 | #include "oscam-array.h"
|
---|
7 | #include "oscam-conf.h"
|
---|
8 | #include "oscam-conf-chk.h"
|
---|
9 | #include "oscam-conf-mk.h"
|
---|
10 | #include "oscam-config.h"
|
---|
11 | #include "oscam-net.h"
|
---|
12 | #include "oscam-string.h"
|
---|
13 |
|
---|
14 | #define cs_conf "oscam.conf"
|
---|
15 |
|
---|
16 | #define DEFAULT_HTTP_PORT 8888
|
---|
17 | #define DEFAULT_HTTP_ALLOW "127.0.0.1,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255,::1"
|
---|
18 |
|
---|
19 | static void disablelog_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
20 | {
|
---|
21 | if(value)
|
---|
22 | {
|
---|
23 | cs_disable_log(strToIntVal(value, 0));
|
---|
24 | return;
|
---|
25 | }
|
---|
26 | if(cfg.disablelog || cfg.http_full_cfg)
|
---|
27 | { fprintf_conf(f, token, "%d\n", cfg.disablelog); }
|
---|
28 | }
|
---|
29 |
|
---|
30 | #if defined(WEBIF) || defined(MODULE_MONITOR)
|
---|
31 | static void loghistorylines_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
32 | {
|
---|
33 | if(value)
|
---|
34 | {
|
---|
35 | uint32_t newsize = strToUIntVal(value, 256);
|
---|
36 | if(newsize < 64 && newsize != 0)
|
---|
37 | {
|
---|
38 | fprintf(stderr, "WARNING: loghistorylines is too small, adjusted to 64\n");
|
---|
39 | newsize = 64;
|
---|
40 | }
|
---|
41 | cs_reinit_loghist(newsize);
|
---|
42 | return;
|
---|
43 | }
|
---|
44 | if(cfg.loghistorylines != 256 || cfg.http_full_cfg)
|
---|
45 | { fprintf_conf(f, token, "%u\n", cfg.loghistorylines); }
|
---|
46 | }
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | static void serverip_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
50 | {
|
---|
51 | IN_ADDR_T srvip = *(IN_ADDR_T *)setting;
|
---|
52 | if(value)
|
---|
53 | {
|
---|
54 | if(strlen(value) == 0)
|
---|
55 | {
|
---|
56 | set_null_ip((IN_ADDR_T *)setting);
|
---|
57 | }
|
---|
58 | else
|
---|
59 | {
|
---|
60 | cs_inet_addr(value, (IN_ADDR_T *)setting);
|
---|
61 | }
|
---|
62 | return;
|
---|
63 | }
|
---|
64 | if(IP_ISSET(srvip) || cfg.http_full_cfg)
|
---|
65 | { fprintf_conf(f, token, "%s\n", cs_inet_ntoa(srvip)); }
|
---|
66 | }
|
---|
67 |
|
---|
68 | void iprange_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
69 | {
|
---|
70 | struct s_ip **ip = setting;
|
---|
71 | if(value)
|
---|
72 | {
|
---|
73 | if(strlen(value) == 0)
|
---|
74 | {
|
---|
75 | clear_sip(ip);
|
---|
76 | }
|
---|
77 | else
|
---|
78 | {
|
---|
79 | chk_iprange(value, ip);
|
---|
80 | }
|
---|
81 | return;
|
---|
82 | }
|
---|
83 | value = mk_t_iprange(*ip);
|
---|
84 | if(strlen(value) > 0 || cfg.http_full_cfg)
|
---|
85 | { fprintf_conf(f, token, "%s\n", value); }
|
---|
86 | free_mk_t(value);
|
---|
87 | }
|
---|
88 |
|
---|
89 | void iprange_free_fn(void *setting)
|
---|
90 | {
|
---|
91 | clear_sip(setting);
|
---|
92 | }
|
---|
93 |
|
---|
94 | static void logfile_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
95 | {
|
---|
96 | if(value)
|
---|
97 | {
|
---|
98 | char *saveptr1 = NULL;
|
---|
99 | cfg.logtostdout = 0;
|
---|
100 | cfg.logtosyslog = 0;
|
---|
101 | NULLFREE(cfg.logfile);
|
---|
102 | if(strlen(value) > 0)
|
---|
103 | {
|
---|
104 | char *pch;
|
---|
105 | for(pch = strtok_r(value, ";", &saveptr1); pch != NULL; pch = strtok_r(NULL, ";", &saveptr1))
|
---|
106 | {
|
---|
107 | pch = trim(pch);
|
---|
108 | if(!strcmp(pch, "stdout")) { cfg.logtostdout = 1; }
|
---|
109 | else if(!strcmp(pch, "syslog")) { cfg.logtosyslog = 1; }
|
---|
110 | else
|
---|
111 | {
|
---|
112 | NULLFREE(cfg.logfile);
|
---|
113 | if(!(cfg.logfile = cs_strdup(pch)))
|
---|
114 | { continue; }
|
---|
115 | }
|
---|
116 | }
|
---|
117 | }
|
---|
118 | else
|
---|
119 | {
|
---|
120 | if(!(cfg.logfile = cs_strdup(CS_LOGFILE)))
|
---|
121 | { cfg.logtostdout = 1; }
|
---|
122 | }
|
---|
123 | return;
|
---|
124 | }
|
---|
125 | if(cfg.logfile || cfg.logtostdout == 1 || cfg.logtosyslog == 1 || cfg.http_full_cfg)
|
---|
126 | {
|
---|
127 | value = mk_t_logfile();
|
---|
128 | fprintf_conf(f, token, "%s\n", value);
|
---|
129 | free_mk_t(value);
|
---|
130 | }
|
---|
131 | }
|
---|
132 |
|
---|
133 | void check_caidtab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
134 | {
|
---|
135 | CAIDTAB *caid_table = setting;
|
---|
136 | if(value)
|
---|
137 | {
|
---|
138 | if(strlen(value)) {
|
---|
139 | chk_caidtab(value, caid_table);
|
---|
140 | } else {
|
---|
141 | caidtab_clear(caid_table);
|
---|
142 | }
|
---|
143 | return;
|
---|
144 | }
|
---|
145 | if(caid_table->ctnum || cfg.http_full_cfg)
|
---|
146 | {
|
---|
147 | value = mk_t_caidtab(caid_table);
|
---|
148 | fprintf_conf(f, token, "%s\n", value);
|
---|
149 | free_mk_t(value);
|
---|
150 | }
|
---|
151 | }
|
---|
152 |
|
---|
153 | void chk_ftab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
154 | {
|
---|
155 | FTAB *ftab = setting;
|
---|
156 | if(value)
|
---|
157 | {
|
---|
158 | if(strlen(value))
|
---|
159 | chk_ftab(value, ftab);
|
---|
160 | else
|
---|
161 | ftab_clear(ftab);
|
---|
162 | return;
|
---|
163 | }
|
---|
164 | value = mk_t_ftab(ftab);
|
---|
165 | if(strlen(value) > 0 || cfg.http_full_cfg)
|
---|
166 | { fprintf_conf(f, token, "%s\n", value); }
|
---|
167 | free_mk_t(value);
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | void caidvaluetab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
172 | {
|
---|
173 | CAIDVALUETAB *caid_value_table = setting;
|
---|
174 | if(value)
|
---|
175 | {
|
---|
176 | if (strlen(value)) {
|
---|
177 | chk_caidvaluetab(value, caid_value_table);
|
---|
178 | if (streq(token, "lb_retrylimits"))
|
---|
179 | {
|
---|
180 | int32_t i;
|
---|
181 | for (i = 0; i < caid_value_table->cvnum; i++)
|
---|
182 | {
|
---|
183 | if (caid_value_table->cvdata[i].value < 50)
|
---|
184 | caid_value_table->cvdata[i].value = 50;
|
---|
185 | }
|
---|
186 | }
|
---|
187 | } else {
|
---|
188 | caidvaluetab_clear(caid_value_table);
|
---|
189 | }
|
---|
190 | return;
|
---|
191 | }
|
---|
192 | if(caid_value_table->cvnum || cfg.http_full_cfg)
|
---|
193 | {
|
---|
194 | value = mk_t_caidvaluetab(caid_value_table);
|
---|
195 | fprintf_conf(f, token, "%s\n", value);
|
---|
196 | free_mk_t(value);
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | #ifdef CS_CACHEEX
|
---|
201 | void cacheex_valuetab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
202 | {
|
---|
203 | CECSPVALUETAB *cacheex_value_table = setting;
|
---|
204 | if(value)
|
---|
205 | {
|
---|
206 | if(strlen(value) == 0)
|
---|
207 | { clear_cacheextab(cacheex_value_table); }
|
---|
208 | else
|
---|
209 | { chk_cacheex_valuetab(value, cacheex_value_table); }
|
---|
210 | return;
|
---|
211 | }
|
---|
212 | if(cacheex_value_table->cevnum || cfg.http_full_cfg)
|
---|
213 | {
|
---|
214 | value = mk_t_cacheex_valuetab(cacheex_value_table);
|
---|
215 | fprintf_conf(f, token, "%s\n", value);
|
---|
216 | free_mk_t(value);
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | void cacheex_cwcheck_tab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
221 | {
|
---|
222 | CWCHECKTAB *cacheex_value_table = setting;
|
---|
223 | if(value)
|
---|
224 | {
|
---|
225 | if(strlen(value) == 0)
|
---|
226 | {
|
---|
227 | cacheex_value_table->cwchecknum = 0;
|
---|
228 | NULLFREE(cacheex_value_table->cwcheckdata);
|
---|
229 | }
|
---|
230 | else
|
---|
231 | {
|
---|
232 | chk_cacheex_cwcheck_valuetab(value, cacheex_value_table);
|
---|
233 | }
|
---|
234 | return;
|
---|
235 | }
|
---|
236 |
|
---|
237 | if(cacheex_value_table->cwchecknum || cfg.http_full_cfg)
|
---|
238 | {
|
---|
239 | value = mk_t_cacheex_cwcheck_valuetab(cacheex_value_table);
|
---|
240 | fprintf_conf(f, token, "%s\n", value);
|
---|
241 | free_mk_t(value);
|
---|
242 | }
|
---|
243 | }
|
---|
244 |
|
---|
245 | void cacheex_hitvaluetab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
246 | {
|
---|
247 | CECSPVALUETAB *cacheex_value_table = setting;
|
---|
248 | if(value)
|
---|
249 | {
|
---|
250 | if(strlen(value) == 0)
|
---|
251 | { clear_cacheextab(cacheex_value_table); }
|
---|
252 | else
|
---|
253 | { chk_cacheex_hitvaluetab(value, cacheex_value_table); }
|
---|
254 | return;
|
---|
255 | }
|
---|
256 | if(cacheex_value_table->cevnum || cfg.http_full_cfg)
|
---|
257 | {
|
---|
258 | value = mk_t_cacheex_hitvaluetab(cacheex_value_table);
|
---|
259 | fprintf_conf(f, token, "%s\n", value);
|
---|
260 | free_mk_t(value);
|
---|
261 | }
|
---|
262 | }
|
---|
263 | #endif
|
---|
264 |
|
---|
265 | #ifdef __CYGWIN__
|
---|
266 | #include <windows.h>
|
---|
267 | #else
|
---|
268 | #include <sys/resource.h> // for setpriority
|
---|
269 | #endif
|
---|
270 |
|
---|
271 | void global_fixups_fn(void *UNUSED(var))
|
---|
272 | {
|
---|
273 | if(!cfg.usrfile) { cfg.disableuserfile = 1; }
|
---|
274 | if(!cfg.mailfile) { cfg.disablemail = 1; }
|
---|
275 | if(cfg.ctimeout < 10) { cfg.ctimeout = cfg.ctimeout * 1000; } // save always in ms
|
---|
276 |
|
---|
277 | if(cfg.nice < -20 || cfg.nice > 20) { cfg.nice = 99; }
|
---|
278 | if(cfg.nice != 99)
|
---|
279 | {
|
---|
280 | #ifndef __CYGWIN__
|
---|
281 | setpriority(PRIO_PROCESS, 0, cfg.nice);
|
---|
282 | #else
|
---|
283 | HANDLE WinId;
|
---|
284 | uint32_t wprio;
|
---|
285 | switch((cfg.nice + 20) / 10)
|
---|
286 | {
|
---|
287 | case 0:
|
---|
288 | wprio = REALTIME_PRIORITY_CLASS;
|
---|
289 | break;
|
---|
290 | case 1:
|
---|
291 | wprio = HIGH_PRIORITY_CLASS;
|
---|
292 | break;
|
---|
293 | case 2:
|
---|
294 | wprio = NORMAL_PRIORITY_CLASS;
|
---|
295 | break;
|
---|
296 | default:
|
---|
297 | wprio = IDLE_PRIORITY_CLASS;
|
---|
298 | break;
|
---|
299 | }
|
---|
300 | WinId = GetCurrentProcess();
|
---|
301 | SetPriorityClass(WinId, wprio);
|
---|
302 | #endif
|
---|
303 | }
|
---|
304 | if(cfg.netprio <= 0 || cfg.netprio > 20) { cfg.netprio = 0; }
|
---|
305 | if(cfg.max_log_size != 0 && cfg.max_log_size <= 10) { cfg.max_log_size = 10; }
|
---|
306 | #ifdef WITH_LB
|
---|
307 | if(cfg.lb_save > 0 && cfg.lb_save < 100) { cfg.lb_save = 100; }
|
---|
308 | if(cfg.lb_nbest_readers < 2) { cfg.lb_nbest_readers = DEFAULT_NBEST; }
|
---|
309 | #endif
|
---|
310 | }
|
---|
311 |
|
---|
312 | #define OFS(X) offsetof(struct s_config, X)
|
---|
313 | #define SIZEOF(X) sizeof(((struct s_config *)0)->X)
|
---|
314 |
|
---|
315 | static const struct config_list global_opts[] =
|
---|
316 | {
|
---|
317 | DEF_OPT_FIXUP_FUNC(global_fixups_fn),
|
---|
318 | #ifdef LEDSUPPORT
|
---|
319 | DEF_OPT_INT8("enableled" , OFS(enableled), 0),
|
---|
320 | #endif
|
---|
321 | DEF_OPT_FUNC("disablelog" , OFS(disablelog), disablelog_fn),
|
---|
322 | #if defined(WEBIF) || defined(MODULE_MONITOR)
|
---|
323 | DEF_OPT_FUNC("loghistorylines" , OFS(loghistorylines), loghistorylines_fn),
|
---|
324 | #endif
|
---|
325 | DEF_OPT_FUNC("serverip" , OFS(srvip), serverip_fn),
|
---|
326 | DEF_OPT_FUNC("logfile" , OFS(logfile), logfile_fn),
|
---|
327 | DEF_OPT_INT32("initial_debuglevel" , OFS(initial_debuglevel), 0),
|
---|
328 | DEF_OPT_STR("sysloghost" , OFS(sysloghost), NULL),
|
---|
329 | DEF_OPT_INT32("syslogport" , OFS(syslogport), 514),
|
---|
330 | DEF_OPT_INT8("logduplicatelines" , OFS(logduplicatelines), 0),
|
---|
331 | DEF_OPT_STR("pidfile" , OFS(pidfile), NULL),
|
---|
332 | DEF_OPT_INT8("disableuserfile" , OFS(disableuserfile), 1),
|
---|
333 | DEF_OPT_INT8("disablemail" , OFS(disablemail), 1),
|
---|
334 | DEF_OPT_INT8("usrfileflag" , OFS(usrfileflag), 0),
|
---|
335 | DEF_OPT_UINT32("clienttimeout" , OFS(ctimeout), CS_CLIENT_TIMEOUT),
|
---|
336 | DEF_OPT_UINT32("fallbacktimeout" , OFS(ftimeout), CS_CLIENT_TIMEOUT / 2),
|
---|
337 | DEF_OPT_FUNC("fallbacktimeout_percaid" , OFS(ftimeouttab), caidvaluetab_fn),
|
---|
338 | DEF_OPT_UINT32("clientmaxidle" , OFS(cmaxidle), CS_CLIENT_MAXIDLE),
|
---|
339 | DEF_OPT_INT32("bindwait" , OFS(bindwait), CS_BIND_TIMEOUT),
|
---|
340 | DEF_OPT_UINT32("netprio" , OFS(netprio), 0),
|
---|
341 | DEF_OPT_INT32("sleep" , OFS(tosleep), 0),
|
---|
342 | DEF_OPT_INT32("unlockparental" , OFS(ulparent), 0),
|
---|
343 | DEF_OPT_INT32("nice" , OFS(nice), 99),
|
---|
344 | DEF_OPT_INT32("maxlogsize" , OFS(max_log_size), 10),
|
---|
345 | DEF_OPT_INT8("waitforcards" , OFS(waitforcards), 1),
|
---|
346 | DEF_OPT_INT32("waitforcards_extra_delay", OFS(waitforcards_extra_delay), 500),
|
---|
347 | DEF_OPT_INT8("preferlocalcards" , OFS(preferlocalcards), 0),
|
---|
348 | DEF_OPT_INT32("readerrestartseconds" , OFS(reader_restart_seconds), 5),
|
---|
349 | DEF_OPT_INT8("dropdups" , OFS(dropdups), 0),
|
---|
350 | DEF_OPT_INT8("reload_useraccounts" , OFS(reload_useraccounts), 0),
|
---|
351 | DEF_OPT_INT8("reload_readers" , OFS(reload_readers), 0),
|
---|
352 | DEF_OPT_INT8("reload_provid" , OFS(reload_provid), 0),
|
---|
353 | DEF_OPT_INT8("reload_services_ids" , OFS(reload_services_ids), 0),
|
---|
354 | DEF_OPT_INT8("reload_tier_ids" , OFS(reload_tier_ids), 0),
|
---|
355 | DEF_OPT_INT8("reload_fakecws" , OFS(reload_fakecws), 0),
|
---|
356 | DEF_OPT_INT8("reload_ac_stat" , OFS(reload_ac_stat), 0),
|
---|
357 | DEF_OPT_INT8("reload_log" , OFS(reload_log), 0),
|
---|
358 | DEF_OPT_INT8("block_same_ip" , OFS(block_same_ip), 1),
|
---|
359 | DEF_OPT_INT8("block_same_name" , OFS(block_same_name), 1),
|
---|
360 | DEF_OPT_STR("usrfile" , OFS(usrfile), NULL),
|
---|
361 | DEF_OPT_STR("mailfile" , OFS(mailfile), NULL),
|
---|
362 | DEF_OPT_STR("cwlogdir" , OFS(cwlogdir), NULL),
|
---|
363 | DEF_OPT_STR("emmlogdir" , OFS(emmlogdir), NULL),
|
---|
364 | #ifdef WITH_LB
|
---|
365 | DEF_OPT_INT32("lb_mode" , OFS(lb_mode), DEFAULT_LB_MODE),
|
---|
366 | DEF_OPT_INT32("lb_save" , OFS(lb_save), 0),
|
---|
367 | DEF_OPT_INT32("lb_nbest_readers" , OFS(lb_nbest_readers), DEFAULT_NBEST),
|
---|
368 | DEF_OPT_INT32("lb_nfb_readers" , OFS(lb_nfb_readers), DEFAULT_NFB),
|
---|
369 | DEF_OPT_INT32("lb_min_ecmcount" , OFS(lb_min_ecmcount), DEFAULT_MIN_ECM_COUNT),
|
---|
370 | DEF_OPT_INT32("lb_max_ecmcount" , OFS(lb_max_ecmcount), DEFAULT_MAX_ECM_COUNT),
|
---|
371 | DEF_OPT_INT32("lb_reopen_seconds" , OFS(lb_reopen_seconds), DEFAULT_REOPEN_SECONDS),
|
---|
372 | DEF_OPT_INT8("lb_reopen_invalid" , OFS(lb_reopen_invalid), 1),
|
---|
373 | DEF_OPT_INT8("lb_force_reopen_always" , OFS(lb_force_reopen_always), 0),
|
---|
374 | DEF_OPT_INT32("lb_retrylimit" , OFS(lb_retrylimit), DEFAULT_RETRYLIMIT),
|
---|
375 | DEF_OPT_INT32("lb_stat_cleanup" , OFS(lb_stat_cleanup), DEFAULT_LB_STAT_CLEANUP),
|
---|
376 | DEF_OPT_INT32("lb_max_readers" , OFS(lb_max_readers), 0),
|
---|
377 | DEF_OPT_INT32("lb_auto_betatunnel" , OFS(lb_auto_betatunnel), DEFAULT_LB_AUTO_BETATUNNEL),
|
---|
378 | DEF_OPT_INT32("lb_auto_betatunnel_mode" , OFS(lb_auto_betatunnel_mode), DEFAULT_LB_AUTO_BETATUNNEL_MODE),
|
---|
379 | DEF_OPT_INT32("lb_auto_betatunnel_prefer_beta" , OFS(lb_auto_betatunnel_prefer_beta), DEFAULT_LB_AUTO_BETATUNNEL_PREFER_BETA),
|
---|
380 | DEF_OPT_STR("lb_savepath" , OFS(lb_savepath), NULL),
|
---|
381 | DEF_OPT_FUNC("lb_retrylimits" , OFS(lb_retrylimittab), caidvaluetab_fn),
|
---|
382 | DEF_OPT_FUNC("lb_nbest_percaid" , OFS(lb_nbest_readers_tab), caidvaluetab_fn),
|
---|
383 | DEF_OPT_FUNC("lb_noproviderforcaid" , OFS(lb_noproviderforcaid), check_caidtab_fn),
|
---|
384 | DEF_OPT_INT32("lb_auto_timeout" , OFS(lb_auto_timeout), DEFAULT_LB_AUTO_TIMEOUT),
|
---|
385 | DEF_OPT_INT32("lb_auto_timeout_p" , OFS(lb_auto_timeout_p), DEFAULT_LB_AUTO_TIMEOUT_P),
|
---|
386 | DEF_OPT_INT32("lb_auto_timeout_t" , OFS(lb_auto_timeout_t), DEFAULT_LB_AUTO_TIMEOUT_T),
|
---|
387 | #endif
|
---|
388 | DEF_OPT_FUNC("double_check_caid" , OFS(double_check_caid), check_caidtab_fn),
|
---|
389 | DEF_OPT_STR("ecmfmt" , OFS(ecmfmt), NULL),
|
---|
390 | DEF_OPT_INT32("resolvegethostbyname" , OFS(resolve_gethostbyname), 0),
|
---|
391 | DEF_OPT_INT32("failbantime" , OFS(failbantime), 0),
|
---|
392 | DEF_OPT_INT32("failbancount" , OFS(failbancount), 0),
|
---|
393 | DEF_OPT_INT8("suppresscmd08" , OFS(c35_suppresscmd08), 0),
|
---|
394 | DEF_OPT_INT8("getblockemmauprovid" , OFS(getblockemmauprovid), 0),
|
---|
395 | DEF_OPT_INT8("double_check" , OFS(double_check), 0),
|
---|
396 | DEF_OPT_INT8("disablecrccws" , OFS(disablecrccws), 0),
|
---|
397 | DEF_OPT_FUNC("disablecrccws_only_for" , OFS(disablecrccws_only_for), chk_ftab_fn),
|
---|
398 | DEF_LAST_OPT
|
---|
399 | };
|
---|
400 |
|
---|
401 | #ifdef CS_ANTICASC
|
---|
402 | static void anticasc_fixups_fn(void *UNUSED(var))
|
---|
403 | {
|
---|
404 | if(cfg.ac_users < 0) { cfg.ac_users = 0; }
|
---|
405 | if(cfg.ac_stime < 0) { cfg.ac_stime = 2; }
|
---|
406 | if(cfg.ac_samples < 2 || cfg.ac_samples > 10) { cfg.ac_samples = 10; }
|
---|
407 | if(cfg.ac_penalty < 0 || cfg.ac_penalty > 3) { cfg.ac_penalty = 0; }
|
---|
408 | if(cfg.ac_fakedelay < 100 || cfg.ac_fakedelay > 3000) { cfg.ac_fakedelay = 1000; }
|
---|
409 | if(cfg.ac_denysamples < 2 || cfg.ac_denysamples > cfg.ac_samples - 1) { cfg.ac_denysamples = cfg.ac_samples - 1; }
|
---|
410 | if(cfg.ac_denysamples + 1 > cfg.ac_samples) { cfg.ac_denysamples = cfg.ac_samples - 1; }
|
---|
411 | if(cfg.acosc_max_active_sids < 0) { cfg.acosc_max_active_sids = 0; }
|
---|
412 | if(cfg.acosc_zap_limit < 0) { cfg.acosc_zap_limit = 0; }
|
---|
413 | if(cfg.acosc_penalty < 0 || cfg.acosc_penalty > 3) { cfg.acosc_penalty = 0; }
|
---|
414 | if(cfg.acosc_penalty_duration < 0) { cfg.acosc_penalty_duration = 0; }
|
---|
415 | if(cfg.acosc_delay < 0 || cfg.acosc_delay > 4000) { cfg.acosc_delay = 0; }
|
---|
416 | }
|
---|
417 |
|
---|
418 | static bool anticasc_should_save_fn(void *UNUSED(var))
|
---|
419 | {
|
---|
420 | return cfg.ac_enabled || cfg.acosc_enabled;
|
---|
421 | }
|
---|
422 |
|
---|
423 | static const struct config_list anticasc_opts[] =
|
---|
424 | {
|
---|
425 | DEF_OPT_SAVE_FUNC(anticasc_should_save_fn),
|
---|
426 | DEF_OPT_FIXUP_FUNC(anticasc_fixups_fn),
|
---|
427 | DEF_OPT_INT8("enabled" , OFS(ac_enabled), 0),
|
---|
428 | DEF_OPT_INT32("numusers" , OFS(ac_users), 0),
|
---|
429 | DEF_OPT_INT32("sampletime" , OFS(ac_stime), 2),
|
---|
430 | DEF_OPT_INT32("samples" , OFS(ac_samples), 10),
|
---|
431 | DEF_OPT_INT8("penalty" , OFS(ac_penalty), 0),
|
---|
432 | DEF_OPT_STR("aclogfile" , OFS(ac_logfile), NULL),
|
---|
433 | DEF_OPT_INT32("fakedelay" , OFS(ac_fakedelay), 3000),
|
---|
434 | DEF_OPT_INT32("denysamples" , OFS(ac_denysamples), 8),
|
---|
435 | DEF_OPT_INT8("acosc_enabled" , OFS(acosc_enabled), 0 ),
|
---|
436 | DEF_OPT_INT8("acosc_max_active_sids" , OFS(acosc_max_active_sids), 0 ),
|
---|
437 | DEF_OPT_INT8("acosc_zap_limit" , OFS(acosc_zap_limit), 0 ),
|
---|
438 | DEF_OPT_INT8("acosc_penalty" , OFS(acosc_penalty), 0 ),
|
---|
439 | DEF_OPT_INT32("acosc_penalty_duration" , OFS(acosc_penalty_duration), 0 ),
|
---|
440 | DEF_OPT_INT32("acosc_delay" , OFS(acosc_delay), 0 ),
|
---|
441 | DEF_LAST_OPT
|
---|
442 | };
|
---|
443 | #else
|
---|
444 | static const struct config_list anticasc_opts[] = { DEF_LAST_OPT };
|
---|
445 | #endif
|
---|
446 |
|
---|
447 | #ifdef MODULE_MONITOR
|
---|
448 | static bool monitor_should_save_fn(void *UNUSED(var))
|
---|
449 | {
|
---|
450 | return cfg.mon_port;
|
---|
451 | }
|
---|
452 |
|
---|
453 | static const struct config_list monitor_opts[] =
|
---|
454 | {
|
---|
455 | DEF_OPT_SAVE_FUNC(monitor_should_save_fn),
|
---|
456 | DEF_OPT_INT32("port" , OFS(mon_port), 0),
|
---|
457 | DEF_OPT_FUNC("serverip" , OFS(mon_srvip), serverip_fn),
|
---|
458 | DEF_OPT_FUNC("nocrypt" , OFS(mon_allowed), iprange_fn, .free_value = iprange_free_fn),
|
---|
459 | DEF_OPT_INT32("aulow" , OFS(aulow), 30),
|
---|
460 | DEF_OPT_UINT8("monlevel" , OFS(mon_level), 2),
|
---|
461 | DEF_OPT_INT32("hideclient_to" , OFS(hideclient_to), 25),
|
---|
462 | DEF_LAST_OPT
|
---|
463 | };
|
---|
464 | #else
|
---|
465 | static const struct config_list monitor_opts[] = { DEF_LAST_OPT };
|
---|
466 | #endif
|
---|
467 |
|
---|
468 | #ifdef WEBIF
|
---|
469 | static void http_port_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
470 | {
|
---|
471 | if(value)
|
---|
472 | {
|
---|
473 | cfg.http_port = 0;
|
---|
474 | if(value[0])
|
---|
475 | {
|
---|
476 | if(value[0] == '+')
|
---|
477 | {
|
---|
478 | if(config_enabled(WITH_SSL))
|
---|
479 | {
|
---|
480 | cfg.http_use_ssl = 1;
|
---|
481 | }
|
---|
482 | else
|
---|
483 | {
|
---|
484 | fprintf(stderr, "Warning: OSCam compiled without SSL support.\n");
|
---|
485 | }
|
---|
486 | cfg.http_port = strtoul(value + 1, NULL, 10);
|
---|
487 | }
|
---|
488 | else
|
---|
489 | {
|
---|
490 | cfg.http_port = strtoul(value, NULL, 10);
|
---|
491 | }
|
---|
492 | }
|
---|
493 | return;
|
---|
494 | }
|
---|
495 | fprintf_conf(f, token, "%s%d\n", cfg.http_use_ssl ? "+" : "", cfg.http_port);
|
---|
496 | }
|
---|
497 |
|
---|
498 | static void http_dyndns_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
499 | {
|
---|
500 | int i;
|
---|
501 | if(value)
|
---|
502 | {
|
---|
503 | char *ptr, *saveptr1 = NULL;
|
---|
504 | memset(cfg.http_dyndns, 0, sizeof(cfg.http_dyndns));
|
---|
505 | for(i = 0, ptr = strtok_r(value, ",", &saveptr1); (i < MAX_HTTP_DYNDNS) && (ptr); ptr = strtok_r(NULL, ",", &saveptr1), i++)
|
---|
506 | {
|
---|
507 | trim(ptr);
|
---|
508 | cs_strncpy((char *)cfg.http_dyndns[i], ptr, sizeof(cfg.http_dyndns[i]));
|
---|
509 | }
|
---|
510 | return;
|
---|
511 | }
|
---|
512 | if(strlen((const char *)(cfg.http_dyndns[0])) > 0 || cfg.http_full_cfg)
|
---|
513 | {
|
---|
514 | fprintf_conf(f, token, "%s", ""); // it should not have \n at the end
|
---|
515 | for(i = 0; i < MAX_HTTP_DYNDNS; i++)
|
---|
516 | {
|
---|
517 | if(cfg.http_dyndns[i][0])
|
---|
518 | {
|
---|
519 | fprintf(f, "%s%s", i > 0 ? "," : "", cfg.http_dyndns[i]);
|
---|
520 | }
|
---|
521 | }
|
---|
522 | fprintf(f, "\n");
|
---|
523 | }
|
---|
524 | }
|
---|
525 |
|
---|
526 | static bool webif_should_save_fn(void *UNUSED(var))
|
---|
527 | {
|
---|
528 | return cfg.http_port;
|
---|
529 | }
|
---|
530 |
|
---|
531 | static const struct config_list webif_opts[] =
|
---|
532 | {
|
---|
533 | DEF_OPT_SAVE_FUNC(webif_should_save_fn),
|
---|
534 | DEF_OPT_FUNC("httpport" , OFS(http_port) , http_port_fn),
|
---|
535 | DEF_OPT_FUNC("serverip" , OFS(http_srvip) , serverip_fn),
|
---|
536 | DEF_OPT_STR("httpuser" , OFS(http_user) , NULL),
|
---|
537 | DEF_OPT_STR("httppwd" , OFS(http_pwd) , NULL),
|
---|
538 | DEF_OPT_STR("httpcss" , OFS(http_css) , NULL),
|
---|
539 | DEF_OPT_STR("httpjscript" , OFS(http_jscript) , NULL),
|
---|
540 | DEF_OPT_STR("httpscript" , OFS(http_script) , NULL),
|
---|
541 | DEF_OPT_STR("httptpl" , OFS(http_tpl) , NULL),
|
---|
542 | DEF_OPT_STR("httppiconpath" , OFS(http_piconpath) , NULL),
|
---|
543 | DEF_OPT_STR("httphelplang" , OFS(http_help_lang) , "en"),
|
---|
544 | DEF_OPT_STR("httplocale" , OFS(http_locale) , NULL),
|
---|
545 | DEF_OPT_INT8("http_prepend_embedded_css" , OFS(http_prepend_embedded_css) , 0),
|
---|
546 | DEF_OPT_INT32("httprefresh" , OFS(http_refresh) , 0),
|
---|
547 | DEF_OPT_INT32("httppollrefresh" , OFS(poll_refresh) , 60),
|
---|
548 | DEF_OPT_INT8("httphideidleclients" , OFS(http_hide_idle_clients) , 1),
|
---|
549 | DEF_OPT_STR("httphidetype" , OFS(http_hide_type) , NULL),
|
---|
550 | DEF_OPT_INT8("httpshowpicons" , OFS(http_showpicons) , 0),
|
---|
551 | DEF_OPT_INT8("httppiconsize" , OFS(http_picon_size) , 0),
|
---|
552 | DEF_OPT_INT8("httpshowmeminfo" , OFS(http_showmeminfo) , 0),
|
---|
553 | DEF_OPT_INT8("httpshowuserinfo" , OFS(http_showuserinfo) , 0),
|
---|
554 | DEF_OPT_INT8("httpshowreaderinfo" , OFS(http_showreaderinfo) , 0),
|
---|
555 | DEF_OPT_INT8("httpshowcacheexinfo" , OFS(http_showcacheexinfo) , 0),
|
---|
556 | DEF_OPT_INT8("httpshowecminfo" , OFS(http_showecminfo) , 0),
|
---|
557 | DEF_OPT_INT8("httpshowloadinfo" , OFS(http_showloadinfo) , 0),
|
---|
558 | DEF_OPT_FUNC("httpallowed" , OFS(http_allowed) , iprange_fn, .free_value = iprange_free_fn),
|
---|
559 | DEF_OPT_INT8("httpreadonly" , OFS(http_readonly) , 0),
|
---|
560 | DEF_OPT_INT8("httpsavefullcfg" , OFS(http_full_cfg) , 0),
|
---|
561 | DEF_OPT_INT8("httpoverwritebakfile" , OFS(http_overwrite_bak_file) , 0),
|
---|
562 | DEF_OPT_STR("httpcert" , OFS(http_cert) , NULL),
|
---|
563 | DEF_OPT_INT8("https_force_secure_mode" , OFS(https_force_secure_mode) , 1),
|
---|
564 | DEF_OPT_FUNC("httpdyndns" , OFS(http_dyndns) , http_dyndns_fn),
|
---|
565 | DEF_OPT_INT32("aulow" , OFS(aulow) , 30),
|
---|
566 | DEF_OPT_INT32("hideclient_to" , OFS(hideclient_to) , 25),
|
---|
567 | DEF_OPT_STR("httposcamlabel" , OFS(http_oscam_label) , "OSCam"),
|
---|
568 | DEF_OPT_INT32("httpemmuclean" , OFS(http_emmu_clean) , 256),
|
---|
569 | DEF_OPT_INT32("httpemmsclean" , OFS(http_emms_clean) , -1),
|
---|
570 | DEF_OPT_INT32("httpemmgclean" , OFS(http_emmg_clean) , -1),
|
---|
571 | #ifdef WEBIF_LIVELOG
|
---|
572 | DEF_OPT_INT8("http_status_log" , OFS(http_status_log) , 0),
|
---|
573 | #else
|
---|
574 | DEF_OPT_INT8("http_status_log" , OFS(http_status_log) , 1),
|
---|
575 | #endif
|
---|
576 | #ifndef WEBIF_JQUERY
|
---|
577 | DEF_OPT_STR("http_extern_jquery" , OFS(http_extern_jquery) , "//code.jquery.com/jquery-1.12.4.min.js"),
|
---|
578 | #endif
|
---|
579 | DEF_LAST_OPT
|
---|
580 | };
|
---|
581 | #else
|
---|
582 | static const struct config_list webif_opts[] = { DEF_LAST_OPT };
|
---|
583 | #endif
|
---|
584 |
|
---|
585 | #ifdef MODULE_CAMD33
|
---|
586 | static bool camd33_should_save_fn(void *UNUSED(var))
|
---|
587 | {
|
---|
588 | return cfg.c33_port;
|
---|
589 | }
|
---|
590 |
|
---|
591 | static const struct config_list camd33_opts[] =
|
---|
592 | {
|
---|
593 | DEF_OPT_SAVE_FUNC(camd33_should_save_fn),
|
---|
594 | DEF_OPT_INT32("port" , OFS(c33_port), 0),
|
---|
595 | DEF_OPT_FUNC("serverip" , OFS(c33_srvip), serverip_fn),
|
---|
596 | DEF_OPT_FUNC("nocrypt" , OFS(c33_plain), iprange_fn, .free_value = iprange_free_fn),
|
---|
597 | DEF_OPT_INT32("passive" , OFS(c33_passive), 0),
|
---|
598 | DEF_OPT_HEX("key" , OFS(c33_key), SIZEOF(c33_key)),
|
---|
599 | DEF_LAST_OPT
|
---|
600 | };
|
---|
601 | #else
|
---|
602 | static const struct config_list camd33_opts[] = { DEF_LAST_OPT };
|
---|
603 | #endif
|
---|
604 |
|
---|
605 |
|
---|
606 | void cache_fixups_fn(void *UNUSED(var))
|
---|
607 | {
|
---|
608 | if(cfg.max_cache_time < ((int32_t)(cfg.ctimeout + 500) / 1000 + 3)) { cfg.max_cache_time = ((cfg.ctimeout + 500) / 1000 + 3); }
|
---|
609 | #ifdef CW_CYCLE_CHECK
|
---|
610 | if(cfg.maxcyclelist > 4000) { cfg.maxcyclelist = 4000; }
|
---|
611 | if(cfg.keepcycletime > 240) { cfg.keepcycletime = 240; }
|
---|
612 | if(cfg.cwcycle_sensitive > 4) { cfg.cwcycle_sensitive = 4; }
|
---|
613 | if(cfg.cwcycle_sensitive == 1) { cfg.cwcycle_sensitive = 2; }
|
---|
614 | #endif
|
---|
615 | }
|
---|
616 |
|
---|
617 | static bool cache_should_save_fn(void *UNUSED(var))
|
---|
618 | {
|
---|
619 | return cfg.delay > 0 || cfg.max_cache_time != 15
|
---|
620 | #ifdef CS_CACHEEX
|
---|
621 | || cfg.cacheex_wait_timetab.cevnum || cfg.cacheex_enable_stats > 0 || cfg.csp_port || cfg.csp.filter_caidtab.cevnum || cfg.csp.allow_request == 0 || cfg.csp.allow_reforward > 0
|
---|
622 | #endif
|
---|
623 | #ifdef CW_CYCLE_CHECK
|
---|
624 | || cfg.cwcycle_check_enable || cfg.cwcycle_check_caidtab.ctnum || cfg.maxcyclelist != 500 || cfg.keepcycletime || cfg.onbadcycle || cfg.cwcycle_dropold || cfg.cwcycle_sensitive || cfg.cwcycle_allowbadfromffb || cfg.cwcycle_usecwcfromce
|
---|
625 | #endif
|
---|
626 | ;
|
---|
627 | }
|
---|
628 |
|
---|
629 | static const struct config_list cache_opts[] =
|
---|
630 | {
|
---|
631 | DEF_OPT_SAVE_FUNC(cache_should_save_fn),
|
---|
632 | DEF_OPT_FIXUP_FUNC(cache_fixups_fn),
|
---|
633 | DEF_OPT_UINT32("delay" , OFS(delay), CS_DELAY),
|
---|
634 | DEF_OPT_INT32("max_time" , OFS(max_cache_time), DEFAULT_MAX_CACHE_TIME),
|
---|
635 | #ifdef CS_CACHEEX
|
---|
636 | DEF_OPT_INT32("max_hit_time" , OFS(max_hitcache_time), DEFAULT_MAX_HITCACHE_TIME),
|
---|
637 | DEF_OPT_FUNC("wait_time" , OFS(cacheex_wait_timetab), cacheex_valuetab_fn),
|
---|
638 | DEF_OPT_FUNC("cacheex_mode1_delay" , OFS(cacheex_mode1_delay_tab), caidvaluetab_fn),
|
---|
639 | DEF_OPT_UINT8("cacheexenablestats" , OFS(cacheex_enable_stats), 0),
|
---|
640 | DEF_OPT_INT32("csp_port" , OFS(csp_port), 0),
|
---|
641 | DEF_OPT_FUNC("csp_serverip" , OFS(csp_srvip), serverip_fn),
|
---|
642 | DEF_OPT_FUNC("csp_ecm_filter" , OFS(csp.filter_caidtab), cacheex_hitvaluetab_fn),
|
---|
643 | DEF_OPT_UINT8("csp_allow_request" , OFS(csp.allow_request), 1),
|
---|
644 | DEF_OPT_UINT8("csp_allow_reforward" , OFS(csp.allow_reforward), 0),
|
---|
645 | DEF_OPT_FUNC("cacheex_cw_check" , OFS(cacheex_cwcheck_tab), cacheex_cwcheck_tab_fn),
|
---|
646 | DEF_OPT_UINT8("wait_until_ctimeout" , OFS(wait_until_ctimeout), 0),
|
---|
647 | DEF_OPT_UINT8("csp_block_fakecws" , OFS(csp.block_fakecws), 0),
|
---|
648 | #endif
|
---|
649 | #ifdef CW_CYCLE_CHECK
|
---|
650 | DEF_OPT_INT8("cwcycle_check_enable" , OFS(cwcycle_check_enable), 0),
|
---|
651 | DEF_OPT_FUNC("cwcycle_check_caid" , OFS(cwcycle_check_caidtab), check_caidtab_fn),
|
---|
652 | DEF_OPT_INT32("cwcycle_maxlist" , OFS(maxcyclelist), 500),
|
---|
653 | DEF_OPT_INT32("cwcycle_keeptime" , OFS(keepcycletime), 15),
|
---|
654 | DEF_OPT_INT8("cwcycle_onbad" , OFS(onbadcycle), 1),
|
---|
655 | DEF_OPT_INT8("cwcycle_dropold" , OFS(cwcycle_dropold), 1),
|
---|
656 | DEF_OPT_INT8("cwcycle_sensitive" , OFS(cwcycle_sensitive), 4),
|
---|
657 | DEF_OPT_INT8("cwcycle_allowbadfromffb" , OFS(cwcycle_allowbadfromffb), 0),
|
---|
658 | DEF_OPT_INT8("cwcycle_usecwcfromce" , OFS(cwcycle_usecwcfromce), 0),
|
---|
659 | #endif
|
---|
660 | DEF_LAST_OPT
|
---|
661 | };
|
---|
662 |
|
---|
663 | #ifdef MODULE_CAMD35
|
---|
664 | static bool camd35_should_save_fn(void *UNUSED(var))
|
---|
665 | {
|
---|
666 | return cfg.c35_port;
|
---|
667 | }
|
---|
668 |
|
---|
669 | static const struct config_list camd35_opts[] =
|
---|
670 | {
|
---|
671 | DEF_OPT_SAVE_FUNC(camd35_should_save_fn),
|
---|
672 | DEF_OPT_INT32("port" , OFS(c35_port), 0),
|
---|
673 | DEF_OPT_FUNC("serverip" , OFS(c35_srvip), serverip_fn),
|
---|
674 | DEF_OPT_INT8("suppresscmd08" , OFS(c35_udp_suppresscmd08), 0),
|
---|
675 | DEF_LAST_OPT
|
---|
676 | };
|
---|
677 | #else
|
---|
678 | static const struct config_list camd35_opts[] = { DEF_LAST_OPT };
|
---|
679 | #endif
|
---|
680 |
|
---|
681 | #ifdef MODULE_NEWCAMD
|
---|
682 | static void porttab_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
683 | {
|
---|
684 | PTAB *ptab = setting;
|
---|
685 | if(value)
|
---|
686 | {
|
---|
687 | if(strlen(value) == 0)
|
---|
688 | {
|
---|
689 | clear_ptab(ptab);
|
---|
690 | }
|
---|
691 | else
|
---|
692 | {
|
---|
693 | chk_port_tab(value, ptab);
|
---|
694 | }
|
---|
695 | return;
|
---|
696 | }
|
---|
697 | value = mk_t_newcamd_port();
|
---|
698 | fprintf_conf(f, token, "%s\n", value);
|
---|
699 | free_mk_t(value);
|
---|
700 | }
|
---|
701 | #endif
|
---|
702 |
|
---|
703 | #ifdef MODULE_CAMD35_TCP
|
---|
704 | static void porttab_camd35_fn(const char *token, char *value, void *setting, FILE *f)
|
---|
705 | {
|
---|
706 | PTAB *ptab = setting;
|
---|
707 | if(value)
|
---|
708 | {
|
---|
709 | if(strlen(value) == 0)
|
---|
710 | {
|
---|
711 | clear_ptab(ptab);
|
---|
712 | }
|
---|
713 | else
|
---|
714 | {
|
---|
715 | chk_port_camd35_tab(value, ptab);
|
---|
716 | }
|
---|
717 | return;
|
---|
718 | }
|
---|
719 | value = mk_t_camd35tcp_port();
|
---|
720 | fprintf_conf(f, token, "%s\n", value);
|
---|
721 | free_mk_t(value);
|
---|
722 | }
|
---|
723 | #endif
|
---|
724 |
|
---|
725 | #if defined(MODULE_NEWCAMD) || defined(MODULE_CAMD35_TCP)
|
---|
726 | static void porttab_free_fn(void *setting)
|
---|
727 | {
|
---|
728 | clear_ptab(setting);
|
---|
729 | }
|
---|
730 | #endif
|
---|
731 |
|
---|
732 | #ifdef MODULE_CAMD35_TCP
|
---|
733 | static bool cs378x_should_save_fn(void *UNUSED(var))
|
---|
734 | {
|
---|
735 | return cfg.c35_tcp_ptab.nports && cfg.c35_tcp_ptab.ports[0].s_port;
|
---|
736 | }
|
---|
737 |
|
---|
738 | static const struct config_list cs378x_opts[] =
|
---|
739 | {
|
---|
740 | DEF_OPT_SAVE_FUNC(cs378x_should_save_fn),
|
---|
741 | DEF_OPT_FUNC("port" , OFS(c35_tcp_ptab) , porttab_camd35_fn , .free_value = porttab_free_fn),
|
---|
742 | DEF_OPT_FUNC("serverip" , OFS(c35_tcp_srvip) , serverip_fn),
|
---|
743 | DEF_OPT_INT8("suppresscmd08" , OFS(c35_tcp_suppresscmd08), 0),
|
---|
744 | DEF_LAST_OPT
|
---|
745 | };
|
---|
746 | #else
|
---|
747 | static const struct config_list cs378x_opts[] = { DEF_LAST_OPT };
|
---|
748 | #endif
|
---|
749 |
|
---|
750 | #ifdef MODULE_NEWCAMD
|
---|
751 | static bool newcamd_should_save_fn(void *UNUSED(var))
|
---|
752 | {
|
---|
753 | return cfg.ncd_ptab.nports && cfg.ncd_ptab.ports[0].s_port;
|
---|
754 | }
|
---|
755 |
|
---|
756 | static const struct config_list newcamd_opts[] =
|
---|
757 | {
|
---|
758 | DEF_OPT_SAVE_FUNC(newcamd_should_save_fn),
|
---|
759 | DEF_OPT_FUNC("port" , OFS(ncd_ptab) , porttab_fn, .free_value = porttab_free_fn),
|
---|
760 | DEF_OPT_FUNC("serverip" , OFS(ncd_srvip) , serverip_fn),
|
---|
761 | DEF_OPT_FUNC("allowed" , OFS(ncd_allowed) , iprange_fn, .free_value = iprange_free_fn),
|
---|
762 | DEF_OPT_HEX("key" , OFS(ncd_key) , SIZEOF(ncd_key)),
|
---|
763 | DEF_OPT_INT8("keepalive" , OFS(ncd_keepalive), DEFAULT_NCD_KEEPALIVE),
|
---|
764 | DEF_OPT_INT8("mgclient" , OFS(ncd_mgclient) , 0),
|
---|
765 | DEF_LAST_OPT
|
---|
766 | };
|
---|
767 | #else
|
---|
768 | static const struct config_list newcamd_opts[] = { DEF_LAST_OPT };
|
---|
769 | #endif
|
---|
770 |
|
---|
771 | #ifdef MODULE_CCCAM
|
---|
772 | static void cccam_port_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
773 | {
|
---|
774 | if(value)
|
---|
775 | {
|
---|
776 | int i;
|
---|
777 | char *ptr, *saveptr1 = NULL;
|
---|
778 | memset(cfg.cc_port, 0, sizeof(cfg.cc_port));
|
---|
779 | for(i = 0, ptr = strtok_r(value, ",", &saveptr1); ptr && i < CS_MAXPORTS; ptr = strtok_r(NULL, ",", &saveptr1))
|
---|
780 | {
|
---|
781 | cfg.cc_port[i] = strtoul(ptr, NULL, 10);
|
---|
782 | if(cfg.cc_port[i])
|
---|
783 | { i++; }
|
---|
784 | }
|
---|
785 | return;
|
---|
786 | }
|
---|
787 | value = mk_t_cccam_port();
|
---|
788 | fprintf_conf(f, token, "%s\n", value);
|
---|
789 | free_mk_t(value);
|
---|
790 | }
|
---|
791 |
|
---|
792 | static bool cccam_should_save_fn(void *UNUSED(var))
|
---|
793 | {
|
---|
794 | return cfg.cc_port[0];
|
---|
795 | }
|
---|
796 |
|
---|
797 | static const struct config_list cccam_opts[] =
|
---|
798 | {
|
---|
799 | DEF_OPT_SAVE_FUNC(cccam_should_save_fn),
|
---|
800 | DEF_OPT_FUNC("port" , OFS(cc_port), cccam_port_fn),
|
---|
801 | DEF_OPT_FUNC("serverip" , OFS(cc_srvip), serverip_fn),
|
---|
802 | DEF_OPT_HEX("nodeid" , OFS(cc_fixed_nodeid), SIZEOF(cc_fixed_nodeid)),
|
---|
803 | DEF_OPT_SSTR("version" , OFS(cc_version), "", SIZEOF(cc_version)),
|
---|
804 | DEF_OPT_INT8("reshare" , OFS(cc_reshare), 10),
|
---|
805 | DEF_OPT_INT8("reshare_mode" , OFS(cc_reshare_services), 4),
|
---|
806 | DEF_OPT_INT8("ignorereshare" , OFS(cc_ignore_reshare), 0),
|
---|
807 | DEF_OPT_INT8("forward_origin_card" , OFS(cc_forward_origin_card), 0),
|
---|
808 | DEF_OPT_INT8("stealth" , OFS(cc_stealth), 0),
|
---|
809 | DEF_OPT_INT32("updateinterval" , OFS(cc_update_interval), DEFAULT_UPDATEINTERVAL),
|
---|
810 | DEF_OPT_INT8("minimizecards" , OFS(cc_minimize_cards), 0),
|
---|
811 | DEF_OPT_INT8("keepconnected" , OFS(cc_keep_connected), 1),
|
---|
812 | DEF_OPT_UINT32("recv_timeout" , OFS(cc_recv_timeout), DEFAULT_CC_RECV_TIMEOUT),
|
---|
813 | DEF_LAST_OPT
|
---|
814 | };
|
---|
815 | #else
|
---|
816 | static const struct config_list cccam_opts[] = { DEF_LAST_OPT };
|
---|
817 | #endif
|
---|
818 |
|
---|
819 | #ifdef MODULE_PANDORA
|
---|
820 | static bool pandora_should_save_fn(void *UNUSED(var))
|
---|
821 | {
|
---|
822 | return cfg.pand_port;
|
---|
823 | }
|
---|
824 |
|
---|
825 | static const struct config_list pandora_opts[] =
|
---|
826 | {
|
---|
827 | DEF_OPT_SAVE_FUNC(pandora_should_save_fn),
|
---|
828 | DEF_OPT_INT32("pand_port" , OFS(pand_port), 0),
|
---|
829 | DEF_OPT_FUNC("pand_srvid" , OFS(pand_srvip), serverip_fn),
|
---|
830 | DEF_OPT_STR("pand_usr" , OFS(pand_usr), NULL),
|
---|
831 | DEF_OPT_STR("pand_pass" , OFS(pand_pass), NULL),
|
---|
832 | DEF_OPT_INT8("pand_ecm" , OFS(pand_ecm), 0),
|
---|
833 | DEF_OPT_INT8("pand_skip_send_dw" , OFS(pand_skip_send_dw), 0),
|
---|
834 | DEF_OPT_FUNC("pand_allowed" , OFS(pand_allowed), iprange_fn, .free_value = iprange_free_fn),
|
---|
835 | DEF_LAST_OPT
|
---|
836 | };
|
---|
837 | #else
|
---|
838 | static const struct config_list pandora_opts[] = { DEF_LAST_OPT };
|
---|
839 | #endif
|
---|
840 |
|
---|
841 | #ifdef MODULE_SCAM
|
---|
842 | static bool scam_should_save_fn(void *UNUSED(var))
|
---|
843 | {
|
---|
844 | return cfg.scam_port;
|
---|
845 | }
|
---|
846 | static const struct config_list scam_opts[] =
|
---|
847 | {
|
---|
848 | DEF_OPT_SAVE_FUNC(scam_should_save_fn),
|
---|
849 | DEF_OPT_INT32("port" , OFS(scam_port), 0),
|
---|
850 | DEF_OPT_FUNC("serverip" , OFS(scam_srvip), serverip_fn),
|
---|
851 | DEF_OPT_FUNC("allowed" , OFS(scam_allowed), iprange_fn, .free_value = iprange_free_fn),
|
---|
852 | DEF_LAST_OPT
|
---|
853 | };
|
---|
854 | #else
|
---|
855 | static const struct config_list scam_opts[] = { DEF_LAST_OPT };
|
---|
856 | #endif
|
---|
857 | #ifdef MODULE_RADEGAST
|
---|
858 | static bool radegast_should_save_fn(void *UNUSED(var))
|
---|
859 | {
|
---|
860 | return cfg.rad_port;
|
---|
861 | }
|
---|
862 |
|
---|
863 | static const struct config_list radegast_opts[] =
|
---|
864 | {
|
---|
865 | DEF_OPT_SAVE_FUNC(radegast_should_save_fn),
|
---|
866 | DEF_OPT_INT32("port" , OFS(rad_port), 0),
|
---|
867 | DEF_OPT_FUNC("serverip" , OFS(rad_srvip), serverip_fn),
|
---|
868 | DEF_OPT_FUNC("allowed" , OFS(rad_allowed), iprange_fn, .free_value = iprange_free_fn),
|
---|
869 | DEF_OPT_STR("user" , OFS(rad_usr), NULL),
|
---|
870 | DEF_LAST_OPT
|
---|
871 | };
|
---|
872 | #else
|
---|
873 | static const struct config_list radegast_opts[] = { DEF_LAST_OPT };
|
---|
874 | #endif
|
---|
875 |
|
---|
876 | #ifdef MODULE_SERIAL
|
---|
877 | static bool serial_should_save_fn(void *UNUSED(var))
|
---|
878 | {
|
---|
879 | return cfg.ser_device != NULL;
|
---|
880 | }
|
---|
881 |
|
---|
882 | static const struct config_list serial_opts[] =
|
---|
883 | {
|
---|
884 | DEF_OPT_SAVE_FUNC(serial_should_save_fn),
|
---|
885 | DEF_OPT_STR("device" , OFS(ser_device), NULL),
|
---|
886 | DEF_LAST_OPT
|
---|
887 | };
|
---|
888 | #else
|
---|
889 | static const struct config_list serial_opts[] = { DEF_LAST_OPT };
|
---|
890 | #endif
|
---|
891 |
|
---|
892 | #ifdef MODULE_GBOX
|
---|
893 |
|
---|
894 | static void gbox_password_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
895 | {
|
---|
896 | if (value)
|
---|
897 | {
|
---|
898 | const char *s;
|
---|
899 | s=value;
|
---|
900 | if (s[strspn(s, "0123456789abcdefABCDEF")] == 0)
|
---|
901 | {
|
---|
902 | /* valid Hexa symbol */
|
---|
903 | cfg.gbox_password = a2i(value, 8);
|
---|
904 | return;
|
---|
905 | }
|
---|
906 | else
|
---|
907 | {
|
---|
908 | cfg.gbox_password = 0;
|
---|
909 | }
|
---|
910 | }
|
---|
911 | if (cfg.gbox_password != 0)
|
---|
912 | {
|
---|
913 | fprintf_conf(f, token, "%08X\n", cfg.gbox_password);
|
---|
914 | }
|
---|
915 | }
|
---|
916 |
|
---|
917 | static void gbox_block_ecm_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
918 | {
|
---|
919 | if (value)
|
---|
920 | {
|
---|
921 | char *ptr1, *saveptr1 = NULL;
|
---|
922 | const char *s;
|
---|
923 | memset(cfg.gbox_block_ecm, 0, sizeof(cfg.gbox_block_ecm));
|
---|
924 | int n = 0, i;
|
---|
925 | for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < 4) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
|
---|
926 | {
|
---|
927 | s=ptr1;
|
---|
928 | if ((n < GBOX_MAX_BLOCKED_ECM) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0))
|
---|
929 | { cfg.gbox_block_ecm[n++] = a2i(ptr1, 4); }
|
---|
930 | }
|
---|
931 | cfg.gbox_block_ecm_num = n;
|
---|
932 | return;
|
---|
933 | }
|
---|
934 | if (cfg.gbox_block_ecm_num > 0)
|
---|
935 | {
|
---|
936 | value = mk_t_gbox_block_ecm();
|
---|
937 | fprintf_conf(f, token, "%s\n", value);
|
---|
938 | free_mk_t(value);
|
---|
939 | }
|
---|
940 | }
|
---|
941 |
|
---|
942 | static void gbox_ignored_peer_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
943 | {
|
---|
944 | if (value)
|
---|
945 | {
|
---|
946 | char *ptr1, *saveptr1 = NULL;
|
---|
947 | const char *s;
|
---|
948 | memset(cfg.gbox_ignored_peer, 0, sizeof(cfg.gbox_ignored_peer));
|
---|
949 | int n = 0, i;
|
---|
950 | for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < 4) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
|
---|
951 | {
|
---|
952 | s=ptr1;
|
---|
953 | if ((n < GBOX_MAX_IGNORED_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0))
|
---|
954 | { cfg.gbox_ignored_peer[n++] = a2i(ptr1, 4); }
|
---|
955 | }
|
---|
956 | cfg.gbox_ignored_peer_num = n;
|
---|
957 | return;
|
---|
958 | }
|
---|
959 | if (cfg.gbox_ignored_peer_num > 0)
|
---|
960 | {
|
---|
961 | value = mk_t_gbox_ignored_peer();
|
---|
962 | fprintf_conf(f, token, "%s\n", value);
|
---|
963 | free_mk_t(value);
|
---|
964 | }
|
---|
965 | }
|
---|
966 |
|
---|
967 | static void gbox_proxy_card_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
968 | {
|
---|
969 | if (value)
|
---|
970 | {
|
---|
971 | char *ptr1, *saveptr1 = NULL;
|
---|
972 | const char *s;
|
---|
973 | memset(cfg.gbox_proxy_card, 0, sizeof(cfg.gbox_proxy_card));
|
---|
974 | int n = 0, i;
|
---|
975 | for (i = 0, ptr1 = strtok_r(value, ",", &saveptr1); (i < 8) && (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
|
---|
976 | {
|
---|
977 | s=ptr1;
|
---|
978 | if ((n < GBOX_MAX_PROXY_CARDS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0))
|
---|
979 | { cfg.gbox_proxy_card[n++] = a2i(ptr1, 8); }
|
---|
980 | }
|
---|
981 | cfg.gbox_proxy_cards_num = n;
|
---|
982 | return;
|
---|
983 | }
|
---|
984 |
|
---|
985 | if (cfg.gbox_proxy_cards_num > 0)
|
---|
986 | {
|
---|
987 | value = mk_t_gbox_proxy_card();
|
---|
988 | fprintf_conf(f, token, "%s\n", value);
|
---|
989 | free_mk_t(value);
|
---|
990 | }
|
---|
991 | }
|
---|
992 |
|
---|
993 | static void gbox_port_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
994 | {
|
---|
995 | if(value)
|
---|
996 | {
|
---|
997 | int i;
|
---|
998 | char *ptr, *saveptr1 = NULL;
|
---|
999 | memset(cfg.gbox_port, 0, sizeof(cfg.gbox_port));
|
---|
1000 | for(i = 0, ptr = strtok_r(value, ",", &saveptr1); ptr && i < CS_MAXPORTS; ptr = strtok_r(NULL, ",", &saveptr1))
|
---|
1001 | {
|
---|
1002 | cfg.gbox_port[i] = strtoul(ptr, NULL, 10);
|
---|
1003 | if(cfg.gbox_port[i])
|
---|
1004 | { i++; }
|
---|
1005 | }
|
---|
1006 | return;
|
---|
1007 | }
|
---|
1008 | value = mk_t_gbox_port();
|
---|
1009 | fprintf_conf(f, token, "%s\n", value);
|
---|
1010 | free_mk_t(value);
|
---|
1011 | }
|
---|
1012 |
|
---|
1013 | static void gbox_my_vers_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
1014 | {
|
---|
1015 | if(value)
|
---|
1016 | {
|
---|
1017 | const char *s;
|
---|
1018 | s=value;
|
---|
1019 | int32_t len = strlen(value);
|
---|
1020 | if ((s[strspn(s, "0123456789abcdefABCDEF")] != 0) || (len == 0) || (len > 2))
|
---|
1021 | {
|
---|
1022 | cfg.gbox_my_vers = GBOX_MY_VERS_DEF;
|
---|
1023 | }
|
---|
1024 | else
|
---|
1025 | {
|
---|
1026 | cfg.gbox_my_vers = a2i(value,1);
|
---|
1027 | return;
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 | if(cfg.gbox_my_vers != GBOX_MY_VERS_DEF)
|
---|
1032 | {
|
---|
1033 | fprintf_conf(f, token, "%02X\n", cfg.gbox_my_vers);
|
---|
1034 | }
|
---|
1035 | else if(cfg.http_full_cfg)
|
---|
1036 | {
|
---|
1037 | fprintf_conf(f, token, "%02X\n", GBOX_MY_VERS_DEF);
|
---|
1038 | }
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | static void gbox_my_cpu_api_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
1042 | {
|
---|
1043 | if(value)
|
---|
1044 | {
|
---|
1045 | const char *s;
|
---|
1046 | s=value;
|
---|
1047 | int32_t len = strlen(value);
|
---|
1048 | if ((s[strspn(s, "0123456789abcdefABCDEF")] != 0) || (len == 0) || (len > 2))
|
---|
1049 | {
|
---|
1050 | cfg.gbox_my_cpu_api = GBOX_MY_CPU_API_DEF;
|
---|
1051 | }
|
---|
1052 | else
|
---|
1053 | {
|
---|
1054 | cfg.gbox_my_cpu_api = a2i(value,1);
|
---|
1055 | return;
|
---|
1056 | }
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | if(cfg.gbox_my_cpu_api != GBOX_MY_CPU_API_DEF)
|
---|
1060 | {
|
---|
1061 | fprintf_conf(f, token, "%02X\n", cfg.gbox_my_cpu_api);
|
---|
1062 | }
|
---|
1063 | else if(cfg.http_full_cfg)
|
---|
1064 | { fprintf_conf(f, token, "%02X\n", GBOX_MY_CPU_API_DEF); }
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | static void gbox_dest_peers_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
1068 | {
|
---|
1069 | if (value)
|
---|
1070 | {
|
---|
1071 | char *ptr1, *saveptr1 = NULL;
|
---|
1072 | const char *s;
|
---|
1073 | memset(cfg.gbox_dest_peers, 0, sizeof(cfg.gbox_dest_peers));
|
---|
1074 | int n = 0;
|
---|
1075 | for (ptr1 = strtok_r(value, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
|
---|
1076 | {
|
---|
1077 | s=trim(ptr1);
|
---|
1078 | if ((n < GBOX_MAX_DEST_PEERS) && (s[strspn(s, "0123456789abcdefABCDEF")] == 0))
|
---|
1079 | { cfg.gbox_dest_peers[n++] = a2i(trim(ptr1), strlen(trim(ptr1))); }
|
---|
1080 | }
|
---|
1081 | cfg.gbox_dest_peers_num = n;
|
---|
1082 | return;
|
---|
1083 | }
|
---|
1084 | if ((cfg.gbox_dest_peers_num > 0) && cfg.gbox_save_gsms)
|
---|
1085 | {
|
---|
1086 | value = mk_t_gbox_dest_peers();
|
---|
1087 | fprintf_conf(f, token, "%s\n", value);
|
---|
1088 | free_mk_t(value);
|
---|
1089 | }
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | static void gbox_msg_txt_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
1093 | {
|
---|
1094 | int len = 0;
|
---|
1095 | if (value)
|
---|
1096 | {
|
---|
1097 | len = strlen(value);
|
---|
1098 | if (len > GBOX_MAX_MSG_TXT) { len = GBOX_MAX_MSG_TXT; }
|
---|
1099 | cs_strncpy(cfg.gbox_msg_txt,value, len+1);
|
---|
1100 | return;
|
---|
1101 | }
|
---|
1102 | if ((cfg.gbox_msg_txt[0]!='\0') && cfg.gbox_save_gsms)
|
---|
1103 | {
|
---|
1104 | fprintf_conf(f, token, "%s\n", cfg.gbox_msg_txt);
|
---|
1105 | }
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | static bool gbox_should_save_fn(void *UNUSED(var))
|
---|
1109 | {
|
---|
1110 | return cfg.gbox_port[0];
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | static const struct config_list gbox_opts[] =
|
---|
1114 | {
|
---|
1115 | DEF_OPT_SAVE_FUNC(gbox_should_save_fn),
|
---|
1116 | DEF_OPT_FUNC("port" , OFS(gbox_port) , gbox_port_fn),
|
---|
1117 | DEF_OPT_STR("hostname" , OFS(gbox_hostname) , NULL),
|
---|
1118 | DEF_OPT_FUNC("my_password" , OFS(gbox_password) , gbox_password_fn ),
|
---|
1119 | DEF_OPT_INT32("gbox_reconnect" , OFS(gbox_reconnect) , DEFAULT_GBOX_RECONNECT),
|
---|
1120 | DEF_OPT_FUNC("my_vers" , OFS(gbox_my_vers) , gbox_my_vers_fn),
|
---|
1121 | DEF_OPT_FUNC("my_cpu_api" , OFS(gbox_my_cpu_api) , gbox_my_cpu_api_fn),
|
---|
1122 | DEF_OPT_UINT8("ccc_reshare" , OFS(ccc_reshare) , 0),
|
---|
1123 | DEF_OPT_UINT8("gsms_disable" , OFS(gsms_dis) , 1),
|
---|
1124 | DEF_OPT_UINT8("dis_attack_txt" , OFS(dis_attack_txt) , 0),
|
---|
1125 | DEF_OPT_UINT8("log_hello" , OFS(log_hello) , 1),
|
---|
1126 | DEF_OPT_STR("tmp_dir" , OFS(gbox_tmp_dir) , NULL ),
|
---|
1127 | DEF_OPT_FUNC("ignore_peer" , OFS(gbox_ignored_peer), gbox_ignored_peer_fn ),
|
---|
1128 | DEF_OPT_FUNC("block_ecm" , OFS(gbox_block_ecm) , gbox_block_ecm_fn ),
|
---|
1129 | DEF_OPT_FUNC("proxy_card" , OFS(gbox_proxy_card) , gbox_proxy_card_fn ),
|
---|
1130 | DEF_OPT_UINT8("gbox_save_gsms" , OFS(gbox_save_gsms) , 0),
|
---|
1131 | DEF_OPT_UINT8("gbox_msg_type" , OFS(gbox_msg_type) , 0),
|
---|
1132 | DEF_OPT_FUNC("gbox_dest_peers" , OFS(gbox_dest_peers) , gbox_dest_peers_fn ),
|
---|
1133 | DEF_OPT_FUNC("gbox_msg_txt" , OFS(gbox_msg_txt) , gbox_msg_txt_fn ),
|
---|
1134 | DEF_LAST_OPT
|
---|
1135 | };
|
---|
1136 | #else
|
---|
1137 | static const struct config_list gbox_opts[] = { DEF_LAST_OPT };
|
---|
1138 | #endif
|
---|
1139 |
|
---|
1140 | #ifdef HAVE_DVBAPI
|
---|
1141 | extern const char *boxdesc[];
|
---|
1142 |
|
---|
1143 | static void dvbapi_boxtype_fn(const char *token, char *value, void *UNUSED(setting), FILE *f)
|
---|
1144 | {
|
---|
1145 | if(value)
|
---|
1146 | {
|
---|
1147 | int i;
|
---|
1148 | cfg.dvbapi_boxtype = 0;
|
---|
1149 | for(i = 1; i <= BOXTYPES; i++)
|
---|
1150 | {
|
---|
1151 | if(streq(value, boxdesc[i]))
|
---|
1152 | {
|
---|
1153 | cfg.dvbapi_boxtype = i;
|
---|
1154 | break;
|
---|
1155 | }
|
---|
1156 | }
|
---|
1157 | return;
|
---|
1158 | }
|
---|
1159 | if(cfg.dvbapi_boxtype)
|
---|
1160 | { fprintf_conf(f, token, "%s\n", boxdesc[cfg.dvbapi_boxtype]); }
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | static void dvbapi_services_fn(const char *UNUSED(token), char *value, void *UNUSED(setting), FILE *UNUSED(f))
|
---|
1164 | {
|
---|
1165 | if(value)
|
---|
1166 | { chk_services(value, &cfg.dvbapi_sidtabs); }
|
---|
1167 | // THIS OPTION IS NOT SAVED
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | extern struct s_dvbapi_priority *dvbapi_priority;
|
---|
1171 |
|
---|
1172 | static void dvbapi_caidtab_fn(const char *UNUSED(token), char *caidasc, void *UNUSED(setting), long cmd, FILE *UNUSED(f))
|
---|
1173 | {
|
---|
1174 | char *ptr1, *ptr3, *saveptr1 = NULL;
|
---|
1175 | if(!caidasc)
|
---|
1176 | { return; }
|
---|
1177 | char type = (char)cmd;
|
---|
1178 | for(ptr1 = strtok_r(caidasc, ",", &saveptr1); (ptr1); ptr1 = strtok_r(NULL, ",", &saveptr1))
|
---|
1179 | {
|
---|
1180 | uint32_t caid, prov;
|
---|
1181 | if((ptr3 = strchr(trim(ptr1), ':')))
|
---|
1182 | { * ptr3++ = '\0'; }
|
---|
1183 | else
|
---|
1184 | { ptr3 = ""; }
|
---|
1185 | if(((caid = a2i(ptr1, 2)) | (prov = a2i(ptr3, 3))))
|
---|
1186 | {
|
---|
1187 | struct s_dvbapi_priority *entry;
|
---|
1188 | if(!cs_malloc(&entry, sizeof(struct s_dvbapi_priority)))
|
---|
1189 | { return; }
|
---|
1190 | entry->caid = caid;
|
---|
1191 | if(type == 'd')
|
---|
1192 | {
|
---|
1193 | char tmp1[5];
|
---|
1194 | snprintf(tmp1, sizeof(tmp1), "%04X", (uint)prov);
|
---|
1195 | int32_t cw_delay = strtol(tmp1, NULL, 10);
|
---|
1196 | entry->delay = cw_delay;
|
---|
1197 | }
|
---|
1198 | else
|
---|
1199 | {
|
---|
1200 | entry->provid = prov;
|
---|
1201 | }
|
---|
1202 | entry->type = type;
|
---|
1203 | entry->next = NULL;
|
---|
1204 | if(!dvbapi_priority)
|
---|
1205 | {
|
---|
1206 | dvbapi_priority = entry;
|
---|
1207 | }
|
---|
1208 | else
|
---|
1209 | {
|
---|
1210 | struct s_dvbapi_priority *p;
|
---|
1211 | for(p = dvbapi_priority; p->next != NULL; p = p->next)
|
---|
1212 | { ; }
|
---|
1213 | p->next = entry;
|
---|
1214 | }
|
---|
1215 | }
|
---|
1216 | }
|
---|
1217 | // THIS OPTION IS NOT SAVED
|
---|
1218 | }
|
---|
1219 |
|
---|
1220 | static bool dvbapi_should_save_fn(void *UNUSED(var))
|
---|
1221 | {
|
---|
1222 | return cfg.dvbapi_enabled;
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | static const struct config_list dvbapi_opts[] =
|
---|
1226 | {
|
---|
1227 | DEF_OPT_SAVE_FUNC(dvbapi_should_save_fn),
|
---|
1228 | DEF_OPT_INT8("enabled" , OFS(dvbapi_enabled), 0),
|
---|
1229 | DEF_OPT_INT8("au" , OFS(dvbapi_au), 0),
|
---|
1230 | DEF_OPT_INT8("pmt_mode" , OFS(dvbapi_pmtmode), 0),
|
---|
1231 | DEF_OPT_INT8("request_mode" , OFS(dvbapi_requestmode), 0),
|
---|
1232 | DEF_OPT_INT32("listen_port" , OFS(dvbapi_listenport), 0),
|
---|
1233 | DEF_OPT_INT32("delayer" , OFS(dvbapi_delayer), 0),
|
---|
1234 | DEF_OPT_INT8("ecminfo_type" , OFS(dvbapi_ecminfo_type), 0),
|
---|
1235 | DEF_OPT_STR("user" , OFS(dvbapi_usr), NULL),
|
---|
1236 | DEF_OPT_INT8("read_sdt" , OFS(dvbapi_read_sdt), 0),
|
---|
1237 | DEF_OPT_INT8("write_sdt_prov", OFS(dvbapi_write_sdt_prov), 0),
|
---|
1238 | DEF_OPT_INT8("extended_cw_api", OFS(dvbapi_extended_cw_api), 0),
|
---|
1239 | DEF_OPT_FUNC("boxtype" , OFS(dvbapi_boxtype), dvbapi_boxtype_fn),
|
---|
1240 | DEF_OPT_FUNC("services" , OFS(dvbapi_sidtabs.ok), dvbapi_services_fn),
|
---|
1241 | // OBSOLETE OPTIONS
|
---|
1242 | DEF_OPT_FUNC_X("priority" , 0, dvbapi_caidtab_fn, 'p'),
|
---|
1243 | DEF_OPT_FUNC_X("ignore" , 0, dvbapi_caidtab_fn, 'i'),
|
---|
1244 | DEF_OPT_FUNC_X("cw_delay" , 0, dvbapi_caidtab_fn, 'd'),
|
---|
1245 | DEF_LAST_OPT
|
---|
1246 | };
|
---|
1247 | #else
|
---|
1248 | static const struct config_list dvbapi_opts[] = { DEF_LAST_OPT };
|
---|
1249 | #endif
|
---|
1250 |
|
---|
1251 | #ifdef LCDSUPPORT
|
---|
1252 | static void lcd_fixups_fn(void *UNUSED(var))
|
---|
1253 | {
|
---|
1254 | if(cfg.lcd_write_intervall < 5) { cfg.lcd_write_intervall = 5; }
|
---|
1255 | }
|
---|
1256 |
|
---|
1257 | static bool lcd_should_save_fn(void *UNUSED(var))
|
---|
1258 | {
|
---|
1259 | return cfg.enablelcd;
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | static const struct config_list lcd_opts[] =
|
---|
1263 | {
|
---|
1264 | DEF_OPT_SAVE_FUNC(lcd_should_save_fn),
|
---|
1265 | DEF_OPT_FIXUP_FUNC(lcd_fixups_fn),
|
---|
1266 | DEF_OPT_INT8("enablelcd" , OFS(enablelcd), 0),
|
---|
1267 | DEF_OPT_STR("lcd_outputpath" , OFS(lcd_output_path), NULL),
|
---|
1268 | DEF_OPT_INT32("lcd_hideidle" , OFS(lcd_hide_idle), 0),
|
---|
1269 | DEF_OPT_INT32("lcd_writeintervall" , OFS(lcd_write_intervall), 10),
|
---|
1270 | DEF_LAST_OPT
|
---|
1271 | };
|
---|
1272 | #else
|
---|
1273 | static const struct config_list lcd_opts[] = { DEF_LAST_OPT };
|
---|
1274 | #endif
|
---|
1275 |
|
---|
1276 | static const struct config_sections oscam_conf[] =
|
---|
1277 | {
|
---|
1278 | { "global", global_opts }, // *** MUST BE FIRST ***
|
---|
1279 | { "anticasc", anticasc_opts },
|
---|
1280 | { "cache", cache_opts },
|
---|
1281 | { "lcd", lcd_opts },
|
---|
1282 | { "camd33", camd33_opts },
|
---|
1283 | { "cs357x", camd35_opts },
|
---|
1284 | { "cs378x", cs378x_opts },
|
---|
1285 | { "newcamd", newcamd_opts },
|
---|
1286 | { "radegast", radegast_opts },
|
---|
1287 | { "serial", serial_opts },
|
---|
1288 | { "gbox", gbox_opts },
|
---|
1289 | { "cccam", cccam_opts },
|
---|
1290 | { "pandora", pandora_opts },
|
---|
1291 | { "scam", scam_opts },
|
---|
1292 | { "dvbapi", dvbapi_opts },
|
---|
1293 | { "monitor", monitor_opts },
|
---|
1294 | { "webif", webif_opts },
|
---|
1295 | { NULL, NULL }
|
---|
1296 | };
|
---|
1297 |
|
---|
1298 | void config_set(char *section, const char *token, char *value)
|
---|
1299 | {
|
---|
1300 | config_set_value(oscam_conf, section, token, value, &cfg);
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 | void config_free(void)
|
---|
1304 | {
|
---|
1305 | config_sections_free(oscam_conf, &cfg);
|
---|
1306 | caidvaluetab_clear(&cfg.ftimeouttab);
|
---|
1307 | caidtab_clear(&cfg.double_check_caid);
|
---|
1308 | ftab_clear(&cfg.disablecrccws_only_for);
|
---|
1309 | #ifdef WITH_LB
|
---|
1310 | caidvaluetab_clear(&cfg.lb_retrylimittab);
|
---|
1311 | caidvaluetab_clear(&cfg.lb_nbest_readers_tab);
|
---|
1312 | caidtab_clear(&cfg.lb_noproviderforcaid);
|
---|
1313 | #endif
|
---|
1314 | #ifdef CS_CACHEEX
|
---|
1315 | caidvaluetab_clear(&cfg.cacheex_mode1_delay_tab);
|
---|
1316 | cecspvaluetab_clear(&cfg.cacheex_wait_timetab);
|
---|
1317 | #endif
|
---|
1318 | #ifdef CW_CYCLE_CHECK
|
---|
1319 | caidtab_clear(&cfg.cwcycle_check_caidtab);
|
---|
1320 | #endif
|
---|
1321 | }
|
---|
1322 |
|
---|
1323 | int32_t init_config(void)
|
---|
1324 | {
|
---|
1325 | FILE *fp;
|
---|
1326 |
|
---|
1327 | if(config_enabled(WEBIF))
|
---|
1328 | {
|
---|
1329 | fp = open_config_file(cs_conf);
|
---|
1330 | }
|
---|
1331 | else
|
---|
1332 | {
|
---|
1333 | fp = open_config_file_or_die(cs_conf);
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | const struct config_sections *cur_section = oscam_conf; // Global
|
---|
1337 | char *token;
|
---|
1338 |
|
---|
1339 | config_sections_set_defaults(oscam_conf, &cfg);
|
---|
1340 |
|
---|
1341 | if(!fp)
|
---|
1342 | {
|
---|
1343 | // no oscam.conf but webif is included in build, set it up for lan access and tweak defaults
|
---|
1344 | #ifdef WEBIF
|
---|
1345 | cfg.http_port = DEFAULT_HTTP_PORT;
|
---|
1346 | char *default_allowed;
|
---|
1347 | if ((default_allowed = cs_strdup(DEFAULT_HTTP_ALLOW)))
|
---|
1348 | {
|
---|
1349 | chk_iprange(default_allowed, &cfg.http_allowed);
|
---|
1350 | free(default_allowed);
|
---|
1351 | }
|
---|
1352 | #endif
|
---|
1353 | NULLFREE(cfg.logfile);
|
---|
1354 | cfg.logtostdout = 1;
|
---|
1355 | #ifdef HAVE_DVBAPI
|
---|
1356 | cfg.dvbapi_enabled = 1;
|
---|
1357 | #endif
|
---|
1358 | return 0;
|
---|
1359 | }
|
---|
1360 |
|
---|
1361 | if(!cs_malloc(&token, MAXLINESIZE))
|
---|
1362 | { return 1; }
|
---|
1363 |
|
---|
1364 | int line = 0;
|
---|
1365 | int valid_section = 1;
|
---|
1366 | while(fgets(token, MAXLINESIZE, fp))
|
---|
1367 | {
|
---|
1368 | ++line;
|
---|
1369 | int len = strlen(trim(token));
|
---|
1370 | if(len < 3) // a=b or [a] are at least 3 chars
|
---|
1371 | { continue; }
|
---|
1372 | if(token[0] == '#') // Skip comments
|
---|
1373 | { continue; }
|
---|
1374 | if(token[0] == '[' && token[len - 1] == ']')
|
---|
1375 | {
|
---|
1376 | token[len - 1] = '\0';
|
---|
1377 | valid_section = 0;
|
---|
1378 | const struct config_sections *newconf = config_find_section(oscam_conf, token + 1);
|
---|
1379 | if(config_section_is_active(newconf) && cur_section)
|
---|
1380 | {
|
---|
1381 | config_list_apply_fixups(cur_section->config, &cfg);
|
---|
1382 | cur_section = newconf;
|
---|
1383 | valid_section = 1;
|
---|
1384 | }
|
---|
1385 | if(!newconf)
|
---|
1386 | {
|
---|
1387 | fprintf(stderr, "WARNING: %s line %d unknown section [%s].\n",
|
---|
1388 | cs_conf, line, token + 1);
|
---|
1389 | continue;
|
---|
1390 | }
|
---|
1391 | if(!config_section_is_active(newconf))
|
---|
1392 | {
|
---|
1393 | fprintf(stderr, "WARNING: %s line %d section [%s] is ignored (support not compiled in).\n",
|
---|
1394 | cs_conf, line, newconf->section);
|
---|
1395 | }
|
---|
1396 | continue;
|
---|
1397 | }
|
---|
1398 |
|
---|
1399 | if(!valid_section)
|
---|
1400 | { continue; }
|
---|
1401 | char *value = strchr(token, '=');
|
---|
1402 | if(!value) // No = found, well go on
|
---|
1403 | { continue; }
|
---|
1404 | *value++ = '\0';
|
---|
1405 | char *tvalue = trim(value);
|
---|
1406 | char *ttoken = trim(strtolower(token));
|
---|
1407 | if(cur_section && !config_list_parse(cur_section->config, ttoken, tvalue, &cfg))
|
---|
1408 | {
|
---|
1409 | fprintf(stderr, "WARNING: %s line %d section [%s] contains unknown setting '%s=%s'\n",
|
---|
1410 | cs_conf, line, cur_section->section, ttoken, tvalue);
|
---|
1411 | }
|
---|
1412 | }
|
---|
1413 | NULLFREE(token);
|
---|
1414 | fclose(fp);
|
---|
1415 | if(cur_section) { config_list_apply_fixups(cur_section->config, &cfg); }
|
---|
1416 | return 0;
|
---|
1417 | }
|
---|
1418 |
|
---|
1419 | int32_t write_config(void)
|
---|
1420 | {
|
---|
1421 | FILE *f = create_config_file(cs_conf);
|
---|
1422 | if(!f)
|
---|
1423 | { return 1; }
|
---|
1424 | config_sections_save(oscam_conf, f, &cfg);
|
---|
1425 | return flush_config_file(f, cs_conf);
|
---|
1426 | }
|
---|