Created
October 29, 2019 05:50
-
-
Save ysc3839/e058bdd35df92b3f5ed9939615ece4a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('luci.util') | |
local nx_redir = false | |
function http_date(time) | |
return os.date('!%a, %d %b %Y %H:%M:%S GMT', time) | |
end | |
function handle_request(env) | |
local send = uhttpd.send | |
if env.REQUEST_URI == '/' then -- NintendoWiFi | |
if nx_redir then | |
send('Status: 302 Found\r\n') | |
send('Location: https://www.bing.com/\r\n\r\n') | |
else | |
local date = http_date(os.time()) | |
send('Status: 200 OK\r\n') | |
send('Content-Length: 2\r\n') | |
send('Expires: %s\r\n' % date) | |
send('Cache-Control: max-age=0, no-cache, no-store\r\n') | |
send('Pragma: no-cache\r\n') | |
send('Date: %s\r\n' % date) | |
send('X-Organization: Nintendo\r\n') | |
send('Content-Type: text/plain\r\n\r\nok') | |
end | |
elseif env.REQUEST_URI == '/generate_204' then -- Android generate_204 | |
send('Status: 204 No Content\r\n') | |
send('Date: %s\r\n\r\n' % http_date(os.time())) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config uhttpd 'conntest' | |
option rfc1918_filter '1' | |
list listen_http '0.0.0.0:080' | |
option home '/var/tmp' | |
list lua_prefix '/=/root/conntest-handler.lua' | |
option http_keepalive '0' | |
option tcp_keepalive '0' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to run
opkg install uhttpd-mod-lua
first to install uHTTPd lua handler support.