wip usenet stuff

This commit is contained in:
zefie
2022-10-12 12:26:30 -04:00
parent 8075438a93
commit 976c79c92a
14 changed files with 619 additions and 46 deletions

View File

@@ -1,12 +1,32 @@
var minisrv_service_file = true;
const wtvnews = new WTVNews(minisrv_config, service_name);
const wtvnews = new WTVNews(minisrv_config, service_name);
var service_config = minisrv_config.services[service_name];
if (service_config.local_nntp_port && wtvnewsserver) {
var tls_path = this.wtvshared.getAbsolutePath(this.minisrv_config.config.ServiceDeps + '/wtv-news');
var tls_options = {
ca: this.fs.readFileSync(tls_path + '/localserver_ca.pem'),
key: this.fs.readFileSync(tls_path + '/localserver_key.pem'),
cert: this.fs.readFileSync(tls_path + '/localserver_cert.pem'),
checkServerIdentity: () => { return null; }
}
if (wtvnewsserver.username)
wtvnews.initializeUsenet("127.0.0.1", minisrv_config.services[service_name].local_nntp_port, tls_options, wtvnewsserver.username, wtvnewsserver.password);
else
wtvnews.initializeUsenet("127.0.0.1", minisrv_config.services[service_name].local_nntp_port, tls_options);
} else {
if (service_config.upstream_auth)
wtvnews.initializeUsenet(service_config.upstream_address, service_config.upstream_port, service_config.upstream_tls || null, service_config.upstream_auth.username || null, service_config.upstream_auth.password || null);
else
wtvnews.initializeUsenet(service_config.upstream_address, service_configupstream_port, service_config.upstream_tls || null);
}
async function throwError(e) {
console.log(e);
var errpage = wtvshared.doErrorPage(400, null, e.toString());
sendToClient(socket, errpage[0], errpage[1]);
}
function isToday (chkdate) {
const today = new Date()
return chkdate.getDate() == today.getDate() &&
@@ -28,7 +48,6 @@ async function WebTVListGroup(group) {
page_start = (limit_per_page * page) + 1;
page_end = (page + 1) * limit_per_page;
if (page_end > NGCount) page_end = NGCount;
wtvnews.getHeaderObj(NGArticles).then((messages) => {
messages = wtvnews.sortByResponse(messages);
wtvnews.quitUsenet();
@@ -157,7 +176,9 @@ Group: ${request_headers.query.group}
</font>
<br>
<img src="wtv-home:/ROMCache/Spacer.gif" width=0 height=8>
`;
if (NGCount > 0) {
data += `
<td width=180 valign=bottom align=right>
<table cellspacing=0 cellpadding=0>
<td rowspan=4 height=26 width=30>
@@ -182,8 +203,9 @@ ${page_start}-${page_end}
<img src="wtv-home:/ROMCache/Spacer.gif" width=1 height=1>
<tr>
<td colspan=5 height=3>
</table> </table>
</table> `;
}
data += `</table>
<TABLE width=446 cellspacing=0 cellpadding=0>
<tr>
<td rowspan=4>
@@ -206,6 +228,7 @@ ${page_start}-${page_end}
var has_relation = (messages[k].relation !== null) ? true : false;
var date_obj = new Date(Date.parse(message.headers.DATE));
var date = (isToday(date_obj)) ? strftime("%I:%M %p", date_obj) : strftime("%b %d", date_obj)
console.log(message);
data += `
<table cellspacing=0 cellpadding=0>
<tr>
@@ -230,8 +253,6 @@ ${(message.headers.FROM.indexOf(' ') > 0) ? message.headers.FROM.split(' ')[0] :
<TABLE width=446 cellspacing=0 cellpadding=0>
<tr>
<td rowspan=4 width=10 height=1>
<img src="wtv-home:/ROMCache/Spacer.gif" width=10 height=1>
<td height=2 width=436 bgcolor="2B2B2B">
<img src="wtv-home:/ROMCache/Spacer.gif" width=436 height=1>
<tr>
<td height=1>
@@ -264,7 +285,6 @@ async function WebTVShowMessage(group, article) {
wtvnews.getArticle(article).then((response) => {
wtvnews.quitUsenet();
if (response.code == 220) {
console.log(response);
headers = `200 OK
Content-type: text/html
wtv-expire-all: wtv-news:/news?group=${group}&article=`;
@@ -573,7 +593,7 @@ ${wtvshared.htmlEntitize(message_body, true)}
});;
}
if (!minisrv_config.services[service_name].upstream_address || !minisrv_config.services[service_name].upstream_port) {
if (!wtvnews.client) {
var errpage = doErrorPage();
headers = errpage[0];
data = errpage[1];

View File

@@ -123,7 +123,7 @@ MAXLENGTH="${minisrv_config.config.passwords.max_length}">
<tr>
<td colspan=3 align=left>
<br>Type again to confirm<br>
<INPUT noSubmit name="verify" id="verify" Value=""
<INPUT noSubmit name="password_verify" id="password_verify" Value=""
bgcolor=#444444 text=#ffdd33 cursor=#cc9933
TYPE="password" ASCIIONLY
SIZE="${minisrv_config.config.passwords.form_size}"

View File

@@ -36,7 +36,7 @@ Content-Type: text/html`
data = errpage[1];
}
else {
if (request_headers.query.password.length == 0 && request_headers.query.verify.length == 0) {
if (request_headers.query.password.length == 0 && request_headers.query.password_verify.length == 0) {
userSession.disableUserPassword();
headers = `300 OK
Content-type: text/html
@@ -50,7 +50,7 @@ Location: ${request_headers.query.return_to}`;
}
else if (request_headers.query.password.length < minisrv_config.config.passwords.min_length) errpage = wtvshared.doErrorPage(400, "Your password must contain at least " + minisrv_config.config.passwords.min_length + " characters.");
else if (request_headers.query.password.length > minisrv_config.config.passwords.max_length) errpage = wtvshared.doErrorPage(400, "Your password must contain no more than than " + minisrv_config.config.passwords.max_length + " characters.");
else if (request_headers.query.password !== request_headers.query.verify) errpage = wtvshared.doErrorPage(400, "The passwords you entered did not match. Please check them and try again.");
else if (request_headers.query.password !== request_headers.query.password_verify) errpage = wtvshared.doErrorPage(400, "The passwords you entered did not match. Please check them and try again.");
else {
if (errpage) {
headers = errpage[0];