/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2015 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
import (
"bytes"
- "encoding/binary"
"log"
"net"
"sync/atomic"
func handleTCP(conn *net.TCPConn, timeouted, rehandshaking, termination chan struct{}) {
hs := govpn.HandshakeStart(*remoteAddr, conn, conf)
- buf := make([]byte, govpn.MTU)
+ buf := make([]byte, 2*(govpn.EncLessEnlargeSize+govpn.MTU)+govpn.MTU)
var n int
var err error
var prev int
break HandshakeCycle
default:
}
- if prev == govpn.MTU {
+ if prev == len(buf) {
log.Println("Timeouted waiting for the packet")
timeouted <- struct{}{}
break HandshakeCycle
}
nonceExpectation := make([]byte, govpn.NonceSize)
- binary.BigEndian.PutUint64(nonceExpectation, peer.NonceExpect)
- peer.NonceCipher.Encrypt(nonceExpectation, nonceExpectation)
+ peer.NonceExpectation(nonceExpectation)
prev = 0
var i int
TransportCycle:
break TransportCycle
default:
}
- if prev == govpn.MTU {
+ if prev == len(buf) {
log.Println("Timeouted waiting for the packet")
timeouted <- struct{}{}
break TransportCycle
rehandshaking <- struct{}{}
break TransportCycle
}
- binary.BigEndian.PutUint64(nonceExpectation, peer.NonceExpect)
- peer.NonceCipher.Encrypt(nonceExpectation, nonceExpectation)
+ peer.NonceExpectation(nonceExpectation)
copy(buf, buf[i+govpn.NonceSize:prev])
prev = prev - i - govpn.NonceSize
goto CheckMore