This commit is contained in:
jdl
2024-12-13 21:30:06 +01:00
parent d9233af4c9
commit 6fcd8637a3
16 changed files with 191 additions and 364 deletions

View File

@@ -8,17 +8,15 @@ import (
)
type Peer struct {
ip byte // Last byte of IPv4 address.
hubAddr string
apiKey string
isServer bool
isMediator bool
encPubKey []byte
encPrivKey []byte
signPubKey []byte
signPrivKey []byte
conn *net.UDPConn
iface io.ReadWriteCloser
ip byte // Last byte of IPv4 address.
hubAddr string
apiKey string
isServer bool
isMediator bool
encPubKey []byte
encPrivKey []byte
conn *net.UDPConn
iface io.ReadWriteCloser
router *Router
}
@@ -30,14 +28,12 @@ func NewPeer(netName, listenIP string, port uint16) (*Peer, error) {
}
peer := &Peer{
ip: conf.PeerIP,
hubAddr: conf.HubAddress,
isMediator: conf.Mediator,
apiKey: conf.APIKey,
encPubKey: conf.EncPubKey,
encPrivKey: conf.EncPrivKey,
signPubKey: conf.SignPubKey,
signPrivKey: conf.SignPrivKey,
ip: conf.PeerIP,
hubAddr: conf.HubAddress,
isMediator: conf.Mediator,
apiKey: conf.APIKey,
encPubKey: conf.EncPubKey,
encPrivKey: conf.EncPrivKey,
}
_, peer.isServer = netip.AddrFromSlice(conf.PublicIP)