mirror of https://gogs.blitter.com/RLabs/xs
Server tun worker now in redial goroutine. TODO: Finish full two-way state change msging
This commit is contained in:
parent
1a153b31ee
commit
dd37922fb2
|
@ -140,17 +140,18 @@ func (hc *Conn) StartClientTunnel(lport, rport uint16) {
|
|||
func (hc *Conn) StartServerTunnel(lport, rport uint16) {
|
||||
hc.InitTunEndpoint(lport, "", rport)
|
||||
t := hc.tuns[rport] // for convenience
|
||||
var err error
|
||||
|
||||
//go func() {
|
||||
// for cmd := range t.Ctl {
|
||||
// var c net.Conn
|
||||
// if cmd == 'a' {
|
||||
go func() {
|
||||
for cmd := range t.Ctl {
|
||||
var c net.Conn
|
||||
if cmd == 'a' {
|
||||
logger.LogDebug("Server dialling...")
|
||||
c, err := net.Dial("tcp", fmt.Sprintf(":%d", rport))
|
||||
c, err = net.Dial("tcp", fmt.Sprintf(":%d", rport))
|
||||
if err != nil {
|
||||
logger.LogDebug(fmt.Sprintf("Nothing is serving at rport :%d!", rport))
|
||||
var resp bytes.Buffer
|
||||
binary.Write(&resp, binary.BigEndian, /*lport*/uint16(0))
|
||||
binary.Write(&resp, binary.BigEndian /*lport*/, uint16(0))
|
||||
binary.Write(&resp, binary.BigEndian, rport)
|
||||
hc.WritePacket(resp.Bytes(), CSOTunRefused)
|
||||
} else {
|
||||
|
@ -213,13 +214,8 @@ func (hc *Conn) StartServerTunnel(lport, rport uint16) {
|
|||
}
|
||||
}()
|
||||
}
|
||||
// } else if cmd == 'h' {
|
||||
// logger.LogDebug("[Server hanging up on rport on behalf of client]")
|
||||
// c.Close()
|
||||
// } else {
|
||||
// logger.LogDebug("[ERR: this should be unreachable]")
|
||||
// }
|
||||
// } // t.Ctl read loop
|
||||
// logger.LogDebug("[ServerTunnel() exiting t.Ctl read loop - channel closed??]")
|
||||
//}()
|
||||
} // TODO: elseifs for other state transtions driven by client
|
||||
}
|
||||
}() // t.Ctl read loop
|
||||
logger.LogDebug("[ServerTunnel() exiting t.Ctl read loop - channel closed??]")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue