本文整理汇总了Golang中github.com/twstrike/coyim/xmpp/interfaces.Conn.SendInitialStreamHeader方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.SendInitialStreamHeader方法的具体用法?Golang Conn.SendInitialStreamHeader怎么用?Golang Conn.SendInitialStreamHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/twstrike/coyim/xmpp/interfaces.Conn
的用法示例。
在下文中一共展示了Conn.SendInitialStreamHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: negotiateSASL
// SASL negotiation. RFC 6120, section 6
func (d *dialer) negotiateSASL(c interfaces.Conn) error {
user := d.getJIDLocalpart()
password := d.password
if err := c.Authenticate(user, password); err != nil {
return xe.ErrAuthenticationFailed
}
// RFC 6120, section 6.3.2. Restart the stream
err := c.SendInitialStreamHeader()
if err != nil {
return err
}
return c.BindResource()
}
示例2: negotiateSTARTTLS
// RFC 6120, section 5.4
func (d *dialer) negotiateSTARTTLS(c interfaces.Conn, conn net.Conn) error {
// RFC 6120, section 5.3
mandatoryToNegotiate := c.Features().StartTLS.Required.Local == "required"
if c.Config().SkipTLS && !mandatoryToNegotiate {
return nil
}
// Section 5.2 states:
// "Support for STARTTLS is REQUIRED in XMPP client and server implementations"
if c.Features().StartTLS.XMLName.Local == "" {
return errors.New("xmpp: server doesn't support TLS")
}
if err := d.startTLS(c, conn); err != nil {
return err
}
return c.SendInitialStreamHeader()
}
示例3: negotiateStreamFeatures
// RFC 6120, section 4.3.2
func (d *dialer) negotiateStreamFeatures(c interfaces.Conn, conn net.Conn) error {
if err := c.SendInitialStreamHeader(); err != nil {
return err
}
// STARTTLS MUST be the first feature to be negotiated
if err := d.negotiateSTARTTLS(c, conn); err != nil {
return err
}
if registered, err := d.negotiateInBandRegistration(c); err != nil || registered {
return err
}
// SASL negotiation. RFC 6120, section 6
if err := d.negotiateSASL(c); err != nil {
return err
}
//TODO: negotiate other features
return nil
}