~emersion/soju-dev

Fix error message when upstream is unreachable v1 PROPOSED

Hubert Hirtz: 1
 Fix error message when upstream is unreachable

 1 files changed, 9 insertions(+), 1 deletions(-)
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/soju-dev/patches/22325/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] Fix error message when upstream is unreachable Export this patch

---

Note: do not apply yet, still testing this.

It doesn't seem to work when soju starts while the upstream is down,
i'll first make sure it works otherwise.

 downstream.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/downstream.go b/downstream.go
index 4707591..9b9184d 100644
--- a/downstream.go
+++ b/downstream.go
@@ -255,6 +255,7 @@ func (dc *downstreamConn) unmarshalEntity(name string) (*upstreamConn, string, e
	}

	var conn *upstreamConn
	var ok bool
	if i := strings.LastIndexByte(name, '/'); i >= 0 {
		network := name[i+1:]
		name = name[:i]
@@ -264,15 +265,22 @@ func (dc *downstreamConn) unmarshalEntity(name string) (*upstreamConn, string, e
				return
			}
			conn = uc
			ok = true
		})
	}

	if conn == nil {
	if !ok {
		return nil, "", ircError{&irc.Message{
			Command: irc.ERR_NOSUCHCHANNEL,
			Params:  []string{name, "Missing network suffix in channel name"},
		}}
	}
	if conn == nil {
		return nil, "", ircError{&irc.Message{
			Command: irc.ERR_NOSUCHCHANNEL,
			Params:  []string{name, "Upstream is unreachable, try again later"},
		}}
	}
	return conn, name, nil
}

-- 
2.31.1