~emersion/public-inbox

gamja: add TLS checkbox to network form v1 PROPOSED

Lauri Tirkkonen: 1
 add TLS checkbox to network form

 3 files changed, 24 insertions(+), 6 deletions(-)
#923168 .build.yml success
Thanks for your response.

On Mon, Jan 16 2023 10:52:52 +0000, Simon Ser wrote:
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/38223/mbox | git am -3
Learn more about email & git

[PATCH gamja] add TLS checkbox to network form Export this patch

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
gamja/patches/.build.yml: SUCCESS in 36s

[add TLS checkbox to network form][0] from [Lauri Tirkkonen][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/38223
[1]: mailto:lauri@hacktheplanet.fi

✓ #923168 SUCCESS gamja/patches/.build.yml https://builds.sr.ht/~emersion/job/923168
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.