Comments clean-up

This commit is contained in:
Mickael Remond 2019-11-04 12:58:10 +01:00
parent 0227596f90
commit 1d7db9ceee
No known key found for this signature in database
GPG key ID: E6F6045D79965AA3
3 changed files with 12 additions and 11 deletions

View file

@ -4,9 +4,9 @@ import (
"os" "os"
) )
type Config struct { // Config & TransportConfiguration must not be modified after having been passed to NewClient. Any
// TransportConfiguration must not be modified after having been passed to NewClient. Any
// changes made after connecting are ignored. // changes made after connecting are ignored.
type Config struct {
TransportConfiguration TransportConfiguration
Jid string Jid string

View file

@ -19,21 +19,21 @@ func newStreamLogger(conn io.ReadWriter, logFile io.Writer) io.ReadWriter {
} }
} }
func (sp *streamLogger) Read(p []byte) (n int, err error) { func (sl *streamLogger) Read(p []byte) (n int, err error) {
n, err = sp.socket.Read(p) n, err = sl.socket.Read(p)
if n > 0 { if n > 0 {
sp.logFile.Write([]byte("RECV:\n")) // Prefix sl.logFile.Write([]byte("RECV:\n")) // Prefix
if n, err := sp.logFile.Write(p[:n]); err != nil { if n, err := sl.logFile.Write(p[:n]); err != nil {
return n, err return n, err
} }
sp.logFile.Write([]byte("\n\n")) // Separator sl.logFile.Write([]byte("\n\n")) // Separator
} }
return return
} }
func (sp *streamLogger) Write(p []byte) (n int, err error) { func (sl *streamLogger) Write(p []byte) (n int, err error) {
sp.logFile.Write([]byte("SEND:\n")) // Prefix sl.logFile.Write([]byte("SEND:\n")) // Prefix
for _, w := range []io.Writer{sp.socket, sp.logFile} { for _, w := range []io.Writer{sl.socket, sl.logFile} {
n, err = w.Write(p) n, err = w.Write(p)
if err != nil { if err != nil {
return return
@ -43,7 +43,7 @@ func (sp *streamLogger) Write(p []byte) (n int, err error) {
return return
} }
} }
sp.logFile.Write([]byte("\n\n")) // Separator sl.logFile.Write([]byte("\n\n")) // Separator
return len(p), nil return len(p), nil
} }

View file

@ -12,6 +12,7 @@ import (
var ErrTransportProtocolNotSupported = errors.New("Transport protocol not supported") var ErrTransportProtocolNotSupported = errors.New("Transport protocol not supported")
var ErrTLSNotSupported = errors.New("Transport does not support StartTLS") var ErrTLSNotSupported = errors.New("Transport does not support StartTLS")
// TODO: rename to transport config?
type TransportConfiguration struct { type TransportConfiguration struct {
// Address is the XMPP Host and port to connect to. Host is of // Address is the XMPP Host and port to connect to. Host is of
// the form 'serverhost:port' i.e "localhost:8888" // the form 'serverhost:port' i.e "localhost:8888"