go-xmpp/transport.go

36 lines
822 B
Go
Raw Normal View History

2019-10-06 10:37:56 -07:00
package xmpp
import (
"crypto/tls"
2019-10-10 22:15:47 -07:00
"errors"
2019-10-06 10:37:56 -07:00
)
2019-10-10 22:15:47 -07:00
var TLSNotSupported = errors.New("Transport does not support StartTLS")
type TransportConfiguration struct {
// Address is the XMPP Host and port to connect to. Host is of
// the form 'serverhost:port' i.e "localhost:8888"
Address string
ConnectTimeout int // Client timeout in seconds. Default to 15
// tls.Config must not be modified after having been passed to NewClient. Any
// changes made after connecting are ignored.
TLSConfig *tls.Config
}
2019-10-06 10:37:56 -07:00
type Transport interface {
Connect() error
2019-10-06 10:37:56 -07:00
DoesStartTLS() bool
StartTLS(domain string) error
2019-10-06 10:37:56 -07:00
2019-10-10 22:15:47 -07:00
IsSecure() bool
2019-10-06 10:37:56 -07:00
Read(p []byte) (n int, err error)
Write(p []byte) (n int, err error)
Close() error
}
func NewTransport(config TransportConfiguration) Transport {
return &XMPPTransport{Config: config}
}