mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
try fix
This commit is contained in:
parent
a6b33fe046
commit
4e3138e099
1 changed files with 7 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -128,12 +129,12 @@ func clientCommuncation(port string, c *comm.Comm) (err error) {
|
||||||
// Read()s from the socket to the channel.
|
// Read()s from the socket to the channel.
|
||||||
func chanFromConn(conn net.Conn) chan []byte {
|
func chanFromConn(conn net.Conn) chan []byte {
|
||||||
c := make(chan []byte)
|
c := make(chan []byte)
|
||||||
// reader := bufio.NewReader(conn)
|
reader := bufio.NewReader(conn)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
b := make([]byte, models.TCP_BUFFER_SIZE)
|
b := make([]byte, models.TCP_BUFFER_SIZE)
|
||||||
n, err := conn.Read(b)
|
n, err := reader.Read(b)
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
// c <- b[:n]
|
// c <- b[:n]
|
||||||
res := make([]byte, n)
|
res := make([]byte, n)
|
||||||
|
@ -157,16 +158,16 @@ func pipe(conn1 net.Conn, conn2 net.Conn) {
|
||||||
chan1 := chanFromConn(conn1)
|
chan1 := chanFromConn(conn1)
|
||||||
// chan2 := chanFromConn(conn2)
|
// chan2 := chanFromConn(conn2)
|
||||||
// writer1 := bufio.NewWriter(conn1)
|
// writer1 := bufio.NewWriter(conn1)
|
||||||
// writer2 := bufio.NewWriter(conn2)
|
writer2 := bufio.NewWriter(conn2)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
b1 := <-chan1
|
b1 := <-chan1
|
||||||
if b1 == nil {
|
if b1 == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conn2.Write(b1)
|
// conn2.Write(b1)
|
||||||
// writer2.Write(b1)
|
writer2.Write(b1)
|
||||||
// writer2.Flush()
|
writer2.Flush()
|
||||||
|
|
||||||
// case b2 := <-chan2:
|
// case b2 := <-chan2:
|
||||||
// if b2 == nil {
|
// if b2 == nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue