Merge pull request #32 from hoffoo/master

TLSConfig in Options
This commit is contained in:
mattn 2014-09-17 12:26:31 +09:00
commit aa27e3ee45

10
xmpp.go
View File

@ -123,6 +123,9 @@ type Options struct {
// from the server. Use "" to let the server generate one for your client. // from the server. Use "" to let the server generate one for your client.
Resource string Resource string
// TLS Config
TLSConfig *tls.Config
// NoTLS disables TLS and specifies that a plain old unencrypted TCP connection should // NoTLS disables TLS and specifies that a plain old unencrypted TCP connection should
// be used. // be used.
NoTLS bool NoTLS bool
@ -146,7 +149,12 @@ func (o Options) NewClient() (*Client, error) {
if o.NoTLS { if o.NoTLS {
client.conn = c client.conn = c
} else { } else {
tlsconn := tls.Client(c, &DefaultConfig) var tlsconn *tls.Conn
if o.TLSConfig != nil {
tlsconn = tls.Client(c, o.TLSConfig)
} else {
tlsconn = tls.Client(c, &DefaultConfig)
}
if err = tlsconn.Handshake(); err != nil { if err = tlsconn.Handshake(); err != nil {
return nil, err return nil, err
} }