Files
OpenFlux/ipc_handler.go
T
damnurmum 7c37115a11 manager: relay the exit's captcha and login checks to the client
A transport on the exit that hit SmartCaptcha or a login wall could only
report it to a local IPC socket on the exit host, where normally no app
is listening, so the exit's side of that carrier stayed down for good.
main.go also only wired the notifier for the first cookie spec and
ignored the name and URL the transport reported.

The exit now also sends a new AuthRequired control message to the client
(rate-limited per transport, retried on the transport's next report if no
client is connected yet). It travels over whichever carrier still reaches
the peer, e.g. direct while the document carrier is the one that is
stuck. The client surfaces it to the app as an IPC CookiesRequest marked
Remote; the app answers with a CookiesOffer marked Remote, which the
client forwards to the exit as a CookiesOffer naming the transport, and
the exit applies and persists it. The client's own checks stay local.
Local notifications now carry the reporting transport's name and URL.

The check has to be passed from the exit's address; the next commit
gives the app a way to browse through the tunnel for that.
2026-09-24 23:52:26 +03:00

45 lines
1.4 KiB
Go

package main
import (
"openflux/transport/ipc"
"openflux/transport/manager"
"openflux/utils"
)
// coreIPCHandler is the app-facing side of the IPC bridge.
//
// It receives commands and cookies from the mobile app and forwards them
// to the manager. When the core needs fresh cookies (SmartCaptcha), the
// manager calls SetCaptchaNotifier, whose callback fires into IPC.
type coreIPCHandler struct {
manager *manager.Manager
}
func (h *coreIPCHandler) OnConnect() { utils.Debugf("[IPC] app connected") }
func (h *coreIPCHandler) OnDisconnect() { utils.Debugf("[IPC] app disconnected") }
func (h *coreIPCHandler) OnCommand(p *ipc.CommandPayload) {
utils.Debugf("[IPC] command action=%q params=%v", p.Action, p.Params)
// No dynamic commands yet. Reserved for start/stop/restart from the UI.
}
func (h *coreIPCHandler) OnCookies(p *ipc.CookiesOfferPayload) {
if p == nil || p.Transport == "" || len(p.Jar) == 0 {
utils.Debugf("[IPC] empty cookies offer, ignoring")
return
}
if p.Remote {
if err := h.manager.OfferCookies(p.Transport, p.Jar); err != nil {
utils.Debugf("[IPC] offer cookies to exit for %q: %v", p.Transport, err)
return
}
utils.Debugf("[IPC] sent %d cookies to exit for %q", len(p.Jar), p.Transport)
return
}
if err := h.manager.AcceptCookies(p.Transport, p.Jar); err != nil {
utils.Debugf("[IPC] apply cookies for %q: %v", p.Transport, err)
return
}
utils.Debugf("[IPC] applied %d cookies for %q", len(p.Jar), p.Transport)
}