1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
|
-- Copyright 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
-- Licensed under the Apache License, Version 2.0
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local UTIL = require "luci.util"
local DISP = require "luci.dispatcher"
local DTYP = require "luci.cbi.datatypes"
local CTRL = require "luci.controller.privoxy" -- this application's controller
-- Bootstrap theme needs 2 or 3 additional linefeeds for tab description for better optic
local HELP = [[<a href="http://www.privoxy.org/user-manual/config.html#%s" target="_blank">%s</a>]]
local VERINST = CTRL.ipkg_ver_installed("privoxy")
local VEROK = CTRL.ipkg_ver_compare(VERINST,">=",CTRL.PRIVOXY_MIN)
local TITLE = [[</a><a href="javascript:alert(']]
.. translate("Version Information")
.. [[\n\nluci-app-privoxy]]
.. [[\n\t]] .. translate("Version") .. [[:\t]]
.. CTRL.ipkg_ver_installed("luci-app-privoxy")
.. [[\n\nprivoxy ]] .. translate("required") .. [[:]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. CTRL.PRIVOXY_MIN .. [[ ]] .. translate("or higher")
.. [[\n\nprivoxy ]] .. translate("installed") .. [[:]]
.. [[\n\t]] .. translate("Version") .. [[:\t]] .. VERINST
.. [[\n\n]]
.. [[')">]]
.. translate("Privoxy WEB proxy")
local DESC = translate("Privoxy is a non-caching web proxy with advanced filtering "
.. "capabilities for enhancing privacy, modifying web page data and HTTP headers, "
.. "controlling access, and removing ads and other obnoxious Internet junk.")
.. [[<br /><strong>]]
.. translate("For help use link at the relevant option")
.. [[</strong>]]
-- Error handling if wrong privoxy version installed -- ########################
if not nixio.fs.access("/etc/config/privoxy") or not VEROK then
local f = SimpleForm("_no_config")
f.title = TITLE
f.description = DESC
f.embedded = true
f.submit = false
f.reset = false
local s = f:section(SimpleSection)
s.title = [[<font color="red">]] .. [[<strong>]]
.. translate("Software update required")
.. [[</strong>]] .. [[</font>]]
local v = s:option(DummyValue, "_update_needed")
v.titleref = DISP.build_url("admin", "system", "packages")
v.rawhtml = true
v.value = [[<h3><strong><br /><br /> ]]
.. translate("The currently installed 'privoxy' package is not supported by LuCI application.")
.. [[<br /><br /> ]]
.. translate("required") .. ": " .. CTRL.PRIVOXY_MIN .. " *** ".. translate("installed") .. ": " .. VERINST
.. [[<br /><br /> ]]
.. translate("Please update to the current version!")
.. [[<br /><br /></strong></h3>]]
return f
end
-- cbi-map -- ##################################################################
local m = Map("privoxy")
m.title = TITLE
m.description = DESC
function m.commit_handler(self)
if self.changed then -- changes ?
os.execute("/etc/init.d/privoxy reload &") -- reload configuration
end
end
-- cbi-section -- ##############################################################
local ns = m:section( NamedSection, "privoxy", "privoxy")
ns:tab("local",
translate("Local Set-up"),
translate("If you intend to operate Privoxy for more users than just yourself, "
.. "it might be a good idea to let them know how to reach you, what you block "
.. "and why you do that, your policies, etc.") )
local function err_tab_local(title, msg)
return string.format(translate("Local Set-up") .. " - %s: %s", title, msg )
end
ns:tab("filter",
translate("Files and Directories"),
translate("Privoxy can (and normally does) use a number of other files "
.. "for additional configuration, help and logging. This section of "
.. "the configuration file tells Privoxy where to find those other files.") )
local function err_tab_filter(title, msg)
return string.format(translate("Files and Directories") .. " - %s: %s", title, msg )
end
ns:tab("access",
translate("Access Control"),
translate("This tab controls the security-relevant aspects of Privoxy's configuration.") )
local function err_tab_access(title, msg)
return string.format(translate("Access Control") .. " - %s: %s", title, msg )
end
ns:tab("forward",
translate("Forwarding"),
translate("Configure here the routing of HTTP requests through a chain of multiple proxies. "
.. "Note that parent proxies can severely decrease your privacy level. "
.. "Also specified here are SOCKS proxies.") )
ns:tab("misc",
translate("Miscellaneous"),
nil)
local function err_tab_misc(self, msg)
return string.format(translate("Miscellaneous") .. " - %s: %s", self.title_base, msg )
end
ns:tab("debug",
translate("Logging"),
nil )
ns:tab("logview",
translate("Log File Viewer"),
nil )
-- tab: local -- ###############################################################
-- start/stop button -----------------------------------------------------------
local btn = ns:taboption("local", Button, "_startstop")
btn.title = translate("Start / Stop")
btn.description = translate("Start/Stop Privoxy WEB Proxy")
btn.template = "privoxy/detail_startstop"
function btn.cfgvalue(self, section)
local pid = CTRL.get_pid(true)
if pid > 0 then
btn.inputtitle = "PID: " .. pid
btn.inputstyle = "reset"
btn.disabled = false
else
btn.inputtitle = translate("Start")
btn.inputstyle = "apply"
btn.disabled = false
end
return true
end
-- enabled ---------------------------------------------------------------------
local ena = ns:taboption("local", Flag, "_enabled")
ena.title = translate("Enabled")
ena.description = translate("Enable/Disable autostart of Privoxy on system startup and interface events")
ena.orientation = "horizontal" -- put description under the checkbox
ena.rmempty = false
function ena.cfgvalue(self, section)
return (SYS.init.enabled("privoxy")) and "1" or "0"
end
function ena.validate(self, value)
error("Validate " .. value)
end
function ena.write(self, section, value)
--error("Write " .. value)
if value == "1" then
return SYS.init.enable("privoxy")
else
return SYS.init.disable("privoxy")
end
end
-- hostname --------------------------------------------------------------------
local hn = ns:taboption("local", Value, "hostname")
hn.title = string.format(HELP, "HOSTNAME", "Hostname" )
hn.description = translate("The hostname shown on the CGI pages.")
hn.placeholder = SYS.hostname()
hn.optional = true
hn.rmempty = true
-- user-manual -----------------------------------------------------------------
local um = ns:taboption("local", Value, "user_manual")
um.title = string.format(HELP, "USER-MANUAL", "User Manual" )
um.description = translate("Location of the Privoxy User Manual.")
um.placeholder = "http://www.privoxy.org/user-manual/"
um.optional = true
um.rmempty = true
-- admin-address ---------------------------------------------------------------
local aa = ns:taboption("local", Value, "admin_address")
aa.title_base = "Admin Email"
aa.title = string.format(HELP, "ADMIN-ADDRESS", aa.title_base )
aa.description = translate("An email address to reach the Privoxy administrator.")
aa.placeholder = "privoxy.admin@example.com"
aa.optional = true
aa.rmempty = true
function aa.validate(self, value)
if not value or #value == 0 then
return ""
end
if not (value:match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?")) then
return nil, err_tab_local(self.title_base, translate("Invalid email address") )
end
return value
end
-- proxy-info-url --------------------------------------------------------------
local piu = ns:taboption("local", Value, "proxy_info_url")
piu.title = string.format(HELP, "PROXY-INFO-URL", "Proxy Info URL" )
piu.description = translate("A URL to documentation about the local Privoxy setup, configuration or policies.")
piu.optional = true
piu.rmempty = true
-- trust-info-url --------------------------------------------------------------
local tiu = ns:taboption("local", Value, "trust_info_url")
tiu.title = string.format(HELP, "TRUST-INFO-URL", "Trust Info URLs" )
tiu.description = translate("A URL to be displayed in the error page that users will see if access to an untrusted page is denied.")
.. [[<br /><strong>]]
.. translate("The value of this option only matters if the experimental trust mechanism has been activated.")
.. [[</strong>]]
tiu.optional = true
tiu.rmepty = true
-- tab: filter -- ##############################################################
-- logdir ----------------------------------------------------------------------
local ld = ns:taboption("filter", Value, "logdir")
ld.title_base = "Log Directory"
ld.title = string.format(HELP, "LOGDIR", ld.title_base )
ld.description = translate("The directory where all logging takes place (i.e. where the logfile is located).")
.. [[<br />]]
.. translate("No trailing '/', please.")
ld.default = "/var/log"
ld.rmempty = false
function ld.validate(self, value)
if not value or #value == 0 then
return nil, err_tab_filter(self.title_base, translate("Mandatory Input: No Directory given!") )
elseif not NXFS.access(value) then
return nil, err_tab_filter(self.title_base, translate("Directory does not exist!") )
else
return value
end
end
-- logfile ---------------------------------------------------------------------
local lf = ns:taboption("filter", Value, "logfile")
lf.title_base = "Log File"
lf.title = string.format(HELP, "LOGFILE", lf.title_base )
lf.description = translate("The log file to use. File name, relative to log directory.")
lf.default = "privoxy.log"
lf.rmempty = false
function lf.validate(self, value)
if not value or #value == 0 then
return nil, err_tab_filter(self.title_base, translate("Mandatory Input: No File given!") )
else
return value
end
end
-- confdir ---------------------------------------------------------------------
local cd = ns:taboption("filter", Value, "confdir")
cd.title_base = "Configuration Directory"
cd.title = string.format(HELP, "CONFDIR", cd.title_base )
cd.description = translate("The directory where the other configuration files are located.")
.. [[<br />]]
.. translate("No trailing '/', please.")
cd.default = "/etc/privoxy"
cd.rmempty = false
function cd.validate(self, value)
if not value or #value == 0 then
return nil, err_tab_filter(self.title_base, translate("Mandatory Input: No Directory given!") )
elseif not NXFS.access(value) then
return nil, err_tab_filter(self.title_base, translate("Directory does not exist!") )
else
return value
end
end
-- templdir --------------------------------------------------------------------
local tld = ns:taboption("filter", Value, "templdir")
tld.title_base = "Template Directory"
tld.title = string.format(HELP, "TEMPLDIR", tld.title_base )
tld.description = translate("An alternative directory where the templates are loaded from.")
.. [[<br />]]
.. translate("No trailing '/', please.")
tld.placeholder = "/etc/privoxy/templates"
tld.rmempty = true
function tld.validate(self, value)
if not NXFS.access(value) then
return nil, err_tab_filter(self.title_base, translate("Directory does not exist!") )
else
return value
end
end
-- temporary-directory ---------------------------------------------------------
local td = ns:taboption("filter", Value, "temporary_directory")
td.title_base = "Temporary Directory"
td.title = string.format(HELP, "TEMPORARY-DIRECTORY", td.title_base )
td.description = translate("A directory where Privoxy can create temporary files.")
.. [[<br /><strong>]]
.. translate("Only when using 'external filters', Privoxy has to create temporary files.")
.. [[</strong>]]
td.rmempty = true
-- actionsfile -----------------------------------------------------------------
local af = ns:taboption("filter", DynamicList, "actionsfile")
af.title_base = "Action Files"
af.title = string.format(HELP, "ACTIONSFILE", af.title_base)
af.description = translate("The actions file(s) to use. Multiple actionsfile lines are permitted, and are in fact recommended!")
.. [[<br /><strong>match-all.action := </strong>]]
.. translate("Actions that are applied to all sites and maybe overruled later on.")
.. [[<br /><strong>default.action := </strong>]]
.. translate("Main actions file")
.. [[<br /><strong>user.action := </strong>]]
.. translate("User customizations")
af.rmempty = false
function af.validate(self, value)
if not value or #value == 0 then
return nil, err_tab_access(self.title_base, translate("Mandatory Input: No files given!") )
end
local confdir = cd:formvalue(ns.section)
local err = false
local file = ""
if type(value) == "table" then
local x
for _, x in ipairs(value) do
if x and #x > 0 then
if not NXFS.access(confdir .."/".. x) then
err = true
file = x
break -- break/leave for on error
end
end
end
else
if not NXFS.access(confdir .."/".. value) then
err = true
file = value
end
end
if err then
return nil, string.format(err_tab_filter(self.title_base, translate("File '%s' not found inside Configuration Directory") ), file)
end
return value
end
-- filterfile ------------------------------------------------------------------
local ff = ns:taboption("filter", DynamicList, "filterfile")
ff.title_base = "Filter files"
ff.title = string.format(HELP, "FILTERFILE", ff.title_base )
ff.description = translate("The filter files contain content modification rules that use regular expressions.")
ff.rmempty = false
function ff.validate(self, value)
if not value or #value == 0 then
return nil, err_tab_access(self.title_base, translate("Mandatory Input: No files given!") )
end
local confdir = cd:formvalue(ns.section)
local err = false
local file = ""
if type(value) == "table" then
local x
for _, x in ipairs(value) do
if x and #x > 0 then
if not NXFS.access(confdir .."/".. x) then
err = true
file = x
break -- break/leave for on error
end
end
end
else
if not NXFS.access(confdir .."/".. value) then
err = true
file = value
end
end
if err then
return nil, string.format(err_tab_filter(self.title_base, translate("File '%s' not found inside Configuration Directory") ), file )
end
return value
end
-- trustfile -------------------------------------------------------------------
local tf = ns:taboption("filter", Value, "trustfile")
tf.title_base = "Trust file"
tf.title = string.format(HELP, "TRUSTFILE", tf.title_base )
tf.description = translate("The trust mechanism is an experimental feature for building white-lists "
.."and should be used with care.")
.. [[<br /><strong>]]
.. translate("It is NOT recommended for the casual user.")
.. [[</strong>]]
tf.placeholder = "user.trust"
tf.rmempty = true
function tf.validate(self, value)
local confdir = cd:formvalue(ns.section)
local err = false
local file = ""
if type(value) == "table" then
local x
for _, x in ipairs(value) do
if x and #x > 0 then
if not NCFS.access(confdir .."/".. x) then
err = true
file = x
break -- break/leave for on error
end
end
end
else
if not NXFS.access(confdir .."/".. value) then
err = true
file = value
end
end
if err then
return nil, string.format(err_tab_filter(self.title_base, translate("File '%s' not found inside Configuration Directory") ), file )
end
return value
end
-- tab: access -- ##############################################################
-- listen-address --------------------------------------------------------------
local la = ns:taboption("access", DynamicList, "listen_address")
la.title_base = "Listen addresses"
la.title = string.format(HELP, "LISTEN-ADDRESS", la.title_base )
la.description = translate("The address and TCP port on which Privoxy will listen for client requests.")
.. [[<br />]]
.. translate("Syntax: ")
.. "IPv4:Port / [IPv6]:Port / Host:Port"
la.default = "127.0.0.1:8118"
la.rmempty = false
function la.validate(self, value)
if not value or #value == 0 then
return nil, err_tab_access(self.title_base, translate("Mandatory Input: No Data given!") )
end
local function check_value(v)
local _ret = UTIL.split(v, "]:")
local _ip
if _ret[2] then -- ip6 with port
_ip = string.gsub(_ret[1], "%[", "") -- remove "[" at beginning
if not DTYP.ip6addr(_ip) then
return translate("Mandatory Input: No valid IPv6 address given!")
elseif not DTYP.port(_ret[2]) then
return translate("Mandatory Input: No valid Port given!")
else
return nil
end
end
_ret = UTIL.split(v, ":")
if not _ret[2] then
return translate("Mandatory Input: No Port given!")
end
if #_ret[1] > 0 and not DTYP.host(_ret[1]) then -- :8118 is valid address
return translate("Mandatory Input: No valid IPv4 address or host given!")
elseif not DTYP.port(_ret[2]) then
return translate("Mandatory Input: No valid Port given!")
else
return nil
end
end
local err = ""
local entry = ""
if type(value) == "table" then
local x
for _, x in ipairs(value) do
if x and #x > 0 then
err = check_value(x)
if err then
entry = x
break
end
end
end
else
err = check_value(value)
entry = value
end
if err then
return nil, string.format(err_tab_access(self.title_base, err .. " - %s"), entry )
end
return value
end
-- permit-access ---------------------------------------------------------------
local pa = ns:taboption("access", DynamicList, "permit_access")
pa.title = string.format(HELP, "ACLS", "Permit access" )
pa.description = translate("Who can access what.")
.. [[<br /><strong>]]
.. translate("Please read Privoxy manual for details!")
.. [[</strong>]]
pa.rmempty = true
-- deny-access -----------------------------------------------------------------
local da = ns:taboption("access", DynamicList, "deny_access")
da.title = string.format(HELP, "ACLS", "Deny Access" )
da.description = translate("Who can access what.")
.. [[<br /><strong>]]
.. translate("Please read Privoxy manual for details!")
.. [[</strong>]]
da.rmempty = true
-- buffer-limit ----------------------------------------------------------------
local bl = ns:taboption("access", Value, "buffer_limit")
bl.title_base = "Buffer Limit"
bl.title = string.format(HELP, "BUFFER-LIMIT", bl.title_base )
bl.description = translate("Maximum size (in KB) of the buffer for content filtering.")
.. [[<br />]]
.. translate("Value range 1 to 4096, no entry defaults to 4096")
bl.default = 4096
bl.rmempty = true
function bl.validate(self, value)
local v = tonumber(value)
if not v then
return nil, err_tab_access(self.title_base, translate("Value is not a number") )
elseif v < 1 or v > 4096 then
return nil, err_tab_access(self.title_base, translate("Value not between 1 and 4096") )
elseif v == self.default then
return "" -- dont need to save default
end
return value
end
-- toggle ----------------------------------------------------------------------
local tgl = ns:taboption("access", Flag, "toggle")
tgl.title = string.format(HELP, "TOGGLE", "Toggle Status" )
tgl.description = translate("Enable/Disable filtering when Privoxy starts.")
.. [[<br />]]
.. translate("Disabled == Transparent Proxy Mode")
tgl.orientation = "horizontal"
tgl.default = "1"
tgl.rmempty = false
function tgl.parse(self, section)
CTRL.flag_parse(self, section)
end
-- enable-remote-toggle --------------------------------------------------------
local ert = ns:taboption("access", Flag, "enable_remote_toggle")
ert.title = string.format(HELP, "ENABLE-REMOTE-TOGGLE", "Enable remote toggle" )
ert.description = translate("Whether or not the web-based toggle feature may be used.")
ert.orientation = "horizontal"
ert.rmempty = true
function ert.parse(self, section)
CTRL.flag_parse(self, section)
end
-- enable-remote-http-toggle ---------------------------------------------------
local eht = ns:taboption("access", Flag, "enable_remote_http_toggle")
eht.title = string.format(HELP, "ENABLE-REMOTE-HTTP-TOGGLE", "Enable remote toggle via HTTP" )
eht.description = translate("Whether or not Privoxy recognizes special HTTP headers to change toggle state.")
.. [[<br /><strong>]]
.. translate("This option will be removed in future releases as it has been obsoleted by the more general header taggers.")
.. [[</strong>]]
eht.orientation = "horizontal"
eht.rmempty = true
function eht.parse(self, section)
CTRL.flag_parse(self, section)
end
-- enable-edit-actions ---------------------------------------------------------
local eea = ns:taboption("access", Flag, "enable_edit_actions")
eea.title = string.format(HELP, "ENABLE-EDIT-ACTIONS", "Enable action file editor" )
eea.description = translate("Whether or not the web-based actions file editor may be used.")
eea.orientation = "horizontal"
eea.rmempty = true
function eea.parse(self, section)
CTRL.flag_parse(self, section)
end
-- enforce-blocks --------------------------------------------------------------
local eb = ns:taboption("access", Flag, "enforce_blocks")
eb.title = string.format(HELP, "ENFORCE-BLOCKS", "Enforce page blocking" )
eb.description = translate("If enabled, Privoxy hides the 'go there anyway' link. "
.. "The user obviously should not be able to bypass any blocks.")
eb.orientation = "horizontal"
eb.rmempty = true
function eb.parse(self, section)
CTRL.flag_parse(self, section)
end
-- tab: forward -- #############################################################
-- enable-proxy-authentication-forwarding --------------------------------------
local paf = ns:taboption("forward", Flag, "enable_proxy_authentication_forwarding")
paf.title = string.format(HELP, "ENABLE-PROXY-AUTHENTICATION-FORWARDING",
translate("Enable proxy authentication forwarding") )
paf.description = translate("Whether or not proxy authentication through Privoxy should work.")
.. [[<br /><strong>]]
.. translate("Enabling this option is NOT recommended if there is no parent proxy that requires authentication!")
.. [[</strong>]]
--paf.orientation = "horizontal"
paf.rmempty = true
function paf.parse(self, section)
CTRL.flag_parse(self, section)
end
-- forward ---------------------------------------------------------------------
local fwd = ns:taboption("forward", DynamicList, "forward")
fwd.title = string.format(HELP, "FORWARD", "Forward HTTP" )
fwd.description = translate("To which parent HTTP proxy specific requests should be routed.")
.. [[<br />]]
.. translate("Syntax: target_pattern http_parent[:port]")
fwd.rmempty = true
-- forward-socks4 --------------------------------------------------------------
local fs4 = ns:taboption("forward", DynamicList, "forward_socks4")
fs4.title = string.format(HELP, "SOCKS", "Forward SOCKS 4" )
fs4.description = translate("Through which SOCKS proxy (and optionally to which parent HTTP proxy) specific requests should be routed.")
.. [[<br />]]
.. translate("Syntax: target_pattern socks_proxy[:port] http_parent[:port]")
fs4.rmempty = true
-- forward-socks4a -------------------------------------------------------------
local f4a = ns:taboption("forward", DynamicList, "forward_socks4a")
f4a.title = string.format(HELP, "SOCKS", "Forward SOCKS 4A" )
f4a.description = fs4.description
f4a.rmempty = true
-- forward-socks5 --------------------------------------------------------------
local fs5 = ns:taboption("forward", DynamicList, "forward_socks5")
fs5.title = string.format(HELP, "SOCKS", "Forward SOCKS 5" )
fs5.description = fs4.description
fs5.rmempty = true
-- forward-socks5t -------------------------------------------------------------
local f5t = ns:taboption("forward", DynamicList, "forward_socks5t")
f5t.title = string.format(HELP, "SOCKS", "Forward SOCKS 5t" )
f5t.description = fs4.description
f5t.rmempty = true
-- tab: misc -- ################################################################
-- accept-intercepted-requests -------------------------------------------------
local air = ns:taboption("misc", Flag, "accept_intercepted_requests")
air.title = string.format(HELP, "ACCEPT-INTERCEPTED-REQUESTS", "Accept intercepted requests" )
air.description = translate("Whether intercepted requests should be treated as valid.")
air.orientation = "horizontal"
air.rmempty = true
function air.parse(self, section)
CTRL.flag_parse(self, section)
end
-- allow-cgi-request-crunching -------------------------------------------------
local crc = ns:taboption("misc", Flag, "allow_cgi_request_crunching")
crc.title = string.format(HELP, "ALLOW-CGI-REQUEST-CRUNCHING", "Allow CGI request crunching" )
crc.description = translate("Whether requests to Privoxy's CGI pages can be blocked or redirected.")
crc.orientation = "horizontal"
crc.rmempty = true
function crc.parse(self, section)
CTRL.flag_parse(self, section)
end
-- split-large-forms -----------------------------------------------------------
local slf = ns:taboption("misc", Flag, "split_large_forms")
slf.title = string.format(HELP, "SPLIT-LARGE-FORMS", "Split large forms" )
slf.description = translate("Whether the CGI interface should stay compatible with broken HTTP clients.")
slf.orientation = "horizontal"
slf.rmempty = true
function slf.parse(self, section)
CTRL.flag_parse(self, section)
end
-- keep-alive-timeout ----------------------------------------------------------
local kat = ns:taboption("misc", Value, "keep_alive_timeout")
kat.title_base = "Keep-alive timeout"
kat.title = string.format(HELP, "KEEP-ALIVE-TIMEOUT", kat.title_base)
kat.description = translate("Number of seconds after which an open connection will no longer be reused.")
kat.rmempty = true
function kat.validate(self, value)
local v = tonumber(value)
if not v then
return nil, err_tab_misc(self.title_base, translate("Value is not a number") )
elseif v < 1 then
return nil, err_tab_misc(self.title_base, translate("Value not greater 0 or empty") )
end
return value
end
-- tolerate-pipelining ---------------------------------------------------------
local tp = ns:taboption("misc", Flag, "tolerate_pipelining")
tp.title = string.format(HELP, "TOLERATE-PIPELINING", "Tolerate pipelining" )
tp.description = translate("Whether or not pipelined requests should be served.")
tp.orientation = "horizontal"
tp.rmempty = true
function tp.parse(self, section)
CTRL.flag_parse(self, section)
end
-- default-server-timeout ------------------------------------------------------
local dst = ns:taboption("misc", Value, "default_server_timeout")
dst.title_base = "Default server timeout"
dst.title = string.format(HELP, "DEFAULT-SERVER-TIMEOUT", dst.title_base)
dst.description = translate("Assumed server-side keep-alive timeout (in seconds) if not specified by the server.")
dst.rmempty = true
function dst.validate(self, value)
local v = tonumber(value)
if not v then
return nil, err_tab_misc(self.title_base, translate("Value is not a number") )
elseif v < 1 then
return nil, err_tab_misc(self.title_base, translate("Value not greater 0 or empty") )
end
return value
end
-- connection-sharing ----------------------------------------------------------
local cs = ns:taboption("misc", Flag, "connection_sharing")
cs.title = string.format(HELP, "CONNECTION-SHARING", "Connection sharing" )
cs.description = translate("Whether or not outgoing connections that have been kept alive should be shared between different incoming connections.")
cs.orientation = "horizontal"
cs.rmempty = true
function cs.parse(self, section)
CTRL.flag_parse(self, section)
end
-- socket-timeout --------------------------------------------------------------
local st = ns:taboption("misc", Value, "socket_timeout")
st.title_base = "Socket timeout"
st.title = string.format(HELP, "SOCKET-TIMEOUT", st.title_base )
st.description = translate("Number of seconds after which a socket times out if no data is received.")
st.default = 300
st.rmempty = true
function st.validate(self, value)
local v = tonumber(value)
if not v then
return nil, err_tab_misc(self.title_base, translate("Value is not a number") )
elseif v < 1 then
return nil, err_tab_misc(self.title_base, translate("Value not greater 0 or empty") )
elseif v == self.default then
return "" -- dont need to save default
end
return value
end
-- max-client-connections ------------------------------------------------------
local mcc = ns:taboption("misc", Value, "max_client_connections")
mcc.title_base = "Max. client connections"
mcc.title = string.format(HELP, "MAX-CLIENT-CONNECTIONS", mcc.title_base )
mcc.description = translate("Maximum number of client connections that will be served.")
mcc.default = 128
mcc.rmempty = true
function mcc.validate(self, value)
local v = tonumber(value)
if not v then
return nil, err_tab_misc(self.title_base, translate("Value is not a number") )
elseif v < 1 then
return nil, err_tab_misc(self.title_base, translate("Value not greater 0 or empty") )
elseif v == self.default then
return "" -- dont need to save default
end
return value
end
-- handle-as-empty-doc-returns-ok ----------------------------------------------
local her = ns:taboption("misc", Flag, "handle_as_empty_doc_returns_ok")
her.title = string.format(HELP, "HANDLE-AS-EMPTY-DOC-RETURNS-OK", "Handle as empty doc returns ok" )
her.description = translate("The status code Privoxy returns for pages blocked with +handle-as-empty-document.")
her.orientation = "horizontal"
her.rmempty = true
function her.parse(self, section)
CTRL.flag_parse(self, section)
end
-- enable-compression ----------------------------------------------------------
local ec = ns:taboption("misc", Flag, "enable_compression")
ec.title = string.format(HELP, "ENABLE-COMPRESSION", "Enable compression" )
ec.description = translate("Whether or not buffered content is compressed before delivery.")
ec.orientation = "horizontal"
ec.rmempty = true
function ec.parse(self, section)
CTRL.flag_parse(self, section)
end
-- compression-level -----------------------------------------------------------
local cl = ns:taboption("misc", Value, "compression_level")
cl.title_base = "Compression level"
cl.title = string.format(HELP, "COMPRESSION-LEVEL", cl.title_base )
cl.description = translate("The compression level that is passed to the zlib library when compressing buffered content.")
cl.default = 1
cl.rmempty = true
function cl.validate(self, value)
local v = tonumber(value)
if not v then
return nil, err_tab_misc(self.title_base, translate("Value is not a number") )
elseif v < 0 or v > 9 then
return nil, err_tab_misc(self.title_base, translate("Value not between 0 and 9") )
elseif v == self.default then
return "" -- don't need to save default
end
return value
end
-- client-header-order ---------------------------------------------------------
local cho = ns:taboption("misc", Value, "client_header_order")
cho.title = string.format(HELP, "CLIENT-HEADER-ORDER", "Client header order" )
cho.description = translate("The order in which client headers are sorted before forwarding them.")
.. [[<br />]]
.. translate("Syntax: Client header names delimited by spaces.")
cho.rmempty = true
-- "debug"-tab definition -- ###################################################
-- single-threaded -------------------------------------------------------------
local st = ns:taboption("debug", Flag, "single_threaded")
st.title = string.format(HELP, "SINGLE-THREADED", "Single Threaded" )
st.description = translate("Whether to run only one server thread.")
.. [[<br /><strong>]]
.. translate("This option is only there for debugging purposes. It will drastically reduce performance.")
.. [[</strong>]]
st.rmempty = true
function st.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 1 ---------------------------------------------------------------------
local d0 = ns:taboption("debug", Flag, "debug_1")
d0.title = string.format(HELP, "DEBUG", "Debug 1" )
d0.description = translate("Log the destination for each request Privoxy let through. See also 'Debug 1024'.")
d0.rmempty = true
function d0.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 2 ---------------------------------------------------------------------
local d1 = ns:taboption("debug", Flag, "debug_2")
d1.title = string.format(HELP, "DEBUG", "Debug 2" )
d1.description = translate("Show each connection status")
d1.rmempty = true
function d1.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 4 ---------------------------------------------------------------------
local d2 = ns:taboption("debug", Flag, "debug_4")
d2.title = string.format(HELP, "DEBUG", "Debug 4" )
d2.description = translate("Show I/O status")
d2.rmempty = true
function d2.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 8 ---------------------------------------------------------------------
local d3 = ns:taboption("debug", Flag, "debug_8")
d3.title = string.format(HELP, "DEBUG", "Debug 8" )
d3.description = translate("Show header parsing")
d3.rmempty = true
function d3.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 16 --------------------------------------------------------------------
local d4 = ns:taboption("debug", Flag, "debug_16")
d4.title = string.format(HELP, "DEBUG", "Debug 16" )
d4.description = translate("Log all data written to the network")
d4.rmempty = true
function d4.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 32 --------------------------------------------------------------------
local d5 = ns:taboption("debug", Flag, "debug_32")
d5.title = string.format(HELP, "DEBUG", "Debug 32" )
d5.description = translate("Debug force feature")
d5.rmempty = true
function d5.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 64 --------------------------------------------------------------------
local d6 = ns:taboption("debug", Flag, "debug_64")
d6.title = string.format(HELP, "DEBUG", "Debug 64" )
d6.description = translate("Debug regular expression filters")
d6.rmempty = true
function d6.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 128 -------------------------------------------------------------------
local d7 = ns:taboption("debug", Flag, "debug_128")
d7.title = string.format(HELP, "DEBUG", "Debug 128" )
d7.description = translate("Debug redirects")
d7.rmempty = true
function d7.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 256 -------------------------------------------------------------------
local d8 = ns:taboption("debug", Flag, "debug_256")
d8.title = string.format(HELP, "DEBUG", "Debug 256" )
d8.description = translate("Debug GIF de-animation")
d8.rmempty = true
function d8.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 512 -------------------------------------------------------------------
local d9 = ns:taboption("debug", Flag, "debug_512")
d9.title = string.format(HELP, "DEBUG", "Debug 512" )
d9.description = translate("Common Log Format")
d9.rmempty = true
function d9.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 1024 ------------------------------------------------------------------
local d10 = ns:taboption("debug", Flag, "debug_1024")
d10.title = string.format(HELP, "DEBUG", "Debug 1024" )
d10.description = translate("Log the destination for requests Privoxy didn't let through, and the reason why.")
d10.rmempty = true
function d10.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 2048 ------------------------------------------------------------------
local d11 = ns:taboption("debug", Flag, "debug_2048")
d11.title = string.format(HELP, "DEBUG", "Debug 2048" )
d11.description = translate("CGI user interface")
d11.rmempty = true
function d11.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 4096 ------------------------------------------------------------------
local d12 = ns:taboption("debug", Flag, "debug_4096")
d12.title = string.format(HELP, "DEBUG", "Debug 4096" )
d12.description = translate("Startup banner and warnings.")
d12.rmempty = true
function d12.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 8192 ------------------------------------------------------------------
local d13 = ns:taboption("debug", Flag, "debug_8192")
d13.title = string.format(HELP, "DEBUG", "Debug 8192" )
d13.description = translate("Non-fatal errors - *we highly recommended enabling this*")
d13.rmempty = true
function d13.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 16384 -----------------------------------------------------------------
--[[ TODO ???
local d14 = ns:taboption("debug", Flag, "debug_16384")
d14.title = string.format(HELP, "DEBUG", "Debug 16384" )
d14.description = translate("")
d14.rmempty = true
function d14.parse(self, section)
CTRL.flag_parse(self, section)
end
]]--
-- debug 32768 -----------------------------------------------------------------
local d15 = ns:taboption("debug", Flag, "debug_32768")
d15.title = string.format(HELP, "DEBUG", "Debug 32768" )
d15.description = translate("Log all data read from the network")
d15.rmempty = true
function d15.parse(self, section)
CTRL.flag_parse(self, section)
end
-- debug 65536 -----------------------------------------------------------------
local d16 = ns:taboption("debug", Flag, "debug_65536")
d16.title = string.format(HELP, "DEBUG", "Debug 65536" )
d16.description = translate("Log the applying actions")
d16.rmempty = true
function d16.parse(self, section)
CTRL.flag_parse(self, section)
end
-- tab: logview -- #############################################################
local lv = ns:taboption("logview", DummyValue, "_logview")
lv.template = "privoxy/detail_logview"
lv.inputtitle = translate("Read / Reread log file")
lv.rows = 50
function lv.cfgvalue(self, section)
local lfile=self.map:get(ns.section, "logdir") .. "/" .. self.map:get(ns.section, "logfile")
if NXFS.access(lfile) then
return lfile .. "\n" .. translate("Please press [Read] button")
end
return lfile .. "\n" .. translate("File not found or empty")
end
return m
|