update
This commit is contained in:
@ -70,8 +70,66 @@ func handler(conn net.Conn, targetAddress string, fakeAddress string) {
|
||||
}
|
||||
|
||||
p := &PackAppData{Conn: conn}
|
||||
go io.Copy(realConnection, p)
|
||||
go io.Copy(p, realConnection)
|
||||
|
||||
defer p.Close()
|
||||
defer realConnection.Close()
|
||||
exit := make(chan int, 1)
|
||||
|
||||
go MyCopy(p, realConnection, exit)
|
||||
go MyCopy(realConnection, p, exit)
|
||||
<-exit
|
||||
|
||||
//go func() {
|
||||
// buf := make([]byte, 64*1024)
|
||||
// for {
|
||||
// nr, er := realConnection.Read(buf)
|
||||
// if er != nil {
|
||||
// if er == io.EOF {
|
||||
// continue
|
||||
// } else {
|
||||
// fmt.Println("read err:", er)
|
||||
// break
|
||||
// }
|
||||
// } else {
|
||||
// lenNum := make([]byte, 2)
|
||||
// binary.BigEndian.PutUint16(lenNum, uint16(nr))
|
||||
//
|
||||
// packetBuf := bytes.NewBuffer(AppDataHeader)
|
||||
// packetBuf.Write(lenNum)
|
||||
// packetBuf.Write(buf[0:nr])
|
||||
//
|
||||
// _, ew := conn.Write(packetBuf.Bytes())
|
||||
// if ew != nil {
|
||||
// fmt.Printf("err2:%v\n", ew)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}()
|
||||
//
|
||||
//go func() {
|
||||
// result := bytes.NewBuffer(nil)
|
||||
// var buf [65542]byte // 由于 标识数据包长度 的只有两个字节 故数据包最大为 2^16+4(魔数)+2(长度标识)
|
||||
// for {
|
||||
// n, er := conn.Read(buf[0:])
|
||||
// result.Write(buf[0:n])
|
||||
// if er != nil {
|
||||
// if er == io.EOF {
|
||||
// continue
|
||||
// } else {
|
||||
// fmt.Println("read err:", er)
|
||||
// break
|
||||
// }
|
||||
// } else {
|
||||
// scanner := bufio.NewScanner(result)
|
||||
// scanner.Split(packetSlitFunc)
|
||||
// for scanner.Scan() {
|
||||
// realConnection.Write(scanner.Bytes()[HeaderLength+2:])
|
||||
// }
|
||||
// }
|
||||
// result.Reset()
|
||||
// }
|
||||
//}()
|
||||
}
|
||||
|
||||
func processHandshake(src net.Conn, dst net.Conn, waitCh chan int) {
|
||||
|
Reference in New Issue
Block a user