two-way tunnel traffic working. Hangup/re-dial on server side needs work

This commit is contained in:
Russ Magee 2018-10-28 21:46:29 -07:00
parent 632f24354b
commit e75ed159f6
1 changed files with 9 additions and 2 deletions

View File

@ -798,12 +798,19 @@ func (hc Conn) Read(b []byte) (n int, err error) {
lport := binary.BigEndian.Uint16(payloadBytes) lport := binary.BigEndian.Uint16(payloadBytes)
rport := binary.BigEndian.Uint16(payloadBytes[2:4]) rport := binary.BigEndian.Uint16(payloadBytes[2:4])
fmt.Printf("[Got CSOTunData: [lport %d:rport %d] data:%v\n", lport, rport, payloadBytes[4:]) fmt.Printf("[Got CSOTunData: [lport %d:rport %d] data:%v\n", lport, rport, payloadBytes[4:])
if hc.tuns[rport] == nil {
fmt.Printf("[Invalid rport:%d]\n", rport)
} else {
hc.tuns[rport] <- payloadBytes[4:] hc.tuns[rport] <- payloadBytes[4:]
}
fmt.Printf("[Done stuffing hc.tuns[rport]\n")
} else if ctrlStatOp == CSOTunClose { } else if ctrlStatOp == CSOTunClose {
lport := binary.BigEndian.Uint16(payloadBytes) lport := binary.BigEndian.Uint16(payloadBytes)
rport := binary.BigEndian.Uint16(payloadBytes[2:4]) rport := binary.BigEndian.Uint16(payloadBytes[2:4])
fmt.Printf("[Got CSOTunClose: [lport %d:rport %d]\n", lport, rport) fmt.Printf("[Got CSOTunClose: [lport %d:rport %d]\n", lport, rport)
hc.tuns[rport] = nil if hc.tuns[rport] != nil {
close(hc.tuns[rport])
}
} else { } else {
hc.dBuf.Write(payloadBytes) hc.dBuf.Write(payloadBytes)
//log.Printf("hc.dBuf: %s\n", hex.Dump(hc.dBuf.Bytes())) //log.Printf("hc.dBuf: %s\n", hex.Dump(hc.dBuf.Bytes()))