stream.go
changeset 22 d6b7b4cbf50d
parent 21 8f6ae5cfc9b9
child 23 b5de44679389
equal deleted inserted replaced
21:8f6ae5cfc9b9 22:d6b7b4cbf50d
   200 		case h := <- cl.handlers:
   200 		case h := <- cl.handlers:
   201 			handlers[h.id] = h.f
   201 			handlers[h.id] = h.f
   202 		case x := <- srvIn:
   202 		case x := <- srvIn:
   203 			send := false
   203 			send := false
   204 			switch obj := x.(type) {
   204 			switch obj := x.(type) {
   205 			case *Stream:
   205 			case *stream:
   206 				handleStream(obj)
   206 				handleStream(obj)
   207 			case *Features:
   207 			case *Features:
   208 				cl.handleFeatures(obj)
   208 				cl.handleFeatures(obj)
   209 			case *starttls:
   209 			case *starttls:
   210 				cl.handleTls(obj)
   210 				cl.handleTls(obj)
   235 	for x := range cliIn {
   235 	for x := range cliIn {
   236 		srvOut <- x
   236 		srvOut <- x
   237 	}
   237 	}
   238 }
   238 }
   239 
   239 
   240 func handleStream(ss *Stream) {
   240 func handleStream(ss *stream) {
   241 }
   241 }
   242 
   242 
   243 func (cl *Client) handleFeatures(fe *Features) {
   243 func (cl *Client) handleFeatures(fe *Features) {
   244 	if fe.Starttls != nil {
   244 	if fe.Starttls != nil {
   245 		start := &starttls{XMLName: xml.Name{Space: nsTLS,
   245 		start := &starttls{XMLName: xml.Name{Space: nsTLS,
   286 
   286 
   287 	log.Println("TLS negotiation succeeded.")
   287 	log.Println("TLS negotiation succeeded.")
   288 
   288 
   289 	// Now re-send the initial handshake message to start the new
   289 	// Now re-send the initial handshake message to start the new
   290 	// session.
   290 	// session.
   291 	hsOut := &Stream{To: cl.Jid.Domain, Version: Version}
   291 	hsOut := &stream{To: cl.Jid.Domain, Version: Version}
   292 	cl.xmlOut <- hsOut
   292 	cl.xmlOut <- hsOut
   293 }
   293 }
   294 
   294 
   295 // Synchronize with handleTls(). Called from readTransport() when
   295 // Synchronize with handleTls(). Called from readTransport() when
   296 // cl.socket is nil.
   296 // cl.socket is nil.
   343 		}
   343 		}
   344 	case "failure":
   344 	case "failure":
   345 		log.Println("SASL authentication failed")
   345 		log.Println("SASL authentication failed")
   346 	case "success":
   346 	case "success":
   347 		log.Println("SASL authentication succeeded")
   347 		log.Println("SASL authentication succeeded")
   348 		ss := &Stream{To: cl.Jid.Domain, Version: Version}
   348 		ss := &stream{To: cl.Jid.Domain, Version: Version}
   349 		cl.xmlOut <- ss
   349 		cl.xmlOut <- ss
   350 	}
   350 	}
   351 }
   351 }
   352 
   352 
   353 func (cl *Client) saslDigest1(srvMap map[string] string) {
   353 func (cl *Client) saslDigest1(srvMap map[string] string) {