mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-23 05:49:07 +02:00
Add logs
This commit is contained in:
@@ -196,6 +196,11 @@ type Client struct {
|
|||||||
// Transport returns the negotiated relay transport of the current connection,
|
// Transport returns the negotiated relay transport of the current connection,
|
||||||
// or an empty string when not connected.
|
// or an empty string when not connected.
|
||||||
func (c *Client) Transport() string {
|
func (c *Client) Transport() string {
|
||||||
|
c.log.Warnf("start to call Transport")
|
||||||
|
defer func() {
|
||||||
|
c.log.Warnf("end of call Transport")
|
||||||
|
}()
|
||||||
|
c.log.Warnf("query Transport:")
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
return c.transport
|
return c.transport
|
||||||
@@ -244,6 +249,7 @@ func NewClientWithServerIP(serverURL string, serverIP netip.Addr, authTokenStore
|
|||||||
// Connect establishes a connection to the relay server. It blocks until the connection is established or an error occurs.
|
// Connect establishes a connection to the relay server. It blocks until the connection is established or an error occurs.
|
||||||
func (c *Client) Connect(ctx context.Context) error {
|
func (c *Client) Connect(ctx context.Context) error {
|
||||||
c.log.Infof("connecting to relay server")
|
c.log.Infof("connecting to relay server")
|
||||||
|
defer c.log.Warnf("end of call Connect to relay server")
|
||||||
c.readLoopMutex.Lock()
|
c.readLoopMutex.Lock()
|
||||||
defer c.readLoopMutex.Unlock()
|
defer c.readLoopMutex.Unlock()
|
||||||
|
|
||||||
@@ -286,6 +292,8 @@ func (c *Client) Connect(ctx context.Context) error {
|
|||||||
// todo: what should happen if call with the same peerID with multiple times?
|
// todo: what should happen if call with the same peerID with multiple times?
|
||||||
func (c *Client) OpenConn(ctx context.Context, dstPeerID string) (net.Conn, error) {
|
func (c *Client) OpenConn(ctx context.Context, dstPeerID string) (net.Conn, error) {
|
||||||
peerID := messages.HashID(dstPeerID)
|
peerID := messages.HashID(dstPeerID)
|
||||||
|
c.log.Infof("open conn to peer: %v", dstPeerID)
|
||||||
|
defer c.log.Warnf("end of OpenConn to peer: %v", dstPeerID)
|
||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
if !c.serviceIsRunning {
|
if !c.serviceIsRunning {
|
||||||
@@ -354,6 +362,9 @@ func (c *Client) ServerInstanceURL() (string, error) {
|
|||||||
// extracted from the underlying socket's RemoteAddr. Zero value if not
|
// extracted from the underlying socket's RemoteAddr. Zero value if not
|
||||||
// connected or if the address is not an IP literal.
|
// connected or if the address is not an IP literal.
|
||||||
func (c *Client) ConnectedIP() netip.Addr {
|
func (c *Client) ConnectedIP() netip.Addr {
|
||||||
|
c.log.Infof("run ConnectedIP")
|
||||||
|
defer c.log.Warnf("end of Connected IP")
|
||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
conn := c.relayConn
|
conn := c.relayConn
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
@@ -376,6 +387,8 @@ func (c *Client) SetOnDisconnectListener(fn func(string)) {
|
|||||||
|
|
||||||
// HasConns returns true if there are connections.
|
// HasConns returns true if there are connections.
|
||||||
func (c *Client) HasConns() bool {
|
func (c *Client) HasConns() bool {
|
||||||
|
c.log.Infof("run HasConns")
|
||||||
|
defer c.log.Warnf("end of HasConns")
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
return len(c.conns) > 0
|
return len(c.conns) > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user