21b693d9f2004fab338079cd4cfc4759ddfa5e0d
[project/luci.git] / applications / luci-p2pblock / luasrc / model / cbi / luci_fw / p2pblock.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 local sys = require "luci.sys"
16
17 m = Map("freifunk_p2pblock", translate("ff_p2pblock", "P2P-Block"),
18         translate("ff_p2pblock_desc", "P2P-Block is a greylisting mechanism to block various peer-to-peer protocols for non-whitelisted clients."))
19
20 s = m:section(NamedSection, "p2pblock", "settings", "Settings")
21 s.anonymous = true
22 s.addremove = false
23
24 en = s:option(Flag, "_enabled", translate("ff_p2pblock_enabled", "Enable P2P-Block"))
25 en.rmempty = false
26
27 function en.cfgvalue()
28         return ( sys.init.enabled("freifunk-p2pblock") and "1" or "0" )
29 end
30
31 function en.write(self, section, val)
32         if val == "1" then
33                 sys.init.enable("freifunk-p2pblock")
34         else
35                 sys.init.disable("freifunk-p2pblock")
36         end
37 end
38
39 s:option(Value, "portrange", translate("ff_p2pblock_portrange", "Portrange"))
40
41 s:option(Value, "blocktime", translate("ff_p2pblock_blocktime", "Block Time"),
42         translate("ff_p2pblock_blocktime_desc", "seconds"))
43
44 s:option(DynamicList, "whitelist", translate("ff_p2pblock_whitelist", "Whitelisted IPs"))
45
46 l7 = s:option(MultiValue, "layer7", translate("ff_p2pblock_layer7", "Layer7-Protokolle"))
47 l7.widget = "checkbox"
48 l7:value("aim", "AIM Chat")
49 l7:value("bittorrent", "Bittorrent")
50 l7:value("edonkey", "eDonkey, eMule, Kademlia")
51 l7:value("fasttrack", "Fasttrack Protocol")
52 l7:value("ftp", "File Transfer Protocol")
53 l7:value("gnutella", "Gnutella")
54 l7:value("http", "Hypertext Transfer Protocol")
55 l7:value("ident", "Ident Protocol")
56 l7:value("irc", "Internet Relay Chat")
57 l7:value("jabber", "Jabber/XMPP")
58 l7:value("msnmessenger", "MSN Messenger")
59 l7:value("ntp", "Network Time Protocol")
60 l7:value("pop3", "POP3 Protocol")
61 l7:value("smtp", "SMTP Protocol")
62 l7:value("ssl", "SSL Protocol")
63 l7:value("vnc", "VNC Protocol")
64
65 ipp2p = s:option(MultiValue, "ipp2p", translate("ff_p2pblock_ipp2p", "IP-P2P"))
66 ipp2p.widget = "checkbox"
67 ipp2p:value("edk", "eDonkey, eMule, Kademlia")
68 ipp2p:value("kazaa", "KaZaA, FastTrack")
69 ipp2p:value("gnu", "Gnutella")
70 ipp2p:value("dc", "Direct Connect")
71 ipp2p:value("bit", "BitTorrent, extended BT")
72 ipp2p:value("apple", "AppleJuice")
73 ipp2p:value("winmx", "WinMX")
74 ipp2p:value("soul", "SoulSeek")
75 ipp2p:value("ares", "AresLite")
76
77 return m