Selaa lähdekoodia

coova-chilli: add uci configuration file, init.d and firewall script

Imre Kaloz 9 vuotta sitten
vanhempi
commit
45e0e2a0b9

+ 8
- 2
net/coova-chilli/Makefile Näytä tiedosto

@@ -12,7 +12,7 @@ PKG_VERSION:=1.3.0+20141128
12 12
 PKG_MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
13 13
 PKG_LICENSE:=GPL-2.0+
14 14
 PKG_LICENSE_FILES:=COPYING
15
-PKG_RELEASE:=1
15
+PKG_RELEASE:=2
16 16
 
17 17
 PKG_SOURCE_PROTO:=git
18 18
 PKG_SOURCE_URL:=git://github.com/coova/coova-chilli
@@ -120,7 +120,7 @@ define Build/Configure
120 120
 endef
121 121
 
122 122
 define Package/coova-chilli/conffiles
123
-/etc/chilli.conf
123
+/etc/config/chilli
124 124
 endef
125 125
 
126 126
 define Package/coova-chilli/install
@@ -136,6 +136,12 @@ define Package/coova-chilli/install
136 136
 	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
137 137
 	$(INSTALL_DIR) $(1)/usr/lib/iptables
138 138
 	$(CP) $(PKG_INSTALL_DIR)/usr/iptables/lib*.so $(1)/usr/lib/iptables
139
+	$(INSTALL_DIR) $(1)/etc/init.d
140
+	$(INSTALL_BIN) files/chilli.init $(1)/etc/init.d/chilli
141
+	$(INSTALL_DIR) $(1)/etc/config
142
+	$(INSTALL_DATA) files/chilli.config $(1)/etc/config/chilli
143
+	$(INSTALL_DIR) $(1)/lib/firewall
144
+	$(CP) files/chilli.firewall $(1)/lib/firewall/chilli.sh
139 145
 endef
140 146
 
141 147
 $(eval $(call BuildPackage,coova-chilli))

+ 230
- 0
net/coova-chilli/files/chilli.config Näytä tiedosto

@@ -0,0 +1,230 @@
1
+#
2
+# Sample Coova-Chilli configuration file
3
+#
4
+
5
+config chilli
6
+    # disable to running chilli. remove this option before running.
7
+    option disabled 1
8
+
9
+    # name of TUN device name. required.
10
+    option tundev 'tun0'
11
+
12
+    # Include this flag if process is to run in the foreground
13
+    #option fg
14
+
15
+    # Include this flag to include debug information.
16
+    #option debug 9
17
+
18
+    # Re-read configuration file at this interval. Will also cause new domain
19
+    # name lookups to be performed. Value is given in seconds.
20
+    #option interval 3600
21
+
22
+    # File to store information about the process id of the program.
23
+    # The program must have write access to this file/directory.
24
+    #option pidfile /var/run/chilli.pid
25
+
26
+    # Directory to use for nonvolatile storage.
27
+    # The program must have write access to this directory.
28
+    # this option is currently ignored
29
+    #option statedir ./
30
+
31
+
32
+    # TUN parameters
33
+
34
+    # IP network address of external packet data network
35
+    # Used to allocate dynamic IP addresses and set up routing.
36
+    # Normally you do not need to uncomment this option.
37
+    #option net 192.168.182.0/24
38
+
39
+    # Dynamic IP address pool
40
+    # Used to allocate dynamic IP addresses to clients.
41
+    # If not set it defaults to the net tag.
42
+    # Do not uncomment this option unless you are an experienced user!
43
+    #option dynip 192.168.182.0/24
44
+
45
+    # Static IP address pool
46
+    # Used to allocate static IP addresses to clients.
47
+    # Do not uncomment this option unless you are an experienced user!
48
+    #option statip 192.168.182.0/24
49
+
50
+
51
+    # Primary DNS server.
52
+    # Will be suggested to the client.
53
+    # If omitted the system default will be used.
54
+    # Normally you do not need to uncomment this option.
55
+    #option dns1 172.16.0.5
56
+
57
+    # Secondary DNS server.
58
+    # Will be suggested to the client.
59
+    # If omitted the system default will be used.
60
+    # Normally you do not need to uncomment this option.
61
+    #option dns2 172.16.0.6
62
+
63
+    # Domain name
64
+    # Will be suggested to the client.
65
+    # Normally you do not need to uncomment this option.
66
+    #option domain key.chillispot.org
67
+
68
+    # Script executed after network interface has been brought up.
69
+    # Executed with the following parameters: <devicename> <ip address>
70
+    # <mask>
71
+    # Normally you do not need to uncomment this option.
72
+    #option ipup /etc/chilli.ipup
73
+
74
+    # Script executed after network interface has been taken down.
75
+    # Executed with the following parameters: <devicename> <ip address>
76
+    # <mask>
77
+    # Normally you do not need to uncomment this option.
78
+    #option ipdown /etc/chilli.ipdown
79
+
80
+
81
+    # Radius parameters
82
+
83
+    # IP address to listen to
84
+    # Normally you do not need to uncomment this option.
85
+    #option radiuslisten 127.0.0.1
86
+
87
+    # IP address of radius server 1
88
+    # For most installations you need to modify this option.
89
+    radiusserver1 rad01.chillispot.org
90
+
91
+    # IP address of radius server 2
92
+    # If you have only one radius server you should set radiusserver2 to the
93
+    # same value as radiusserver1.
94
+    # For most installations you need to modify this option.
95
+    radiusserver2 rad02.chillispot.org
96
+
97
+    # Radius authentication port
98
+    # The UDP port number to use for radius authentication requests.
99
+    # The same port number is used for both radiusserver1 and radiusserver2.
100
+    # Normally you do not need to uncomment this option.
101
+    #option radiusauthport 1812
102
+
103
+    # Radius accounting port
104
+    # The UDP port number to use for radius accounting requests.
105
+    # The same port number is used for both radiusserver1 and radiusserver2.
106
+    # Normally you do not need to uncomment this option.
107
+    #option radiusacctport 1813
108
+
109
+    # Radius shared secret for both servers
110
+    # For all installations you should modify this option.
111
+    #option radiussecret testing123
112
+
113
+    # Radius NAS-Identifier
114
+    # Normally you do not need to uncomment this option.
115
+    #option radiusnasid nas01
116
+
117
+    # WISPr Location ID. Should be in the format: isocc=<ISO_Country_Code>,
118
+    # cc=<E.164_Country_Code>,ac=<E.164_Area_Code>,network=<ssid/ZONE>
119
+    # Normally you do not need to uncomment this option.
120
+    #option radiuslocationid isocc=us,cc=1,ac=408,network=ACMEWISP_NewarkAirport
121
+
122
+    # WISPr Location Name. Should be in the format:
123
+    # <HOTSPOT_OPERATOR_NAME>,<LOCATION>
124
+    # Normally you do not need to uncomment this option.
125
+    #option radiuslocationname ACMEWISP,Gate_14_Terminal_C_of_Newark_Airport
126
+
127
+
128
+    # Radius proxy parameters
129
+
130
+    # IP address to listen to
131
+    # Normally you do not need to uncomment this option.
132
+    #option proxylisten 10.0.0.1
133
+
134
+    # UDP port to listen to.
135
+    # If not specified a port will be selected by the system
136
+    # Normally you do not need to uncomment this option.
137
+    #option proxyport 1645
138
+
139
+    # Client(s) from which we accept radius requests
140
+    # Normally you do not need to uncomment this option.
141
+    #option proxyclient 10.0.0.1/24
142
+
143
+    # Radius proxy shared secret for all clients
144
+    # If not specified defaults to radiussecret
145
+    # Normally you do not need to uncomment this option.
146
+    #option proxysecret testing123
147
+
148
+
149
+    # DHCP Parameters
150
+
151
+    # Ethernet interface to listen to.
152
+    # This is the network interface which is connected to the access points.
153
+    # In a typical configuration this option should be set to eth1.
154
+    dhcpif eth1
155
+
156
+    # Use specified MAC address.
157
+    # An address in the range  00:00:5E:00:02:00 - 00:00:5E:FF:FF:FF falls
158
+    # within the IANA range of addresses and is not allocated for other
159
+    # purposes.
160
+    # Normally you do not need to uncomment this option.
161
+    #option dhcpmac 00:00:5E:00:02:00
162
+
163
+    # Time before DHCP lease expires
164
+    # Normally you do not need to uncomment this option.
165
+    #option lease 600
166
+
167
+
168
+    # Universal access method (UAM) parameters
169
+
170
+    # URL of web server handling authentication.
171
+    uamserver https://radius.chillispot.org/hotspotlogin
172
+
173
+    # URL of welcome homepage.
174
+    # Unauthenticated users will be redirected to this URL. If not specified
175
+    # users will be redirected to the uamserver instead.
176
+    # Normally you do not need to uncomment this option.
177
+    #option uamhomepage http://192.168.182.1/welcome.html
178
+
179
+    # Shared between chilli and authentication web server
180
+    #option uamsecret ht2eb8ej6s4et3rg1ulp
181
+
182
+    # IP address to listen to for authentication requests
183
+    # Do not uncomment this option unless you are an experienced user!
184
+    #option uamlisten 192.168.182.1
185
+
186
+    # TCP port to listen to for authentication requests
187
+    # Do not uncomment this option unless you are an experienced user!
188
+    #option uamport 3990
189
+
190
+    # Comma separated list of domain names, IP addresses or network segments
191
+    # the client can access without first authenticating.
192
+    # It is possible to specify this option multiple times.
193
+    # Normally you do not need to uncomment this option.
194
+    #option uamallowed www.chillispot.org,10.11.12.0/24
195
+
196
+    # Comma separated list of domain names
197
+    # the client can access without first authenticating.
198
+    # It is possible to specify this option multiple times.
199
+    # Normally you do not need to uncomment this option.
200
+    #option uamdomain .chillispot.org,.coova.org
201
+
202
+    # If this flag is given unauthenticated users are allowed to use
203
+    # any DNS server.
204
+    # Normally you do not need to uncomment this option.
205
+    #option uamanydns
206
+
207
+
208
+    # MAC authentication
209
+
210
+    # If this flag is given users will be authenticated only on their MAC
211
+    # address.
212
+    # Normally you do not need to uncomment this option.
213
+    #option macauth
214
+
215
+    # List of MAC addresses.
216
+    # The MAC addresses specified in this list will be authenticated only on
217
+    # their MAC address.
218
+    # this option is ignored if the macauth tag is given.
219
+    # It is possible to specify this option multiple times.
220
+    # Normally you do not need to uncomment this option.
221
+    #option macallowed 00-0A-5E-AC-BE-51,00-30-1B-3C-32-E9
222
+
223
+    # Password to use for MAC authentication.
224
+    # Normally you do not need to uncomment this option.
225
+    #option macpasswd password
226
+
227
+    # Suffix to add to MAC address in order to form the username.
228
+    # Normally you do not need to uncomment this option.
229
+    #option macsuffix suffix
230
+

+ 41
- 0
net/coova-chilli/files/chilli.firewall Näytä tiedosto

@@ -0,0 +1,41 @@
1
+#!/bin/sh
2
+
3
+chilli_firewall() {
4
+    local cfg="$1"
5
+
6
+    local network ifname tun
7
+
8
+    config_get network "$cfg" network
9
+
10
+    . /lib/functions/network.sh
11
+    network_get_device ifname ${network:-lan}
12
+
13
+    if [ "$ifname" = "" ]
14
+    then
15
+       config_get ifname "$cfg" dhcpif
16
+    fi
17
+
18
+    config_get tun "$cfg" tundev
19
+
20
+    for n in ACCEPT DROP REJECT
21
+    do
22
+       iptables -F zone_${network}_${n}
23
+       iptables -I zone_${network}_${n} -i $tun -j $n
24
+       iptables -I zone_${network}_${n} -o $tun -j $n
25
+    done
26
+
27
+    iptables -D forward -i ${ifname} -j zone_${network}_forward
28
+    iptables -A forward -i ${ifname} -j DROP
29
+    iptables -A forward -i $tun -j zone_${network}_forward
30
+
31
+    iptables -D input -i ${ifname} -j zone_${network}
32
+    iptables -A input -i $tun -j zone_${network}
33
+
34
+    iptables -I zone_${network} -p tcp --dport 3990 -j ACCEPT
35
+    iptables -I zone_${network} -p tcp --dport 3991 -j ACCEPT
36
+}
37
+
38
+chilli_post_core_cb() {
39
+    config_load chilli
40
+    config_foreach chilli_firewall chilli
41
+}

+ 61
- 0
net/coova-chilli/files/chilli.init Näytä tiedosto

@@ -0,0 +1,61 @@
1
+#!/bin/sh /etc/rc.common
2
+
3
+START=30
4
+STOP=90
5
+
6
+config_cb() {
7
+    chilli_inst=$2
8
+    if [ "$chilli_inst" != "" ]
9
+    then
10
+       rm -f /var/run/chilli_${chilli_inst}*
11
+       chilli_conf=/var/run/chilli_${chilli_inst}.conf
12
+       eval "start_chilli_$chilli_inst=1"
13
+    fi
14
+}
15
+
16
+option_cb() {
17
+    case "$1" in
18
+        # UCI settings
19
+       network)
20
+           . /lib/functions/network.sh
21
+           local ifname
22
+           network_get_device ifname $2
23
+           echo "dhcpif=\"$ifname\"" >> $chilli_conf
24
+           ;;
25
+       disabled)
26
+           eval "start_chilli_$chilli_inst=0"
27
+           ;;
28
+        # boolean settings
29
+       dhcpbroadcast|nodynip|vlanlocation|locationstopstart|locationcopycalled|locationimmediateupdate|locationopt82|coanoipcheck|noradallow|proxymacaccept|proxyonacct|dhcpmacset|dhcpradius|noc2c|eapolenable|uamanydns|uamanyip|uamnatanyip|nouamsuccess|nowispr1|nowispr2|domaindnslocal|radsec|macauth|macreauth|macauthdeny|macallowlocal|strictmacauth|strictdhcp|ieee8021q|only8021q|radiusoriginalurl|swapoctets|statusfilesave|wpaguests|openidauth|papalwaysok|mschapv2|chillixml|acctupdate|dnsparanoia|seskeepalive|usetap|noarpentries|framedservice|scalewin|redir|injectwispr|redirurl|routeonetone|nousergardendata|uamgardendata|uamotherdata|withunixipc|uamallowpost|redirssl|uamuissl|layer3|patricia|redirdnsreq|dhcpnotidle|ipv6|ipv6only)
30
+           [ "$2" = "true" -o "$2" = "1" ] && echo "$1" >> $chilli_conf
31
+           ;;
32
+       *)
33
+           echo "$1=\"$2\"" >> $chilli_conf
34
+           ;;
35
+    esac
36
+}
37
+
38
+start_chilli() {
39
+    local cfg="$1"
40
+    local start_chilli=$(eval "echo \$start_chilli_$cfg")
41
+    [ "$start_chilli" = "0" ] && return
42
+    local base=/var/run/chilli_${cfg}
43
+    chilli -c ${base}.conf \
44
+       --pidfile ${base}.pid \
45
+       --cmdsocket ${base}.sock \
46
+       --unixipc ${base}.ipc &
47
+}
48
+
49
+start() {
50
+    config_load chilli
51
+    config_foreach start_chilli chilli
52
+}
53
+
54
+stop() {
55
+    ls /var/run/chilli*.pid 2>/dev/null && {
56
+       kill $(cat /var/run/chilli*.pid)
57
+       sleep 1
58
+       killall -9 chilli
59
+       rm -f /var/run/chilli*
60
+    }
61
+}