mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 11:21:04 +01:00
34 lines
489 B
Go
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
|
|
}
|