Skip to content
Snippets Groups Projects
Commit 9bd71001 authored by echicken's avatar echicken :chicken:
Browse files

More information must be gathered by Keyop.

Therefore, be it resolved:
Whereas more information is required,
Whereas such information cometh from log files,
Whereas this script should spew many messages into the logs,
The script shalt not cache any data for the time being, nor load
any cached data,
The script shall barf much data into the logs for purposes of
troubleshooting.

- King James III on the eve of his coronation, hand on bibble
parent 3ed775d5
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3839 passed
...@@ -82,17 +82,24 @@ function wsrsGetIPAddress() { ...@@ -82,17 +82,24 @@ function wsrsGetIPAddress() {
} }
function getAddress() { function getAddress() {
log(LOG_DEBUG, 'user.ip_address is ' + user.ip_address);
const addrRe = /^(127\.)|(192\.168\.)|(10\.)|(172\.1[6-9]\.)|(172\.2[0-9]\.)|(172\.3[0-1]\.)|(169\.254\.)|(::1$)|([fF][cCdD])/; const addrRe = /^(127\.)|(192\.168\.)|(10\.)|(172\.1[6-9]\.)|(172\.2[0-9]\.)|(172\.3[0-1]\.)|(169\.254\.)|(::1$)|([fF][cCdD])/;
if (user.ip_address.search(addrRe) > -1) { if (user.ip_address.search(addrRe) > -1) {
var addr; var addr;
if (client.protocol === 'Telnet') { if (client.protocol === 'Telnet') {
log(LOG_DEBUG, 'Trying wsts method');
addr = wstsGetIPAddress(); addr = wstsGetIPAddress();
log(LOG_DEBUG, 'wsts result: ' + addr);
} else if (bbs.sys_status&SS_RLOGIN) { } else if (bbs.sys_status&SS_RLOGIN) {
log(LOG_DEBUG, 'Trying wsrs method');
addr = wsrsGetIPAddress(); addr = wsrsGetIPAddress();
log(LOG_DEBUG, 'wsrs result: ' + addr);
} }
if (addr === undefined || addr.search(addrRe) > -1) return; if (addr === undefined || addr.search(addrRe) > -1) return;
log(LOG_DEBUG, 'returning: ' + addr);
return addr; return addr;
} }
log(LOG_DEBUG, 'returning: ' + user.ip_address);
return user.ip_address; return user.ip_address;
} }
......
...@@ -31,10 +31,14 @@ function writeCache(qs, addr, ans) { ...@@ -31,10 +31,14 @@ function writeCache(qs, addr, ans) {
} }
function fetchWeather(qs, addr) { function fetchWeather(qs, addr) {
log(LOG_DEBUG, 'Requesting weather from ' + qs + ' for ' + addr);
const http = new HTTPRequest(); const http = new HTTPRequest();
if (addr !== undefined) http.extra_headers = { 'X-Forwarded-For': addr }; if (addr !== undefined) http.extra_headers = { 'X-Forwarded-For': addr };
const body = http.Get(qs); const body = http.Get(qs);
if (http.response_code !== 200) throw new Error('wttr.in response had status ' + http.response_code); if (http.response_code !== 200) {
log(LOG_DEBUG, 'wttr.in response had status ' + http.response_code);
throw new Error('wttr.in response had status ' + http.response_code);
}
return body; return body;
} }
......
...@@ -4,7 +4,7 @@ const wttr = load({}, js.exec_dir + 'wttr-lib.js'); ...@@ -4,7 +4,7 @@ const wttr = load({}, js.exec_dir + 'wttr-lib.js');
function parseArgs() { function parseArgs() {
const ret = { const ret = {
qs: 'https://wttr.in/?AFn', qs: 'https://wttr.in/?AFn',
ttl: 3600, // Seconds ttl: 0, // Seconds
}; };
for (var n = 0; n < argc; n++) { for (var n = 0; n < argc; n++) {
const arg = parseInt(argv[n], 10); const arg = parseInt(argv[n], 10);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment