Refactor error handling in publisher.go, comment redundant logging in acl/follows.go, and improve error handling for connection rejections (403).
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
"next.orly.dev/pkg/encoders/kind"
|
||||
"next.orly.dev/pkg/interfaces/publisher"
|
||||
"next.orly.dev/pkg/interfaces/typer"
|
||||
utils "next.orly.dev/pkg/utils"
|
||||
"next.orly.dev/pkg/utils"
|
||||
)
|
||||
|
||||
const Type = "socketapi"
|
||||
@@ -229,7 +229,7 @@ func (p *P) Deliver(ev *event.E) {
|
||||
|
||||
if err = d.w.Write(
|
||||
writeCtx, websocket.MessageText, res.Marshal(nil),
|
||||
); chk.E(err) {
|
||||
); err != nil {
|
||||
// On error, remove the subscriber connection safely
|
||||
p.removeSubscriber(d.w)
|
||||
_ = d.w.CloseNow()
|
||||
|
||||
@@ -79,7 +79,7 @@ func (f *Follows) Configure(cfg ...any) (err error) {
|
||||
} else {
|
||||
adm = a
|
||||
}
|
||||
log.I.F("admin: %0x", adm)
|
||||
// log.I.F("admin: %0x", adm)
|
||||
f.admins = append(f.admins, adm)
|
||||
fl := &filter.F{
|
||||
Authors: tag.NewFromAny(adm),
|
||||
@@ -229,6 +229,15 @@ func (f *Follows) startSubscriptions(ctx context.Context) {
|
||||
c, _, err := websocket.Dial(ctx, u, nil)
|
||||
if err != nil {
|
||||
log.W.F("follows syncer: dial %s failed: %v", u, err)
|
||||
if strings.Contains(
|
||||
err.Error(), "response status code 101 but got 403",
|
||||
) {
|
||||
// 403 means the relay is not accepting connections from
|
||||
// us. Forbidden is the meaning, usually used to
|
||||
// indicate either the IP or user is blocked. so stop
|
||||
// trying this one.
|
||||
return
|
||||
}
|
||||
timer := time.NewTimer(backoff)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -300,10 +309,10 @@ func (f *Follows) startSubscriptions(ctx context.Context) {
|
||||
if f.pubs != nil {
|
||||
go f.pubs.Deliver(res.Event)
|
||||
}
|
||||
log.I.F(
|
||||
"saved new event from follows syncer: %0x",
|
||||
res.Event.ID,
|
||||
)
|
||||
// log.I.F(
|
||||
// "saved new event from follows syncer: %0x",
|
||||
// res.Event.ID,
|
||||
// )
|
||||
}
|
||||
case eoseenvelope.L:
|
||||
// ignore, continue subscription
|
||||
|
||||
Reference in New Issue
Block a user