2
0

coovachilli.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. 'use strict';
  2. 'require form';
  3. 'require network';
  4. 'require rpc';
  5. 'require tools.widgets as widgets';
  6. return L.view.extend({
  7. callNetworkDevices: rpc.declare({
  8. object: 'luci-rpc',
  9. method: 'getNetworkDevices',
  10. expect: { '': {} }
  11. }),
  12. addLocalDeviceIPs: function(o, devices) {
  13. L.sortedKeys(devices, 'name').forEach(function(dev) {
  14. var ip4addrs = devices[dev].ipaddrs;
  15. var ip6addrs = devices[dev].ip6addrs;
  16. // if (!L.isObject(devices[dev].flags) || devices[dev].flags.loopback)
  17. // return;
  18. if (Array.isArray(ip4addrs)) {
  19. ip4addrs.forEach(function(addr) {
  20. if (!L.isObject(addr) || !addr.address)
  21. return;
  22. o.value(addr.address, E([], [
  23. addr.address, ' (', E('strong', {}, [dev]), ')'
  24. ]));
  25. });
  26. }
  27. if (Array.isArray(ip6addrs)) {
  28. ip6addrs.forEach(function(addr) {
  29. if (!L.isObject(addr) || !addr.address)
  30. return;
  31. o.value(addr.address, E([], [
  32. addr.address, ' (', E('strong', {}, [dev]), ')'
  33. ]));
  34. });
  35. }
  36. });
  37. return o;
  38. },
  39. load: function() {
  40. return Promise.all([
  41. this.callNetworkDevices(),
  42. ]);
  43. },
  44. render: function(returned_promises) {
  45. var m, s, o, to, so, ss;
  46. var net_devices = returned_promises[0];
  47. m = new form.Map('coovachilli', _('Coova Chilli'),
  48. _('Coova Chilli') + ' ' + _('access controller for WLAN.'));
  49. s = m.section(form.TypedSection, 'chilli', _('Settings'));
  50. s.anonymous = true;
  51. s.tab('general', _('General'));
  52. s.tab('uam', _('UAM and MAC Authentication'));
  53. s.tab('network', _('Network Configuration'));
  54. s.tab('radius', _('RADIUS'));
  55. // General
  56. o = s.taboption('general', form.SectionValue, '__gen__', form.TypedSection, 'chilli', null);
  57. ss = o.subsection;
  58. ss.anonymous = true;
  59. so = ss.option(form.Flag, 'disabled', _('Enabled') );
  60. so.enabled = '0';
  61. so.disabled = '1';
  62. // analogue of dhcpif in init script:
  63. // so = ss.option(form.Value, 'network', _('Network') );
  64. // so.optional = true;
  65. ss.option(form.Flag, 'debug', _('Debug') );
  66. so = ss.option(form.Value, 'interval', _('Re-read interval'), _('Re-read configuration file at this interval') );
  67. so.placeholder = '3600';
  68. so = ss.option(form.Value, 'logfacility', _('Syslog facility') );
  69. so.value('KERN');
  70. so.value('USER');
  71. so.value('MAIL');
  72. so.value('DAEMON');
  73. so.value('AUTH');
  74. so.value('LPR');
  75. so.value('NEWS');
  76. so.value('UUCP');
  77. so.value('CRON');
  78. so.value('LOCAL0');
  79. so.value('LOCAL1');
  80. so.value('LOCAL2');
  81. so.value('LOCAL3');
  82. so.value('LOCAL4');
  83. so.value('LOCAL5');
  84. so.value('LOCAL6');
  85. so.value('LOCAL7');
  86. so = ss.option(form.Value, 'statedir', _('State directory') );
  87. so.optional = true;
  88. so.placeholder = './';
  89. // UAM
  90. o = s.taboption('uam', form.SectionValue, '__uam__', form.TypedSection, 'chilli', null,
  91. _('Universal access method'));
  92. ss = o.subsection;
  93. ss.anonymous = true;
  94. so = ss.option(form.Value, 'uamserver', _('Server'), _('URL of web server to use for authenticating clients') );
  95. so.placeholder = 'https://radius.coova.org/hotspotlogin';
  96. so = ss.option(form.Value, 'uamsecret', _('Secret') );
  97. so.password = true;
  98. ss.option(form.Flag, 'uamanydns', _('Any DNS'), _('Allow unauthenticated users access to any DNS') );
  99. ss.option(form.Flag, 'nouamsuccess', _('Ignore Success'), _('Do not return to UAM server on login success, just redirect to original URL') );
  100. ss.option(form.Flag, 'nouamwispr', _('No WISPr'), _('Do not do any WISPr XML, assume the back-end is doing this instead') );
  101. ss.option(form.Flag, 'nowispr1', _('No WISPr 1 XML'), _('Do not offer WISPr 1.0 XML') );
  102. ss.option(form.Flag, 'nowispr2', _('No WISPr 2 XML'), _('Do not offer WISPr 2.0 XML') );
  103. ss.option(form.Flag, 'chillixml', _('Chilli XML'), _('Return the so-called Chilli XML along with WISPr XML.') );
  104. so = ss.option(form.Flag, 'uamanyip', _('Any IP'), _('Allow client to use any IP Address') );
  105. so.optional = true;
  106. so = ss.option(form.Flag, 'dnsparanoia', _('Strict DNS'), _('Inspect DNS packets and drop responses with any non- A, CNAME, SOA, or MX records') );
  107. so.optional = true;
  108. so = ss.option(form.Flag, 'usestatusfile', _('Use status file') );
  109. so.optional = true;
  110. so = ss.option(form.Value, 'uamhomepage', _('Homepage'), _('URL of homepage to redirect unauthenticated users to') );
  111. so.optional = true;
  112. so.placeholder = 'http://192.168.182.1/welcome.html';
  113. so = ss.option(form.Value, 'uamlisten', _('Listen') );
  114. so.optional = true;
  115. so.placeholder = '192.168.182.1';
  116. so = ss.option(form.Value, 'uamport', _('Port'), _('TCP port to bind to for authenticating clients') );
  117. so.optional = true;
  118. so.placeholder = '3990';
  119. so = ss.option(form.Value, 'uamiport', _('iport'), _('TCP port to bind to for only serving embedded content') );
  120. so.optional = true;
  121. so.placeholder = '3990';
  122. so = ss.option(form.DynamicList, 'uamdomain', _('Domain suffixes') );
  123. so.optional = true;
  124. so.placeholder = '.chillispot.org,.coova.org';
  125. so = ss.option(form.Value, 'uamlogoutip', _('Logout IP') );
  126. so.optional = true;
  127. so.placeholder = '192.168.0.1';
  128. so.datatype = 'ipaddr';
  129. so = ss.option(form.DynamicList, 'uamallowed', _('Allowed') );
  130. so.placeholder = 'www.coova.org,10.11.12.0/24,coova.org:80,icmp:coova.org';
  131. so.optional = true;
  132. so = ss.option(form.Value, 'wisprlogin', _('WISPr Login'), _('A specific URL to be given in WISPr XML LoginURL') );
  133. so.optional = true;
  134. so = ss.option(form.Value, 'defsessiontimeout', _('Default session timeout'), _('0 means unlimited') );
  135. so.optional = true;
  136. so.placeholder = '0';
  137. so.datatype = 'uinteger';
  138. so = ss.option(form.Value, 'defidletimeout', _('Default idle timeout'), _('0 means unlimited') );
  139. so.optional = true;
  140. so.placeholder = '0';
  141. so.datatype = 'uinteger';
  142. so = ss.option(form.Value, 'definteriminterval', _('Default interim interval'), _('0 means unlimited') );
  143. so.optional = true;
  144. so.placeholder = '0';
  145. so.datatype = 'uinteger';
  146. so = ss.option(form.Value, 'defbandwidthmaxdown', _('Max download bandwidth'), _('Default bandwidth max down set in bps, same as WISPr-Bandwidth-Max-Down.') );
  147. so.optional = true;
  148. so.placeholder = '1000000000';
  149. so.datatype = 'uinteger';
  150. so = ss.option(form.Value, 'defbandwidthmaxup', _('Max upload bandwidth'), _('Default bandwidth max up set in bps, same as WISPr-Bandwidth-Max-Up.') );
  151. so.optional = true;
  152. so.placeholder = '1000000000';
  153. so.datatype = 'uinteger';
  154. so = ss.option(form.Value, 'ssid', _('SSID'), _('passed on to the UAM server in the initial redirect URL') );
  155. so.optional = true;
  156. so = ss.option(form.Value, 'vlan', _('VLAN'), _('passed on to the UAM server in the initial redirect URL') );
  157. so.optional = true;
  158. so = ss.option(form.Value, 'nasip', _('NAS IP'), _('Unique IP address of the NAS (nas-ip-address)') );
  159. so.optional = true;
  160. so.datatype = 'ipaddr';
  161. so = ss.option(form.Value, 'nasmac', _('NAS MAC'), _('Unique MAC address of the NAS (called-station-id)') );
  162. so.optional = true;
  163. so.datatype = 'macaddr';
  164. so = ss.option(form.Value, 'wwwdir', _('www directory'), _('Directory where embedded local web content is placed') );
  165. so.optional = true;
  166. so = ss.option(form.Value, 'wwwbin', _('www binary'), _('Executable to run as a CGI type program') );
  167. so.optional = true;
  168. so = ss.option(form.Value, 'uamui', _('UI'), _('Program in inetd style to handle all uam requests') );
  169. so.optional = true;
  170. so = ss.option(form.Value, 'localusers', _('Local users') );
  171. so.optional = true;
  172. so = ss.option(form.Value, 'postauthproxy', _('Post authentication proxy') );
  173. so.optional = true;
  174. so.datatype = 'ipaddr';
  175. so = ss.option(form.Value, 'postauthproxyport', _('Post authentication proxy') + ' ' + _('port') );
  176. so.optional = true;
  177. so.datatype = 'port';
  178. so = ss.option(form.Value, 'locationname', _('Location Name') );
  179. so.optional = true;
  180. /// MAC auth
  181. o = s.taboption('uam', form.SectionValue, '__macauth__', form.TypedSection, 'chilli', null,
  182. _('Special options for MAC authentication'));
  183. ss = o.subsection;
  184. ss.anonymous = true;
  185. so = ss.option(form.Flag, 'macauth', _('MAC authentication'), _('ChilliSpot will try to authenticate all users based on their mac address alone') );
  186. so = ss.option(form.Flag, 'strictmacauth', _('Strict MAC authentication'), _('Be strict about MAC Auth (no DHCP reply until we get RADIUS reply)') );
  187. so = ss.option(form.Flag, 'macauthdeny', _('Deny MAC authentication'), _('Deny access (even UAM) to MAC addresses given Access-Reject') );
  188. so = ss.option(form.Flag, 'macreauth', _('MAC re-authentication'), _('Re-Authenticate based on MAC address for every initial URL redirection') );
  189. so = ss.option(form.Flag, 'macallowlocal', _('Allow Local MAC') );
  190. so = ss.option(form.DynamicList, 'macallowed', _('Allowed MACs') );
  191. so.placeholder = 'AB-CD-EF-AB-CD-EF';
  192. // TODO: split and join
  193. so = ss.option(form.Value, 'macpasswd', _('MAC password'), _('Password used when performing MAC authentication') );
  194. so.optional = true;
  195. so.password = true;
  196. so = ss.option(form.Value, 'macsuffix', _('MAC suffix') );
  197. so.optional = true;
  198. so.placeholder = 'AB-CD-EF';
  199. // Network
  200. /// TUN
  201. o = s.taboption('network', form.SectionValue, '__tun__', form.TypedSection, 'chilli', null,
  202. _('Options for TUN'));
  203. ss = o.subsection;
  204. ss.anonymous = true;
  205. // Linux only:
  206. // so = ss.option(form.Flag, 'usetap', _('Use TAP') );
  207. so = ss.option(form.Flag, 'ipv6', _('Use IPv6') );
  208. so = ss.option(form.Flag, 'ipv6only', _('Use IPv6') + ' ' + _('only') );
  209. so = ss.option(form.Value, 'ipv6mode', _('IPv6 mode') );
  210. so.value('6and4');
  211. so.value('6to4');
  212. so.value('4to6');
  213. so = ss.option(widgets.DeviceSelect, 'tundev', _('TUN device') );
  214. so.optional = true;
  215. so = ss.option(form.Value, 'tcpwin', _('TCP Window') );
  216. so.optional = true;
  217. so.placeholder = '0';
  218. so.datatype = 'max(9200)';
  219. so = ss.option(form.Value, 'tcpmss', _('TCP MSS') );
  220. so.optional = true;
  221. so.placeholder = '1280';
  222. so.datatype = 'max(9200)';
  223. so = ss.option(form.Value, 'maxclients', _('Max clients') );
  224. so.optional = true;
  225. so.placeholder = '512';
  226. so.datatype = 'uinteger';
  227. so = ss.option(form.Value, 'txqlen', _('TX Q length') );
  228. so.optional = true;
  229. so = ss.option(form.Value, 'net', _('Net'), _('Network address of the uplink interface') );
  230. so.placeholder = '192.168.182.0/24';
  231. so.datatype = 'cidr';
  232. so = ss.option(form.Value, 'dynip', _('Dynamic IP'), _('Specifies a pool of dynamic IP addresses. If this option is omitted the network address specified by the Net option is used') );
  233. so.optional = true;
  234. so.placeholder = '192.168.182.0/24';
  235. so.datatype = 'cidr';
  236. so = ss.option(form.Value, 'statip', _('Static IP'), _('Specifies a pool of static IP addresses. With static address allocation the IP address of the client can be specified by the RADIUS server.') );
  237. so.optional = true;
  238. so.placeholder = '192.168.182.0/24';
  239. so = ss.option(form.Value, 'dns1', _('DNS Primary') );
  240. so.optional = true;
  241. so.placeholder = '172.16.0.5';
  242. so.datatype = 'ipaddr';
  243. so = ss.option(form.Value, 'dns2', _('DNS Auxiliary') );
  244. so.optional = true;
  245. so.placeholder = '172.16.0.6';
  246. so.datatype = 'ipaddr';
  247. so = ss.option(form.Value, 'domain', _('Domain') );
  248. so.optional = true;
  249. so.placeholder = 'key.chillispot.org';
  250. so.datatype = 'hostname';
  251. so = ss.option(form.Value, 'ipup', _('IP up script'), _('Executed after the TUN/TAP network interface has been brought up') );
  252. so.optional = true;
  253. so.placeholder = '/etc/chilli/up.sh';
  254. so = ss.option(form.Value, 'ipdown', _('IP down script'), _('Executed after the TUN/TAP network interface has been taken down') );
  255. so.optional = true;
  256. so.placeholder = '/etc/chilli/down.sh';
  257. so = ss.option(form.Value, 'conup', _('Connection up script'), _('Executed after a session is authorized') );
  258. so.optional = true;
  259. so.placeholder = '/etc/chilli/connup.sh';
  260. so = ss.option(form.Value, 'condown', _('Connection down script'), _('Executed after a session has moved from authorized state to unauthorized') );
  261. so.optional = true;
  262. so.placeholder = '/etc/chilli/conndown.sh';
  263. /// DHCP
  264. o = s.taboption('network', form.SectionValue, '__tun__', form.TypedSection, 'chilli', null,
  265. _('Special options for DHCP'));
  266. ss = o.subsection;
  267. ss.anonymous = true;
  268. so = ss.option(widgets.DeviceSelect, 'dhcpif', _('DHCP interface') );
  269. // so = ss.option(form.Value, 'dhcpmac', _('DHCP MAC') );
  270. // so.optional = true;
  271. // so.placeholder = '00:00:5E:00:02:00';
  272. // so.datatype = 'macaddr';
  273. so = ss.option(form.Value, 'lease', _('Lease time'), _('in seconds') );
  274. so.optional = true;
  275. so.placeholder = '600';
  276. so.datatype = 'uinteger';
  277. so = ss.option(form.Value, 'dhcpstart', _('DHCP Start') );
  278. so.optional = true;
  279. so.placeholder = '10';
  280. so.datatype = 'uinteger';
  281. so = ss.option(form.Value, 'dhcpend', _('DHCP End') );
  282. so.optional = true;
  283. so.placeholder = '254';
  284. so.datatype = 'uinteger';
  285. so = ss.option(form.Value, 'dhcpgatewayip', _('DHCP Gateway IP') );
  286. so.optional = true;
  287. so.placeholder = '192.168.1.1';
  288. so.datatype = 'ipaddr';
  289. so = ss.option(form.Value, 'dhcpgatewayport', _('DHCP Gateway Port') );
  290. so.optional = true;
  291. so.placeholder = '67';
  292. so.datatype = 'port';
  293. so = ss.option(form.Flag, 'eapolenable', _('Enable EAPOL'), _('IEEE 802.1x authentication') );
  294. so = ss.option(form.Flag, 'dhcpbroadcast', _('Broadcast Answer'), _('Always respond to DHCP to the broadcast IP, when no relay.') );
  295. so = ss.option(form.Flag, 'ieee8021q', _('802.1Q'), _('Support for 802.1Q/VLAN network') );
  296. so = ss.option(form.Flag, 'only8021q', _('802.1Q only'), _('Support 802.1Q VLAN tagged traffic only') );
  297. // RADIUS
  298. o = s.taboption('radius', form.SectionValue, '__rad__', form.TypedSection, 'chilli', null,
  299. _('RADIUS configuration'));
  300. ss = o.subsection;
  301. ss.anonymous = true;
  302. so = ss.option(form.Value, 'radiuslisten', _('Send IP') );
  303. so.optional = true;
  304. so.placeholder = '127.0.0.1';
  305. this.addLocalDeviceIPs(so, net_devices);
  306. so = ss.option(form.Value, 'radiusserver1', _('Primary server') );
  307. so.placeholder = 'rad01.coova.org';
  308. so.datatype = 'hostname';
  309. so = ss.option(form.Value, 'radiusserver2', _('Auxiliary server') );
  310. so.placeholder = 'rad02.coova.org';
  311. so.datatype = 'hostname';
  312. so = ss.option(form.Value, 'radiussecret', _('Secret') );
  313. so.password = true;
  314. so = ss.option(form.Value, 'radiusauthport', _('Authentication port') );
  315. so.optional = true;
  316. so.placeholder = '1812';
  317. so.datatype = 'port';
  318. so = ss.option(form.Value, 'radiusacctport', _('Accounting port') );
  319. so.optional = true;
  320. so.placeholder = '1813';
  321. so.datatype = 'port';
  322. so = ss.option(form.Value, 'radiustimeout', _('Timeout') );
  323. so.optional = true;
  324. so.placeholder = '10';
  325. so.datatype = 'uinteger';
  326. so = ss.option(form.Value, 'radiusretry', _('Retries') );
  327. so.optional = true;
  328. so.placeholder = '4';
  329. so.datatype = 'uinteger';
  330. so = ss.option(form.Value, 'radiusretrysec', _('Retry seconds') );
  331. so.optional = true;
  332. so.placeholder = '2';
  333. so.datatype = 'uinteger';
  334. so = ss.option(form.Value, 'radiusnasid', _('NAS ID'), _('NAS-Identifier') );
  335. so.optional = true;
  336. so.placeholder = 'nas01';
  337. so.datatype = 'string';
  338. so = ss.option(form.Value, 'radiuslocationid', _('WISPr Location ID') );
  339. so.optional = true;
  340. so.placeholder = 'isocc=us,cc=1,ac=408,network=ACMEWISP_NewarkAirport';
  341. so = ss.option(form.Value, 'radiuslocationname', _('WISPr Location Name') );
  342. so.optional = true;
  343. so.placeholder = 'ACMEWISP,Gate_14_Terminal_C_of_Newark_Airport';
  344. so = ss.option(form.Value, 'radiusnasporttype', _('NAS-Port-Type') );
  345. so.optional = true;
  346. so.placeholder = '19';
  347. so.datatype = 'uinteger';
  348. so = ss.option(form.Value, 'adminuser', _('Admin user') );
  349. so.optional = true;
  350. so = ss.option(form.Value, 'adminpassword', _('Admin password') );
  351. so.optional = true;
  352. so.password = true;
  353. ss.option(form.Flag, 'radiusoriginalurl', _('Original URL'), _('Send CoovaChilli-OriginalURL in Access-Request') );
  354. ss.option(form.Flag, 'swapoctets', _('Swap Octets'), _('Swap the meaning of input and output octets') );
  355. ss.option(form.Flag, 'openidauth', _('Open ID Auth') );
  356. ss.option(form.Flag, 'wpaguests', _('WPA guests') );
  357. ss.option(form.Flag, 'acctupdate', _('Accounting update') );
  358. ss.option(form.Flag, 'noradallow', _('Allow all, absent RADIUS'), _('Allow all sessions when RADIUS is not available') );
  359. so = ss.option(form.Value, 'coaport', _('COA Port'), _('UDP port to listen to for accepting RADIUS disconnect requests') );
  360. so.optional = true;
  361. so.datatype = 'port';
  362. ss.option(form.Flag, 'coanoipcheck', _('COA no IP check'), _('Do not check the source IP address of RADIUS disconnect requests') );
  363. /// RADIUS Proxy
  364. o = s.taboption('radius', form.SectionValue, '__radprox__', form.TypedSection, 'chilli', null,
  365. _('Options for RADIUS proxy'));
  366. ss = o.subsection;
  367. ss.anonymous = true;
  368. so = ss.option(form.Value, 'proxylisten', _('Proxy Listen') );
  369. so.optional = true;
  370. this.addLocalDeviceIPs(so, net_devices);
  371. so.placeholder = '10.0.0.1';
  372. so.datatype = 'ipaddr';
  373. so = ss.option(form.Value, 'proxyport', _('Proxy Port'), _('UDP Port to listen to for accepting RADIUS requests') );
  374. so.optional = true;
  375. so.placeholder = '1645';
  376. so.datatype = 'port';
  377. so = ss.option(form.Value, 'proxyclient', _('Proxy Client'), _('IP address from which RADIUS requests are accepted') );
  378. so.optional = true;
  379. so.placeholder = '10.0.0.1/24';
  380. so.datatype = 'cidr';
  381. so = ss.option(form.Value, 'proxysecret', _('Proxy Secret') );
  382. so.optional = true;
  383. so.password = true;
  384. ///////
  385. return m.render();
  386. }
  387. });