also, remove the default value for the port field; per the
bouncer-networks spec, if it's missing the bouncer should automatically
choose the appropriate port (6667 or 6697, depending on tls)
---
components/app.js | 4 ++--
components/network-form.js | 10 +++++++++-
lib/irc.js | 16 +++++++++++++---
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/components/app.js b/components/app.js
index 48dc72b..53bb946 100644
--- a/components/app.js
+++ b/components/app.js
@@ -1304,6 +1304,7 @@ export default class App extends Component {
}
let { host, port } = splitHostPort(url.host);
+ let tls = url.tls;
let serverID;
if (!url.host) {
@@ -1317,7 +1318,7 @@ export default class App extends Component {
return false;
}
- let params = { host };
+ let params = { host, tls };
if (typeof port === "number") {
params.port = port;
}
@@ -1831,7 +1832,6 @@ export default class App extends Component {
params: ["CHANGENETWORK", this.state.dialogData.id, irc.formatTags(attrs)],
});
} else {
- attrs = { ...attrs, tls: "1" };
client.createBouncerNetwork(attrs).then((id) => {
if (!autojoin) {
return;
diff --git a/components/network-form.js b/components/network-form.js
index 1610040..d06682b 100644
--- a/components/network-form.js
+++ b/components/network-form.js
@@ -3,7 +3,8 @@ import { html, Component } from "../lib/index.js";
const defaultParams = {
name: "",
host: "",
- port: 6697,
+ port: null,
+ tls: true,
nickname: "",
username: "",
realname: "",
@@ -32,6 +33,9 @@ export default class NetworkForm extends Component {
this.prevParams[k] = props.params[k];
}
});
+ if (typeof this.state["tls"] === "string") {
+ this.state["tls"] = this.state["tls"] === "1" ? true : false;
+ }
}
}
@@ -103,6 +107,10 @@ export default class NetworkForm extends Component {
Port:<br/>
<input type="number" name="port" value=${this.state.port}/>
</label>
+ <label>
+ <input type="checkbox" name="tls" checked=${this.state.tls}/>
+ TLS
+ </label>
<br/><br/>
<label>
diff --git a/lib/irc.js b/lib/irc.js
index 03ceb8d..023bde8 100644
--- a/lib/irc.js
+++ b/lib/irc.js
@@ -120,7 +120,12 @@ export function formatTags(tags) {
l.push(k);
continue;
}
- let v = escapeTag(tags[k]);
+ let v;
+ if (typeof tags[k] === "boolean") {
+ v = tags[k] ? "1" : "0";
+ } else {
+ v = escapeTag(tags[k]);
+ }
l.push(k + "=" + v);
}
return l.join(";");
@@ -786,7 +791,12 @@ export function isMeaningfulRealname(realname, nick) {
* See: https://datatracker.ietf.org/doc/html/draft-butcher-irc-url-04
*/
export function parseURL(str) {
- if (!str.startsWith("irc://") && !str.startsWith("ircs://")) {
+ let tls;
+ if (str.startsWith("irc://")) {
+ tls = false;
+ } else if (str.startsWith("ircs://")) {
+ tls = true;
+ } else {
return null;
}
@@ -836,7 +846,7 @@ export function parseURL(str) {
enttype = entity.startsWith("#") ? "channel" : "user";
}
- return { host, enttype, entity };
+ return { host, enttype, entity, tls };
}
export class CapRegistry {
--
2.38.2
--
Lauri Tirkkonen | lotheac @ IRCnet
Hm, thanks for the patch, but I'm not sure this is something I want to
support. I'd prefer to force users who want insecure connections to use
BouncerServ manually. Insecure connections are best avoided.
Thanks for your response.
On Mon, Jan 16 2023 10:52:52 +0000, Simon Ser wrote:
> Hm, thanks for the patch, but I'm not sure this is something I want to
> support. I'd prefer to force users who want insecure connections to use
> BouncerServ manually. Insecure connections are best avoided.
Sure. It's just that there are some IRC networks out there that either
don't support TLS connections at all (QuakeNet, I think), or only a
small minority of servers do (IRCnet); I wanted my users to have an
easier experience with those.
That said, the patch does change behavior for irc:// links - I could be
persuaded into requiring irc+insecure:// for insecure links instead, if
that's more reasonable to you.
--
Lauri Tirkkonen | lotheac @ IRCnet