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) {
|
func (hc *Conn) StartServerTunnel(lport, rport uint16) {
|
||||||
hc.InitTunEndpoint(lport, "", rport)
|
hc.InitTunEndpoint(lport, "", rport)
|
||||||
t := hc.tuns[rport] // for convenience
|
t := hc.tuns[rport] // for convenience
|
||||||
|
var err error
|
||||||
|
|
||||||
//go func() {
|
go func() {
|
||||||
// for cmd := range t.Ctl {
|
for cmd := range t.Ctl {
|
||||||
// var c net.Conn
|
var c net.Conn
|
||||||
// if cmd == 'a' {
|
if cmd == 'a' {
|
||||||
logger.LogDebug("Server dialling...")
|
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 {
|
if err != nil {
|
||||||
logger.LogDebug(fmt.Sprintf("Nothing is serving at rport :%d!", rport))
|
logger.LogDebug(fmt.Sprintf("Nothing is serving at rport :%d!", rport))
|
||||||
var resp bytes.Buffer
|
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)
|
binary.Write(&resp, binary.BigEndian, rport)
|
||||||
hc.WritePacket(resp.Bytes(), CSOTunRefused)
|
hc.WritePacket(resp.Bytes(), CSOTunRefused)
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,13 +214,8 @@ func (hc *Conn) StartServerTunnel(lport, rport uint16) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
// } else if cmd == 'h' {
|
} // TODO: elseifs for other state transtions driven by client
|
||||||
// logger.LogDebug("[Server hanging up on rport on behalf of client]")
|
}
|
||||||
// c.Close()
|
}() // t.Ctl read loop
|
||||||
// } else {
|
logger.LogDebug("[ServerTunnel() exiting t.Ctl read loop - channel closed??]")
|
||||||
// logger.LogDebug("[ERR: this should be unreachable]")
|
|
||||||
// }
|
|
||||||
// } // t.Ctl read loop
|
|
||||||
// logger.LogDebug("[ServerTunnel() exiting t.Ctl read loop - channel closed??]")
|
|
||||||
//}()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue