mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
uspot: various fixes
* add web-root override support * various cleanups Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -4,10 +4,10 @@ PKG_NAME:=ucentral-schema
|
|||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_SOURCE_URL=https://github.com/Telecominfraproject/wlan-ucentral-schema.git
|
PKG_SOURCE_URL=https://github.com/Telecominfraproject/wlan-ucentral-schema.git
|
||||||
PKG_MIRROR_HASH:=422708640ae281e15bb156a3d1cd50d84723a6c47d6df76d1b806d3ac532aa73
|
PKG_MIRROR_HASH:=6eb2054f7ee014aa1a7ccc6d03aba34a8c041599bf63a575b3f3b73bb461ca15
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_DATE:=2022-05-29
|
PKG_SOURCE_DATE:=2022-05-29
|
||||||
PKG_SOURCE_VERSION:=bab27cb9679081332cfe69c8310d57e9483950d4
|
PKG_SOURCE_VERSION:=161fa7e666bb6c00f49487275d1150fd5cfc5b31
|
||||||
|
|
||||||
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
|
||||||
PKG_LICENSE:=BSD-3-Clause
|
PKG_LICENSE:=BSD-3-Clause
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,36 +0,0 @@
|
|||||||
ubus call spotfilter interface_add '{ "name": "hotspot", "devices": [ "wlancaptive0", "wlancaptive1" ], "config": { "default_class": 1, "default_dns_class": 0, "class": [ { "index": 0, "device_macaddr": "up0v0", "fwmark": 1,"fwmark_mask": 127}, { "index": 1, "fwmark": 2,"fwmark_mask": 127 }] } }'
|
|
||||||
|
|
||||||
ubus call spotfilter interface_add '{ "name": "hotspot", "devices": [ "wlan0" ], "config": { "class": [ { "index": 0, "device_macaddr": "up0v0", "fwmark": 1,"fwmark_mask": 127}, { "index": 1, "fwmark": 2,"fwmark_mask": 127 }] } }'
|
|
||||||
ubus call spotfilter interface_add '{ "name": "hotspot", "devices": [ "wlan1" ], "config": { "class": [ { "index": 0, "device_macaddr": "up0v0", "fwmark": 1,"fwmark_mask": 127}, { "index": 1, "fwmark": 2,"fwmark_mask": 127 }] } }'
|
|
||||||
|
|
||||||
ubus call spotfilter client_set '{"interface":"hotspot", "address": "1c:57:dc:37:3c:b1", "state": 0, "dns_state": 1}'
|
|
||||||
ubus call spotfilter client_set '{"interface":"hotspot", "address": "e8:a7:30:a0:9c:6e", "state": 0, "dns_state": 1}'
|
|
||||||
ubus call spotfilter client_get '{"interface":"hotspot", "address": "1e:07:4c:c0:89:a7", "state": 0, "dns_state": 1}'
|
|
||||||
|
|
||||||
ubus call spotfilter client_set '{"interface":"hotspot", "address": "e8:a7:30:a0:9c:6e", "state": 0, "dns_state": 1}'
|
|
||||||
ubus call spotfilter client_get '{"interface":"hotspot", "address": "1c:57:dc:37:3c:b1", "state": 0, "dns_state": 1}'
|
|
||||||
|
|
||||||
config redirect
|
|
||||||
option name 'HTTP-Redirect'
|
|
||||||
option src up0v0
|
|
||||||
option src_dport 80
|
|
||||||
option proto tcp
|
|
||||||
option target DNAT
|
|
||||||
option mark 1/127
|
|
||||||
|
|
||||||
|
|
||||||
config rule
|
|
||||||
option name 'Allow-captive-up0v0'
|
|
||||||
option src 'up0v0'
|
|
||||||
option dest_port '80'
|
|
||||||
option proto 'tcp'
|
|
||||||
option mark 2/127
|
|
||||||
option target 'ACCEPT'
|
|
||||||
|
|
||||||
config rule
|
|
||||||
option name 'Allow-captive-up0v0'
|
|
||||||
option src 'up0v0'
|
|
||||||
option dest_port '80'
|
|
||||||
option proto 'tcp'
|
|
||||||
option mark 1/127
|
|
||||||
option target 'ACCEPT'
|
|
||||||
@@ -6,17 +6,17 @@ let fs = require('fs');
|
|||||||
let rtnl = require('rtnl');
|
let rtnl = require('rtnl');
|
||||||
let uam = require('uam');
|
let uam = require('uam');
|
||||||
|
|
||||||
let file = fs.open('/usr/share/uspot/header', 'r');
|
let uci = require('uci').cursor();
|
||||||
|
let config = uci.get_all('uspot');
|
||||||
|
|
||||||
|
let file = fs.open(config.config.web_root == 1 ? '/tmp/ucentral/www-uspot/header.html' : '/usr/share/uspot/header', 'r');
|
||||||
let header = file.read('all');
|
let header = file.read('all');
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
file = fs.open('/usr/share/uspot/footer', 'r');
|
file = fs.open(config.config.web_root == 1 ? '/tmp/ucentral/www-uspot/footer.html' : '/usr/share/uspot/footer', 'r');
|
||||||
let footer = file.read('all');
|
let footer = file.read('all');
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
let uci = require('uci').cursor();
|
|
||||||
let config = uci.get_all('uspot');
|
|
||||||
|
|
||||||
// fs.open wrapper
|
// fs.open wrapper
|
||||||
function fs_open(cmd) {
|
function fs_open(cmd) {
|
||||||
let stdout = fs.popen(cmd);
|
let stdout = fs.popen(cmd);
|
||||||
@@ -60,8 +60,7 @@ function request_start(ctx) {
|
|||||||
'&mac=' + replace(ctx.mac, ':', '-') +
|
'&mac=' + replace(ctx.mac, ':', '-') +
|
||||||
'&ip=' + ctx.env.REMOTE_ADDR +
|
'&ip=' + ctx.env.REMOTE_ADDR +
|
||||||
'&called=' + config.uam.nasmac +
|
'&called=' + config.uam.nasmac +
|
||||||
'&nasid=' + config.uam.nasid +
|
'&nasid=' + config.uam.nasid;
|
||||||
'&userurl=www.google.com';
|
|
||||||
ctx.uam_location += '&md=' + uam.md5(ctx.uam_location, config.uam.uam_secret);
|
ctx.uam_location += '&md=' + uam.md5(ctx.uam_location, config.uam.uam_secret);
|
||||||
include('uam.uc', ctx);
|
include('uam.uc', ctx);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
|
||||||
<meta http-equiv="refresh" content="0; URL=http://192.168.178.22/hotspot" />
|
|
||||||
</head>
|
|
||||||
<body style="background-color: white">
|
|
||||||
<a style="color: black; font-family: arial, helvetica, sans-serif;" href="http://192.168.178.22/hotspot">HotSpot Login</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
let uci = require('uci').cursor();
|
|
||||||
let config = uci.get_all('uspot');
|
|
||||||
let fs = require('fs');
|
|
||||||
|
|
||||||
let stdout = fs.popen('env');
|
|
||||||
let raw = stdout.read('all');
|
|
||||||
let lines = split(raw, '\n');
|
|
||||||
let env = {};
|
|
||||||
for (let line in lines) {
|
|
||||||
let e = split(line, '=');
|
|
||||||
if (length(e) == 2)
|
|
||||||
env[e[0]] = e[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
let location;
|
|
||||||
|
|
||||||
switch(config.config.auth_mode) {
|
|
||||||
case 'uam':
|
|
||||||
location = config.uam.server +
|
|
||||||
'?res=notyet' +
|
|
||||||
'&uamip=' + env.SERVER_ADDR +
|
|
||||||
'&uamport=' + config.uam.port +
|
|
||||||
//'&challenge=' +
|
|
||||||
//'&mac=' +
|
|
||||||
'&called=' + config.uam.nasmac +
|
|
||||||
'&nasid=' + config.uam.nasid +
|
|
||||||
// '&sessionid=' + +
|
|
||||||
// userurl
|
|
||||||
// md=
|
|
||||||
"";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
location = 'http://' + env.SERVER_ADDR + '/hotspot';
|
|
||||||
}
|
|
||||||
|
|
||||||
system('logger "' + location + '"');
|
|
||||||
|
|
||||||
printf('Status: 302 Found
|
|
||||||
Location: %s
|
|
||||||
Content-Type: text/html
|
|
||||||
|
|
||||||
', location);
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
|
||||||
<meta http-equiv="refresh" content="0; URL=http://192.168.178.22/hotspot" />
|
|
||||||
</head>
|
|
||||||
<body style="background-color: white">
|
|
||||||
<a style="color: black; font-family: arial, helvetica, sans-serif;" href="http://192.168.178.22/hotspot">HotSpot Login</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user