mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
link/stream refactoring bugfixes and gofmt
This commit is contained in:
parent
41a410f2a1
commit
c8e1be0f73
4 changed files with 28 additions and 30 deletions
|
@ -378,9 +378,6 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
|
|||
// E.g. over different interfaces
|
||||
p := iface.core.peers.newPeer(&meta.box, &meta.sig, crypto.GetSharedKey(myLinkPriv, &meta.link), sock.RemoteAddr().String())
|
||||
p.linkOut = make(chan []byte, 1)
|
||||
in := func(bs []byte) {
|
||||
p.handlePacket(bs)
|
||||
}
|
||||
out := make(chan []byte, 1)
|
||||
defer close(out)
|
||||
go func() {
|
||||
|
@ -443,7 +440,7 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
|
|||
themAddrString := net.IP(themAddr[:]).String()
|
||||
themString := fmt.Sprintf("%s@%s", themAddrString, them)
|
||||
iface.core.log.Printf("Connected: %s, source: %s", themString, us)
|
||||
iface.stream.init()
|
||||
iface.stream.init(p.handlePacket)
|
||||
bs := make([]byte, 2*streamMsgSize)
|
||||
var n int
|
||||
for {
|
||||
|
@ -455,7 +452,7 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) {
|
|||
break
|
||||
}
|
||||
if n > 0 {
|
||||
iface.stream.write(bs[:n], in)
|
||||
iface.stream.handleInput(bs[:n])
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue