netbird/relay/server/peer.go
2024-05-26 22:14:33 +02:00

34 lines
489 B
Go

package server
import (
"net"
log "github.com/sirupsen/logrus"
"github.com/netbirdio/netbird/relay/messages"
)
type Peer struct {
Log *log.Entry
idS string
idB []byte
conn net.Conn
}
func NewPeer(id []byte, conn net.Conn) *Peer {
stringID := messages.HashIDToString(id)
return &Peer{
Log: log.WithField("peer_id", stringID),
idB: id,
idS: stringID,
conn: conn,
}
}
func (p *Peer) ID() []byte {
return p.idB
}
func (p *Peer) String() string {
return p.idS
}