'fixtlsbug'

This commit is contained in:
chowyu08
2017-09-06 20:55:54 +08:00
parent 417a12174c
commit 47c44570fc
+8 -11
View File
@@ -96,19 +96,21 @@ func (b *Broker) wsHandler(ws *websocket.Conn) {
go b.handleConnection(CLIENT, ws, b.cid) go b.handleConnection(CLIENT, ws, b.cid)
} }
func (b *Broker) StartClientListening(tls bool) { func (b *Broker) StartClientListening(Tls bool) {
var hp string var hp string
if tls { var err error
var l net.Listener
if Tls {
hp = b.config.TlsHost + ":" + b.config.TlsPort hp = b.config.TlsHost + ":" + b.config.TlsPort
l, err = tls.Listen("tcp", hp, b.tlsConfig)
log.Info("Start TLS Listening client on ", hp) log.Info("Start TLS Listening client on ", hp)
} else { } else {
hp := b.config.Host + ":" + b.config.Port hp := b.config.Host + ":" + b.config.Port
l, err = net.Listen("tcp", hp)
log.Info("Start Listening client on ", hp) log.Info("Start Listening client on ", hp)
} }
if err != nil {
l, e := net.Listen("tcp", hp) log.Error("Error listening on ", err)
if e != nil {
log.Error("Error listening on ", e)
return return
} }
tmpDelay := 10 * ACCEPT_MIN_SLEEP tmpDelay := 10 * ACCEPT_MIN_SLEEP
@@ -129,11 +131,6 @@ func (b *Broker) StartClientListening(tls bool) {
continue continue
} }
tmpDelay = ACCEPT_MIN_SLEEP tmpDelay = ACCEPT_MIN_SLEEP
if tls {
if !b.Handshake(conn) {
return
}
}
atomic.AddUint64(&b.cid, 1) atomic.AddUint64(&b.cid, 1)
go b.handleConnection(CLIENT, conn, b.cid) go b.handleConnection(CLIENT, conn, b.cid)