ScuttleBot

fix: aggressive IRC keepalive and reliable reconnection - Set PingDelay=30s PingTimeout=30s on all girc clients (relay + 11 bots) so dead connections are detected within ~60s - Fix relay reconnect: treat nil error from Connect() as a disconnect event so keepAlive loop always triggers on connection loss - Previously a clean server disconnect returned nil and the relay would hang forever without reconnecting

lmata 2026-04-03 19:53 trunk
Commit 81587e63ffd76e66225dba941c90ec6eeaea1a4e7dc71f692f92d7e795f5c125
--- internal/bots/auditbot/auditbot.go
+++ internal/bots/auditbot/auditbot.go
@@ -107,12 +107,14 @@
107107
Server: host,
108108
Port: port,
109109
Nick: botNick,
110110
User: botNick,
111111
Name: "scuttlebot auditbot",
112
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
113
- SSL: false,
112
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
113
+ PingDelay: 30 * time.Second,
114
+ PingTimeout: 30 * time.Second,
115
+ SSL: false,
114116
})
115117
116118
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
117119
for _, ch := range b.channels {
118120
cl.Cmd.Join(ch)
119121
--- internal/bots/auditbot/auditbot.go
+++ internal/bots/auditbot/auditbot.go
@@ -107,12 +107,14 @@
107 Server: host,
108 Port: port,
109 Nick: botNick,
110 User: botNick,
111 Name: "scuttlebot auditbot",
112 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
113 SSL: false,
 
 
114 })
115
116 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
117 for _, ch := range b.channels {
118 cl.Cmd.Join(ch)
119
--- internal/bots/auditbot/auditbot.go
+++ internal/bots/auditbot/auditbot.go
@@ -107,12 +107,14 @@
107 Server: host,
108 Port: port,
109 Nick: botNick,
110 User: botNick,
111 Name: "scuttlebot auditbot",
112 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
113 PingDelay: 30 * time.Second,
114 PingTimeout: 30 * time.Second,
115 SSL: false,
116 })
117
118 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
119 for _, ch := range b.channels {
120 cl.Cmd.Join(ch)
121
--- internal/bots/bridge/bridge.go
+++ internal/bots/bridge/bridge.go
@@ -156,12 +156,14 @@
156156
Server: host,
157157
Port: port,
158158
Nick: b.nick,
159159
User: b.nick,
160160
Name: "scuttlebot bridge",
161
- SASL: &girc.SASLPlain{User: b.nick, Pass: b.password},
162
- SSL: false,
161
+ SASL: &girc.SASLPlain{User: b.nick, Pass: b.password},
162
+ PingDelay: 30 * time.Second,
163
+ PingTimeout: 30 * time.Second,
164
+ SSL: false,
163165
})
164166
165167
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
166168
if b.log != nil {
167169
b.log.Info("bridge connected")
168170
--- internal/bots/bridge/bridge.go
+++ internal/bots/bridge/bridge.go
@@ -156,12 +156,14 @@
156 Server: host,
157 Port: port,
158 Nick: b.nick,
159 User: b.nick,
160 Name: "scuttlebot bridge",
161 SASL: &girc.SASLPlain{User: b.nick, Pass: b.password},
162 SSL: false,
 
 
163 })
164
165 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
166 if b.log != nil {
167 b.log.Info("bridge connected")
168
--- internal/bots/bridge/bridge.go
+++ internal/bots/bridge/bridge.go
@@ -156,12 +156,14 @@
156 Server: host,
157 Port: port,
158 Nick: b.nick,
159 User: b.nick,
160 Name: "scuttlebot bridge",
161 SASL: &girc.SASLPlain{User: b.nick, Pass: b.password},
162 PingDelay: 30 * time.Second,
163 PingTimeout: 30 * time.Second,
164 SSL: false,
165 })
166
167 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
168 if b.log != nil {
169 b.log.Info("bridge connected")
170
--- internal/bots/herald/herald.go
+++ internal/bots/herald/herald.go
@@ -142,12 +142,14 @@
142142
Server: host,
143143
Port: port,
144144
Nick: botNick,
145145
User: botNick,
146146
Name: "scuttlebot herald",
147
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
148
- SSL: false,
147
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
148
+ PingDelay: 30 * time.Second,
149
+ PingTimeout: 30 * time.Second,
150
+ SSL: false,
149151
})
150152
151153
c.Handlers.AddBg(girc.CONNECTED, func(_ *girc.Client, _ girc.Event) {
152154
if b.log != nil {
153155
b.log.Info("herald connected")
154156
--- internal/bots/herald/herald.go
+++ internal/bots/herald/herald.go
@@ -142,12 +142,14 @@
142 Server: host,
143 Port: port,
144 Nick: botNick,
145 User: botNick,
146 Name: "scuttlebot herald",
147 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
148 SSL: false,
 
 
149 })
150
151 c.Handlers.AddBg(girc.CONNECTED, func(_ *girc.Client, _ girc.Event) {
152 if b.log != nil {
153 b.log.Info("herald connected")
154
--- internal/bots/herald/herald.go
+++ internal/bots/herald/herald.go
@@ -142,12 +142,14 @@
142 Server: host,
143 Port: port,
144 Nick: botNick,
145 User: botNick,
146 Name: "scuttlebot herald",
147 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
148 PingDelay: 30 * time.Second,
149 PingTimeout: 30 * time.Second,
150 SSL: false,
151 })
152
153 c.Handlers.AddBg(girc.CONNECTED, func(_ *girc.Client, _ girc.Event) {
154 if b.log != nil {
155 b.log.Info("herald connected")
156
--- internal/bots/oracle/oracle.go
+++ internal/bots/oracle/oracle.go
@@ -153,12 +153,14 @@
153153
Server: host,
154154
Port: port,
155155
Nick: botNick,
156156
User: botNick,
157157
Name: "scuttlebot oracle",
158
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
159
- SSL: false,
158
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
159
+ PingDelay: 30 * time.Second,
160
+ PingTimeout: 30 * time.Second,
161
+ SSL: false,
160162
})
161163
162164
c.Handlers.AddBg(girc.CONNECTED, func(_ *girc.Client, _ girc.Event) {
163165
if b.log != nil {
164166
b.log.Info("oracle connected")
165167
--- internal/bots/oracle/oracle.go
+++ internal/bots/oracle/oracle.go
@@ -153,12 +153,14 @@
153 Server: host,
154 Port: port,
155 Nick: botNick,
156 User: botNick,
157 Name: "scuttlebot oracle",
158 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
159 SSL: false,
 
 
160 })
161
162 c.Handlers.AddBg(girc.CONNECTED, func(_ *girc.Client, _ girc.Event) {
163 if b.log != nil {
164 b.log.Info("oracle connected")
165
--- internal/bots/oracle/oracle.go
+++ internal/bots/oracle/oracle.go
@@ -153,12 +153,14 @@
153 Server: host,
154 Port: port,
155 Nick: botNick,
156 User: botNick,
157 Name: "scuttlebot oracle",
158 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
159 PingDelay: 30 * time.Second,
160 PingTimeout: 30 * time.Second,
161 SSL: false,
162 })
163
164 c.Handlers.AddBg(girc.CONNECTED, func(_ *girc.Client, _ girc.Event) {
165 if b.log != nil {
166 b.log.Info("oracle connected")
167
--- internal/bots/scribe/scribe.go
+++ internal/bots/scribe/scribe.go
@@ -57,12 +57,14 @@
5757
Server: host,
5858
Port: port,
5959
Nick: botNick,
6060
User: botNick,
6161
Name: "scuttlebot scribe",
62
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
63
- SSL: false,
62
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
63
+ PingDelay: 30 * time.Second,
64
+ PingTimeout: 30 * time.Second,
65
+ SSL: false,
6466
})
6567
6668
c.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, e girc.Event) {
6769
for _, ch := range b.channels {
6870
client.Cmd.Join(ch)
6971
--- internal/bots/scribe/scribe.go
+++ internal/bots/scribe/scribe.go
@@ -57,12 +57,14 @@
57 Server: host,
58 Port: port,
59 Nick: botNick,
60 User: botNick,
61 Name: "scuttlebot scribe",
62 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
63 SSL: false,
 
 
64 })
65
66 c.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, e girc.Event) {
67 for _, ch := range b.channels {
68 client.Cmd.Join(ch)
69
--- internal/bots/scribe/scribe.go
+++ internal/bots/scribe/scribe.go
@@ -57,12 +57,14 @@
57 Server: host,
58 Port: port,
59 Nick: botNick,
60 User: botNick,
61 Name: "scuttlebot scribe",
62 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
63 PingDelay: 30 * time.Second,
64 PingTimeout: 30 * time.Second,
65 SSL: false,
66 })
67
68 c.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, e girc.Event) {
69 for _, ch := range b.channels {
70 client.Cmd.Join(ch)
71
--- internal/bots/scroll/scroll.go
+++ internal/bots/scroll/scroll.go
@@ -66,12 +66,14 @@
6666
Server: host,
6767
Port: port,
6868
Nick: botNick,
6969
User: botNick,
7070
Name: "scuttlebot scroll",
71
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
72
- SSL: false,
71
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
72
+ PingDelay: 30 * time.Second,
73
+ PingTimeout: 30 * time.Second,
74
+ SSL: false,
7375
})
7476
7577
c.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, e girc.Event) {
7678
b.log.Info("scroll connected")
7779
})
7880
--- internal/bots/scroll/scroll.go
+++ internal/bots/scroll/scroll.go
@@ -66,12 +66,14 @@
66 Server: host,
67 Port: port,
68 Nick: botNick,
69 User: botNick,
70 Name: "scuttlebot scroll",
71 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
72 SSL: false,
 
 
73 })
74
75 c.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, e girc.Event) {
76 b.log.Info("scroll connected")
77 })
78
--- internal/bots/scroll/scroll.go
+++ internal/bots/scroll/scroll.go
@@ -66,12 +66,14 @@
66 Server: host,
67 Port: port,
68 Nick: botNick,
69 User: botNick,
70 Name: "scuttlebot scroll",
71 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
72 PingDelay: 30 * time.Second,
73 PingTimeout: 30 * time.Second,
74 SSL: false,
75 })
76
77 c.Handlers.AddBg(girc.CONNECTED, func(client *girc.Client, e girc.Event) {
78 b.log.Info("scroll connected")
79 })
80
--- internal/bots/sentinel/sentinel.go
+++ internal/bots/sentinel/sentinel.go
@@ -137,11 +137,13 @@
137137
Server: host,
138138
Port: port,
139139
Nick: b.cfg.Nick,
140140
User: b.cfg.Nick,
141141
Name: "scuttlebot sentinel",
142
- SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
142
+ SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
143
+ PingDelay: 30 * time.Second,
144
+ PingTimeout: 30 * time.Second,
143145
})
144146
145147
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
146148
if b.log != nil {
147149
b.log.Info("sentinel connected")
148150
--- internal/bots/sentinel/sentinel.go
+++ internal/bots/sentinel/sentinel.go
@@ -137,11 +137,13 @@
137 Server: host,
138 Port: port,
139 Nick: b.cfg.Nick,
140 User: b.cfg.Nick,
141 Name: "scuttlebot sentinel",
142 SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
 
 
143 })
144
145 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
146 if b.log != nil {
147 b.log.Info("sentinel connected")
148
--- internal/bots/sentinel/sentinel.go
+++ internal/bots/sentinel/sentinel.go
@@ -137,11 +137,13 @@
137 Server: host,
138 Port: port,
139 Nick: b.cfg.Nick,
140 User: b.cfg.Nick,
141 Name: "scuttlebot sentinel",
142 SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
143 PingDelay: 30 * time.Second,
144 PingTimeout: 30 * time.Second,
145 })
146
147 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
148 if b.log != nil {
149 b.log.Info("sentinel connected")
150
--- internal/bots/snitch/snitch.go
+++ internal/bots/snitch/snitch.go
@@ -126,11 +126,13 @@
126126
Server: host,
127127
Port: port,
128128
Nick: b.cfg.Nick,
129129
User: b.cfg.Nick,
130130
Name: "scuttlebot snitch",
131
- SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
131
+ SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
132
+ PingDelay: 30 * time.Second,
133
+ PingTimeout: 30 * time.Second,
132134
})
133135
134136
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
135137
if b.log != nil {
136138
b.log.Info("snitch connected")
137139
--- internal/bots/snitch/snitch.go
+++ internal/bots/snitch/snitch.go
@@ -126,11 +126,13 @@
126 Server: host,
127 Port: port,
128 Nick: b.cfg.Nick,
129 User: b.cfg.Nick,
130 Name: "scuttlebot snitch",
131 SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
 
 
132 })
133
134 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
135 if b.log != nil {
136 b.log.Info("snitch connected")
137
--- internal/bots/snitch/snitch.go
+++ internal/bots/snitch/snitch.go
@@ -126,11 +126,13 @@
126 Server: host,
127 Port: port,
128 Nick: b.cfg.Nick,
129 User: b.cfg.Nick,
130 Name: "scuttlebot snitch",
131 SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
132 PingDelay: 30 * time.Second,
133 PingTimeout: 30 * time.Second,
134 })
135
136 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
137 if b.log != nil {
138 b.log.Info("snitch connected")
139
--- internal/bots/steward/steward.go
+++ internal/bots/steward/steward.go
@@ -121,11 +121,13 @@
121121
Server: host,
122122
Port: port,
123123
Nick: b.cfg.Nick,
124124
User: b.cfg.Nick,
125125
Name: "scuttlebot steward",
126
- SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
126
+ SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
127
+ PingDelay: 30 * time.Second,
128
+ PingTimeout: 30 * time.Second,
127129
})
128130
129131
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
130132
if b.log != nil {
131133
b.log.Info("steward connected")
132134
--- internal/bots/steward/steward.go
+++ internal/bots/steward/steward.go
@@ -121,11 +121,13 @@
121 Server: host,
122 Port: port,
123 Nick: b.cfg.Nick,
124 User: b.cfg.Nick,
125 Name: "scuttlebot steward",
126 SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
 
 
127 })
128
129 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
130 if b.log != nil {
131 b.log.Info("steward connected")
132
--- internal/bots/steward/steward.go
+++ internal/bots/steward/steward.go
@@ -121,11 +121,13 @@
121 Server: host,
122 Port: port,
123 Nick: b.cfg.Nick,
124 User: b.cfg.Nick,
125 Name: "scuttlebot steward",
126 SASL: &girc.SASLPlain{User: b.cfg.Nick, Pass: b.cfg.Password},
127 PingDelay: 30 * time.Second,
128 PingTimeout: 30 * time.Second,
129 })
130
131 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
132 if b.log != nil {
133 b.log.Info("steward connected")
134
--- internal/bots/systembot/systembot.go
+++ internal/bots/systembot/systembot.go
@@ -84,12 +84,14 @@
8484
Server: host,
8585
Port: port,
8686
Nick: botNick,
8787
User: botNick,
8888
Name: "scuttlebot systembot",
89
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
90
- SSL: false,
89
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
90
+ PingDelay: 30 * time.Second,
91
+ PingTimeout: 30 * time.Second,
92
+ SSL: false,
9193
})
9294
9395
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
9496
for _, ch := range b.channels {
9597
cl.Cmd.Join(ch)
9698
--- internal/bots/systembot/systembot.go
+++ internal/bots/systembot/systembot.go
@@ -84,12 +84,14 @@
84 Server: host,
85 Port: port,
86 Nick: botNick,
87 User: botNick,
88 Name: "scuttlebot systembot",
89 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
90 SSL: false,
 
 
91 })
92
93 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
94 for _, ch := range b.channels {
95 cl.Cmd.Join(ch)
96
--- internal/bots/systembot/systembot.go
+++ internal/bots/systembot/systembot.go
@@ -84,12 +84,14 @@
84 Server: host,
85 Port: port,
86 Nick: botNick,
87 User: botNick,
88 Name: "scuttlebot systembot",
89 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
90 PingDelay: 30 * time.Second,
91 PingTimeout: 30 * time.Second,
92 SSL: false,
93 })
94
95 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
96 for _, ch := range b.channels {
97 cl.Cmd.Join(ch)
98
--- internal/bots/warden/warden.go
+++ internal/bots/warden/warden.go
@@ -190,12 +190,14 @@
190190
Server: host,
191191
Port: port,
192192
Nick: botNick,
193193
User: botNick,
194194
Name: "scuttlebot warden",
195
- SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
196
- SSL: false,
195
+ SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
196
+ PingDelay: 30 * time.Second,
197
+ PingTimeout: 30 * time.Second,
198
+ SSL: false,
197199
})
198200
199201
c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
200202
// Join all configured channels.
201203
for ch := range b.channelConfigs {
202204
--- internal/bots/warden/warden.go
+++ internal/bots/warden/warden.go
@@ -190,12 +190,14 @@
190 Server: host,
191 Port: port,
192 Nick: botNick,
193 User: botNick,
194 Name: "scuttlebot warden",
195 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
196 SSL: false,
 
 
197 })
198
199 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
200 // Join all configured channels.
201 for ch := range b.channelConfigs {
202
--- internal/bots/warden/warden.go
+++ internal/bots/warden/warden.go
@@ -190,12 +190,14 @@
190 Server: host,
191 Port: port,
192 Nick: botNick,
193 User: botNick,
194 Name: "scuttlebot warden",
195 SASL: &girc.SASLPlain{User: botNick, Pass: b.password},
196 PingDelay: 30 * time.Second,
197 PingTimeout: 30 * time.Second,
198 SSL: false,
199 })
200
201 c.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
202 // Join all configured channels.
203 for ch := range b.channelConfigs {
204
--- pkg/sessionrelay/irc.go
+++ pkg/sessionrelay/irc.go
@@ -96,16 +96,18 @@
9696
// connection goroutine. onJoined fires once when the primary channel is
9797
// joined — used as the initial-connect signal and to reset backoff on
9898
// successful reconnects.
9999
func (c *ircConnector) dial(host string, port int, onJoined func()) {
100100
client := girc.New(girc.Config{
101
- Server: host,
102
- Port: port,
103
- Nick: c.nick,
104
- User: c.nick,
105
- Name: c.nick + " (session relay)",
106
- SASL: &girc.SASLPlain{User: c.nick, Pass: c.pass},
101
+ Server: host,
102
+ Port: port,
103
+ Nick: c.nick,
104
+ User: c.nick,
105
+ Name: c.nick + " (session relay)",
106
+ SASL: &girc.SASLPlain{User: c.nick, Pass: c.pass},
107
+ PingDelay: 30 * time.Second,
108
+ PingTimeout: 30 * time.Second,
107109
})
108110
client.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
109111
for _, channel := range c.Channels() {
110112
cl.Cmd.Join(channel)
111113
}
@@ -143,15 +145,17 @@
143145
c.mu.Lock()
144146
c.client = client
145147
c.mu.Unlock()
146148
147149
go func() {
148
- if err := client.Connect(); err != nil {
149
- select {
150
- case c.errCh <- err:
151
- default:
152
- }
150
+ err := client.Connect()
151
+ if err == nil {
152
+ err = fmt.Errorf("connection closed")
153
+ }
154
+ select {
155
+ case c.errCh <- err:
156
+ default:
153157
}
154158
}()
155159
}
156160
157161
// keepAlive watches for connection errors and redials with exponential backoff.
158162
--- pkg/sessionrelay/irc.go
+++ pkg/sessionrelay/irc.go
@@ -96,16 +96,18 @@
96 // connection goroutine. onJoined fires once when the primary channel is
97 // joined — used as the initial-connect signal and to reset backoff on
98 // successful reconnects.
99 func (c *ircConnector) dial(host string, port int, onJoined func()) {
100 client := girc.New(girc.Config{
101 Server: host,
102 Port: port,
103 Nick: c.nick,
104 User: c.nick,
105 Name: c.nick + " (session relay)",
106 SASL: &girc.SASLPlain{User: c.nick, Pass: c.pass},
 
 
107 })
108 client.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
109 for _, channel := range c.Channels() {
110 cl.Cmd.Join(channel)
111 }
@@ -143,15 +145,17 @@
143 c.mu.Lock()
144 c.client = client
145 c.mu.Unlock()
146
147 go func() {
148 if err := client.Connect(); err != nil {
149 select {
150 case c.errCh <- err:
151 default:
152 }
 
 
153 }
154 }()
155 }
156
157 // keepAlive watches for connection errors and redials with exponential backoff.
158
--- pkg/sessionrelay/irc.go
+++ pkg/sessionrelay/irc.go
@@ -96,16 +96,18 @@
96 // connection goroutine. onJoined fires once when the primary channel is
97 // joined — used as the initial-connect signal and to reset backoff on
98 // successful reconnects.
99 func (c *ircConnector) dial(host string, port int, onJoined func()) {
100 client := girc.New(girc.Config{
101 Server: host,
102 Port: port,
103 Nick: c.nick,
104 User: c.nick,
105 Name: c.nick + " (session relay)",
106 SASL: &girc.SASLPlain{User: c.nick, Pass: c.pass},
107 PingDelay: 30 * time.Second,
108 PingTimeout: 30 * time.Second,
109 })
110 client.Handlers.AddBg(girc.CONNECTED, func(cl *girc.Client, _ girc.Event) {
111 for _, channel := range c.Channels() {
112 cl.Cmd.Join(channel)
113 }
@@ -143,15 +145,17 @@
145 c.mu.Lock()
146 c.client = client
147 c.mu.Unlock()
148
149 go func() {
150 err := client.Connect()
151 if err == nil {
152 err = fmt.Errorf("connection closed")
153 }
154 select {
155 case c.errCh <- err:
156 default:
157 }
158 }()
159 }
160
161 // keepAlive watches for connection errors and redials with exponential backoff.
162

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button