copy/paste old flowkey logic into a util function, add a struct of key and packet, make WriteNoCopy accept this instead of a slice

This commit is contained in:
Arceliar 2019-08-06 19:25:55 -05:00
parent 6cb0ed91ad
commit 790524bd1c
5 changed files with 105 additions and 52 deletions

View file

@ -96,8 +96,11 @@ func (s *tunConn) writer() error {
if !ok {
return errors.New("send closed")
}
// TODO write timeout and close
if err := s.conn.WriteNoCopy(bs); err != nil {
msg := yggdrasil.FlowKeyMessage{
FlowKey: util.GetFlowKey(bs),
Message: bs,
}
if err := s.conn.WriteNoCopy(msg); err != nil {
if e, eok := err.(yggdrasil.ConnError); !eok {
if e.Closed() {
s.tun.log.Debugln(s.conn.String(), "TUN/TAP generic write debug:", err)