1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-28 14:50:26 +08:00

feat: impl. new protol design & new head

This commit is contained in:
源文雨
2025-03-12 22:20:02 +09:00
parent 60209117b7
commit f4fd9b1423
49 changed files with 1643 additions and 1137 deletions

View File

@@ -4,10 +4,9 @@ import (
"net"
"time"
"github.com/fumiama/WireGold/gold/head"
"github.com/fumiama/WireGold/gold/p2p"
"github.com/fumiama/WireGold/internal/algo"
curve "github.com/fumiama/go-x25519"
"github.com/fumiama/orbyte"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/chacha20poly1305"
)
@@ -50,7 +49,7 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
}
if !cfg.NoPipe {
l.pipe = make(chan *orbyte.Item[head.Packet], 65536)
l.pipe = make(chan LinkData, 4096)
}
var k, p []byte
if cfg.PubicKey != nil {
@@ -62,7 +61,7 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
if len(k) == 32 {
var err error
if len(p) == 32 {
mixk := mixkeys(k, p)
mixk := algo.MixKeys(k, p)
for i := range k {
l.keys[i], err = chacha20poly1305.NewX(mixk[i : i+32])
if err != nil {
@@ -113,7 +112,7 @@ func (m *Me) AddPeer(cfg *PeerConfig) (l *Link) {
}
logrus.Infoln("[peer] add peer:", cfg.PeerIP, "allow:", cfg.AllowedIPs)
go l.keepAlive(cfg.KeepAliveDur)
go l.sendquery(time.Second*time.Duration(cfg.QueryTick), cfg.Querys...)
go l.sendQuery(time.Second*time.Duration(cfg.QueryTick), cfg.Querys...)
return
}