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