|
@@ -175,20 +175,18 @@ func PipeDecryptoReader(r net.Conn, w net.Conn, key string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- log.Debug("PipeDecryptoReader")
|
|
|
-
|
|
|
- buf := make([]byte, 10*1024)
|
|
|
+ nreader := bufio.NewReader(r)
|
|
|
|
|
|
for {
|
|
|
- n, err := r.Read(buf)
|
|
|
+ buf, err := nreader.ReadBytes('\n')
|
|
|
if err != nil {
|
|
|
- log.Error("Conn ReadLine error, [%v]", err)
|
|
|
+ log.Error("Conn ReadBytes error, [%v]", err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- res, err := laes.Decrypto(buf[:n])
|
|
|
+ res, err := laes.Decrypto(buf)
|
|
|
if err != nil {
|
|
|
- log.Error("Decrypto error, [%s] [%s]", err, string(buf[:n]))
|
|
|
+ log.Error("Decrypto error, [%s] [%s]", err, string(buf))
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -211,12 +209,11 @@ func PipeEncryptoWriter(r net.Conn, w net.Conn, key string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- log.Debug("PipeEncryptoWriter")
|
|
|
-
|
|
|
+ nreader := bufio.NewReader(r)
|
|
|
buf := make([]byte, 10*1024)
|
|
|
|
|
|
for {
|
|
|
- n, err := r.Read(buf)
|
|
|
+ n, err := nreader.Read(buf)
|
|
|
if err != nil {
|
|
|
log.Error("Conn ReadLine error, [%v]", err)
|
|
|
return
|
|
@@ -227,6 +224,7 @@ func PipeEncryptoWriter(r net.Conn, w net.Conn, key string) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ res = append(res, '\n')
|
|
|
_, err = w.Write(res)
|
|
|
if err != nil {
|
|
|
log.Error("net.Conn Write error, [%v]", err)
|