[PR #4733] [CLOSED] add callback option to client service to track login state #5035

Closed
opened 2026-05-05 14:53:29 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/4733
Author: @koho
Created: 3/29/2025
Status: Closed

Base: devHead: login-state


📝 Commits (1)

  • 3ec91af add callback option to client service to track login state

📊 Changes

1 file changed (+14 additions, -0 deletions)

View changed files

📝 client/service.go (+14 -0)

📄 Description

WHY

When using frp as library, I want to check if the connection between frpc and frps is working properly.

In most cases, we can determine that by the proxy status, for example, if the login was unsuccessful, the API /api/status will respond with an empty object. However, this method is not working if no proxy is provided in the config.

It would be great if a callback function could be added to client service to allow users to track the login state. I'm not sure this single callback function is sufficient to cover common use cases. If we should do more work, I think we can add more callbacks, such as on_connect(msg.LoginResp), on_connect_fail and on_disconnect. In my opinion, since we currently don't have error codes defined in login response, the callback function on_connect(msg.LoginResp) may be replaced with on_connect(bool). As for the callback on_connect_fail, it may not be commonly used.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fatedier/frp/pull/4733 **Author:** [@koho](https://github.com/koho) **Created:** 3/29/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `login-state` --- ### 📝 Commits (1) - [`3ec91af`](https://github.com/fatedier/frp/commit/3ec91af2f3d3e62ea04d1296fb567cb39066e43c) add callback option to client service to track login state ### 📊 Changes **1 file changed** (+14 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `client/service.go` (+14 -0) </details> ### 📄 Description ### WHY When using frp as library, I want to check if the connection between frpc and frps is working properly. In most cases, we can determine that by the proxy status, for example, if the login was unsuccessful, the API `/api/status` will respond with an empty object. However, this method is not working if no proxy is provided in the config. It would be great if a callback function could be added to client service to allow users to track the login state. I'm not sure this single callback function is sufficient to cover common use cases. If we should do more work, I think we can add more callbacks, such as `on_connect(msg.LoginResp)`, `on_connect_fail` and `on_disconnect`. In my opinion, since we currently don't have error codes defined in login response, the callback function `on_connect(msg.LoginResp)` may be replaced with `on_connect(bool)`. As for the callback `on_connect_fail`, it may not be commonly used. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:53:29 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#5035
No description provided.