~samwhited/xmpp

2c0e7c9330381825e8bf9c8aa48df4f19823689c — Sam Whited 5 years ago 008072a
Minor function refactor
2 files changed, 5 insertions(+), 6 deletions(-)

M config.go
M dial.go
M config.go => config.go +2 -2
@@ 71,8 71,8 @@ func NewServerConfig(location, origin *jid.JID, features ...StreamFeature) (c *C
	return c
}

func (config *Config) connType() string {
	if config.S2S {
func connType(s2s bool) string {
	if s2s {
		return "xmpp-server"
	}
	return "xmpp-client"

M dial.go => dial.go +3 -4
@@ 123,8 123,7 @@ func (d *Dialer) Dial(ctx context.Context, network string, config *Config) (*Con
	return c, err
}

func (d *Dialer) dial(
	ctx context.Context, network string, config *Config) (*Conn, error) {
func (d *Dialer) dial(ctx context.Context, network string, config *Config) (*Conn, error) {
	if ctx == nil {
		panic("xmpp.Dial: nil context")
	}


@@ 149,7 148,7 @@ func (d *Dialer) dial(
	// }

	if d.NoLookup {
		p, err := lookupPort(network, config.connType())
		p, err := lookupPort(network, connType(config.S2S))
		if err != nil {
			return nil, err
		}


@@ 163,7 162,7 @@ func (d *Dialer) dial(
		return NewConn(ctx, config, conn)
	}

	addrs, err := lookupService(config.connType(), network, config.Location)
	addrs, err := lookupService(connType(config.S2S), network, config.Location)
	if err != nil {
		return nil, err
	}