Pass config struct into irc.Client
This commit is contained in:
parent
9aac4f4e29
commit
e97c7f2ada
@ -72,8 +72,8 @@ func (c *Client) handleCAP(msg *Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(c.requestedCapabilities) == 0 {
|
if len(c.requestedCapabilities) == 0 {
|
||||||
if c.SASL != nil && c.HasCapability("sasl", c.SASL.Name()) {
|
if c.Config.SASL != nil && c.HasCapability("sasl", c.Config.SASL.Name()) {
|
||||||
c.write("AUTHENTICATE " + c.SASL.Name())
|
c.write("AUTHENTICATE " + c.Config.SASL.Name())
|
||||||
} else {
|
} else {
|
||||||
c.write("CAP END")
|
c.write("CAP END")
|
||||||
}
|
}
|
||||||
|
@ -11,22 +11,27 @@ import (
|
|||||||
"github.com/jpillora/backoff"
|
"github.com/jpillora/backoff"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Config struct {
|
||||||
Server string
|
|
||||||
Host string
|
Host string
|
||||||
|
Port string
|
||||||
TLS bool
|
TLS bool
|
||||||
TLSConfig *tls.Config
|
TLSConfig *tls.Config
|
||||||
|
Nick string
|
||||||
Password string
|
Password string
|
||||||
Username string
|
Username string
|
||||||
Realname string
|
Realname string
|
||||||
SASL SASL
|
SASL SASL
|
||||||
HandleNickInUse func(string) string
|
|
||||||
|
|
||||||
// Version is the reply to VERSION and FINGER CTCP messages
|
// Version is the reply to VERSION and FINGER CTCP messages
|
||||||
Version string
|
Version string
|
||||||
// Source is the reply to SOURCE CTCP messages
|
// Source is the reply to SOURCE CTCP messages
|
||||||
Source string
|
Source string
|
||||||
|
|
||||||
|
HandleNickInUse func(string) string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
Config Config
|
||||||
|
|
||||||
Messages chan *Message
|
Messages chan *Message
|
||||||
ConnectionChanged chan ConnectionState
|
ConnectionChanged chan ConnectionState
|
||||||
Features *Features
|
Features *Features
|
||||||
@ -52,20 +57,35 @@ type Client struct {
|
|||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(nick, username string) *Client {
|
func NewClient(config Config) *Client {
|
||||||
return &Client{
|
if config.Port == "" {
|
||||||
nick: nick,
|
if config.TLS {
|
||||||
|
config.Port = "6697"
|
||||||
|
} else {
|
||||||
|
config.Port = "6667"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Username == "" {
|
||||||
|
config.Username = config.Nick
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Realname == "" {
|
||||||
|
config.Realname = config.Nick
|
||||||
|
}
|
||||||
|
|
||||||
|
c := Client{
|
||||||
|
Config: config,
|
||||||
|
nick: config.Nick,
|
||||||
Features: NewFeatures(),
|
Features: NewFeatures(),
|
||||||
Username: username,
|
|
||||||
Realname: nick,
|
|
||||||
Messages: make(chan *Message, 32),
|
Messages: make(chan *Message, 32),
|
||||||
|
wantedCapabilities: clientWantedCaps,
|
||||||
|
requestedCapabilities: map[string][]string{},
|
||||||
|
enabledCapabilities: map[string][]string{},
|
||||||
ConnectionChanged: make(chan ConnectionState, 4),
|
ConnectionChanged: make(chan ConnectionState, 4),
|
||||||
out: make(chan string, 32),
|
out: make(chan string, 32),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
reconnect: make(chan struct{}),
|
reconnect: make(chan struct{}),
|
||||||
wantedCapabilities: clientWantedCaps,
|
|
||||||
enabledCapabilities: map[string][]string{},
|
|
||||||
requestedCapabilities: map[string][]string{},
|
|
||||||
dialer: &net.Dialer{Timeout: 10 * time.Second},
|
dialer: &net.Dialer{Timeout: 10 * time.Second},
|
||||||
recvBuf: make([]byte, 0, 4096),
|
recvBuf: make([]byte, 0, 4096),
|
||||||
backoff: &backoff.Backoff{
|
backoff: &backoff.Backoff{
|
||||||
@ -74,6 +94,12 @@ func NewClient(nick, username string) *Client {
|
|||||||
Jitter: true,
|
Jitter: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.SASL != nil {
|
||||||
|
c.wantedCapabilities = append(c.wantedCapabilities, "sasl")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetNick() string {
|
func (c *Client) GetNick() string {
|
||||||
@ -113,6 +139,10 @@ func (c *Client) setRegistered(reg bool) {
|
|||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) Host() string {
|
||||||
|
return c.Config.Host
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) Nick(nick string) {
|
func (c *Client) Nick(nick string) {
|
||||||
c.Write("NICK " + nick)
|
c.Write("NICK " + nick)
|
||||||
}
|
}
|
||||||
@ -199,16 +229,12 @@ func (c *Client) writeUser(username, realname string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) register() {
|
func (c *Client) register() {
|
||||||
if c.SASL != nil {
|
|
||||||
c.wantedCapabilities = append(c.wantedCapabilities, "sasl")
|
|
||||||
}
|
|
||||||
|
|
||||||
c.writeCAP()
|
c.writeCAP()
|
||||||
if c.Password != "" {
|
if c.Config.Password != "" {
|
||||||
c.writePass(c.Password)
|
c.writePass(c.Config.Password)
|
||||||
}
|
}
|
||||||
c.writeNick(c.nick)
|
c.writeNick(c.Config.Nick)
|
||||||
c.writeUser(c.Username, c.Realname)
|
c.writeUser(c.Config.Username, c.Config.Realname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) addChannel(channel string) {
|
func (c *Client) addChannel(channel string) {
|
||||||
|
@ -7,12 +7,8 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testClient() *Client {
|
|
||||||
return NewClient("test", "testing")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testClientSend() (*Client, chan string) {
|
func testClientSend() (*Client, chan string) {
|
||||||
c := testClient()
|
c := NewClient(Config{})
|
||||||
conn := &mockConn{hook: make(chan string, 16)}
|
conn := &mockConn{hook: make(chan string, 16)}
|
||||||
c.conn = conn
|
c.conn = conn
|
||||||
c.sendRecv.Add(1)
|
c.sendRecv.Add(1)
|
||||||
@ -148,15 +144,16 @@ func TestAway(t *testing.T) {
|
|||||||
|
|
||||||
func TestRegister(t *testing.T) {
|
func TestRegister(t *testing.T) {
|
||||||
c, out := testClientSend()
|
c, out := testClientSend()
|
||||||
c.nick = "nick"
|
c.Config.Nick = "nick"
|
||||||
c.Username = "user"
|
c.Config.Username = "user"
|
||||||
c.Realname = "rn"
|
c.Config.Realname = "rn"
|
||||||
|
t.Log(c.Config)
|
||||||
c.register()
|
c.register()
|
||||||
assert.Equal(t, "CAP LS 302\r\n", <-out)
|
assert.Equal(t, "CAP LS 302\r\n", <-out)
|
||||||
assert.Equal(t, "NICK nick\r\n", <-out)
|
assert.Equal(t, "NICK nick\r\n", <-out)
|
||||||
assert.Equal(t, "USER user 0 * :rn\r\n", <-out)
|
assert.Equal(t, "USER user 0 * :rn\r\n", <-out)
|
||||||
|
|
||||||
c.Password = "pass"
|
c.Config.Password = "pass"
|
||||||
c.register()
|
c.register()
|
||||||
assert.Equal(t, "CAP LS 302\r\n", <-out)
|
assert.Equal(t, "CAP LS 302\r\n", <-out)
|
||||||
assert.Equal(t, "PASS pass\r\n", <-out)
|
assert.Equal(t, "PASS pass\r\n", <-out)
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,20 +15,7 @@ var (
|
|||||||
ErrBadProtocol = errors.New("This server does not speak IRC")
|
ErrBadProtocol = errors.New("This server does not speak IRC")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) Connect(address string) {
|
func (c *Client) Connect() {
|
||||||
if idx := strings.Index(address, ":"); idx < 0 {
|
|
||||||
c.Host = address
|
|
||||||
|
|
||||||
if c.TLS {
|
|
||||||
address += ":6697"
|
|
||||||
} else {
|
|
||||||
address += ":6667"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.Host = address[:idx]
|
|
||||||
}
|
|
||||||
c.Server = address
|
|
||||||
|
|
||||||
c.connChange(false, nil)
|
c.connChange(false, nil)
|
||||||
go c.run()
|
go c.run()
|
||||||
}
|
}
|
||||||
@ -130,15 +117,16 @@ func (c *Client) connect() error {
|
|||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
if c.TLS {
|
addr := net.JoinHostPort(c.Config.Host, c.Config.Port)
|
||||||
conn, err := tls.DialWithDialer(c.dialer, "tcp", c.Server, c.TLSConfig)
|
if c.Config.TLS {
|
||||||
|
conn, err := tls.DialWithDialer(c.dialer, "tcp", addr, c.Config.TLSConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.conn = conn
|
c.conn = conn
|
||||||
} else {
|
} else {
|
||||||
conn, err := c.dialer.Dial("tcp", c.Server)
|
conn, err := c.dialer.Dial("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -242,8 +230,8 @@ func (c *Client) recv() {
|
|||||||
c.Features.Parse(msg.Params)
|
c.Features.Parse(msg.Params)
|
||||||
|
|
||||||
case ERR_NICKNAMEINUSE, ERR_NICKCOLLISION, ERR_UNAVAILRESOURCE:
|
case ERR_NICKNAMEINUSE, ERR_NICKCOLLISION, ERR_UNAVAILRESOURCE:
|
||||||
if c.HandleNickInUse != nil {
|
if c.Config.HandleNickInUse != nil {
|
||||||
go c.writeNick(c.HandleNickInUse(msg.Params[1]))
|
go c.writeNick(c.Config.HandleNickInUse(msg.Params[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
case ERROR:
|
case ERROR:
|
||||||
|
@ -78,34 +78,38 @@ func (i *mockIrcd) handle(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnect(t *testing.T) {
|
func TestConnect(t *testing.T) {
|
||||||
c := testClient()
|
c := NewClient(Config{
|
||||||
c.Connect("127.0.0.1:45678")
|
Host: "127.0.0.1",
|
||||||
assert.Equal(t, c.Host, "127.0.0.1")
|
Port: "45678",
|
||||||
assert.Equal(t, c.Server, "127.0.0.1:45678")
|
})
|
||||||
|
c.Connect()
|
||||||
waitConnAndClose(t, c)
|
waitConnAndClose(t, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConnectTLS(t *testing.T) {
|
func TestConnectTLS(t *testing.T) {
|
||||||
c := testClient()
|
c := NewClient(Config{
|
||||||
c.TLS = true
|
Host: "127.0.0.1",
|
||||||
c.TLSConfig = &tls.Config{
|
Port: "45679",
|
||||||
|
TLS: true,
|
||||||
|
TLSConfig: &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
}
|
},
|
||||||
c.Connect("127.0.0.1:45679")
|
})
|
||||||
assert.Equal(t, c.Host, "127.0.0.1")
|
c.Connect()
|
||||||
assert.Equal(t, c.Server, "127.0.0.1:45679")
|
|
||||||
waitConnAndClose(t, c)
|
waitConnAndClose(t, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConnectDefaultPorts(t *testing.T) {
|
func TestConnectDefaultPorts(t *testing.T) {
|
||||||
c := testClient()
|
c := NewClient(Config{
|
||||||
c.Connect("127.0.0.1")
|
Host: "127.0.0.1",
|
||||||
assert.Equal(t, "127.0.0.1:6667", c.Server)
|
})
|
||||||
|
assert.Equal(t, "6667", c.Config.Port)
|
||||||
|
|
||||||
c = testClient()
|
c = NewClient(Config{
|
||||||
c.TLS = true
|
Host: "127.0.0.1",
|
||||||
c.Connect("127.0.0.1")
|
TLS: true,
|
||||||
assert.Equal(t, "127.0.0.1:6697", c.Server)
|
})
|
||||||
|
assert.Equal(t, "6697", c.Config.Port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrite(t *testing.T) {
|
func TestWrite(t *testing.T) {
|
||||||
@ -121,7 +125,7 @@ func TestWrite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRecv(t *testing.T) {
|
func TestRecv(t *testing.T) {
|
||||||
c := testClient()
|
c := NewClient(Config{})
|
||||||
conn := &mockConn{hook: make(chan string, 16)}
|
conn := &mockConn{hook: make(chan string, 16)}
|
||||||
c.conn = conn
|
c.conn = conn
|
||||||
|
|
||||||
@ -141,7 +145,7 @@ func TestRecv(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRecvTriggersReconnect(t *testing.T) {
|
func TestRecvTriggersReconnect(t *testing.T) {
|
||||||
c := testClient()
|
c := NewClient(Config{})
|
||||||
c.conn = &mockConn{}
|
c.conn = &mockConn{}
|
||||||
c.scan = bufio.NewScanner(bytes.NewBufferString("001 bob\r\n"))
|
c.scan = bufio.NewScanner(bytes.NewBufferString("001 bob\r\n"))
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
@ -164,7 +168,7 @@ func TestRecvTriggersReconnect(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestClose(t *testing.T) {
|
func TestClose(t *testing.T) {
|
||||||
c := testClient()
|
c := NewClient(Config{})
|
||||||
close(c.quit)
|
close(c.quit)
|
||||||
ok := false
|
ok := false
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
@ -48,22 +48,22 @@ func (c *Client) handleCTCP(ctcp *CTCP, msg *Message) {
|
|||||||
c.ReplyCTCP(msg.Nick, ctcp.Command, ClientInfo)
|
c.ReplyCTCP(msg.Nick, ctcp.Command, ClientInfo)
|
||||||
|
|
||||||
case "FINGER", "VERSION":
|
case "FINGER", "VERSION":
|
||||||
if c.Version != "" {
|
if c.Config.Version != "" {
|
||||||
c.ReplyCTCP(msg.Nick, ctcp.Command, c.Version)
|
c.ReplyCTCP(msg.Nick, ctcp.Command, c.Config.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "PING":
|
case "PING":
|
||||||
c.ReplyCTCP(msg.Nick, ctcp.Command, ctcp.Params)
|
c.ReplyCTCP(msg.Nick, ctcp.Command, ctcp.Params)
|
||||||
|
|
||||||
case "SOURCE":
|
case "SOURCE":
|
||||||
if c.Source != "" {
|
if c.Config.Source != "" {
|
||||||
c.ReplyCTCP(msg.Nick, ctcp.Command, c.Source)
|
c.ReplyCTCP(msg.Nick, ctcp.Command, c.Config.Source)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "TIME":
|
case "TIME":
|
||||||
c.ReplyCTCP(msg.Nick, ctcp.Command, time.Now().UTC().Format(time.RFC3339))
|
c.ReplyCTCP(msg.Nick, ctcp.Command, time.Now().UTC().Format(time.RFC3339))
|
||||||
|
|
||||||
case "USERINFO":
|
case "USERINFO":
|
||||||
c.ReplyCTCP(msg.Nick, ctcp.Command, fmt.Sprintf("%s (%s)", c.GetNick(), c.Realname))
|
c.ReplyCTCP(msg.Nick, ctcp.Command, fmt.Sprintf("%s (%s)", c.GetNick(), c.Config.Realname))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func (s *SASLExternal) Encode() string {
|
|||||||
func (c *Client) handleSASL(msg *Message) {
|
func (c *Client) handleSASL(msg *Message) {
|
||||||
switch msg.Command {
|
switch msg.Command {
|
||||||
case AUTHENTICATE:
|
case AUTHENTICATE:
|
||||||
auth := c.SASL.Encode()
|
auth := c.Config.SASL.Encode()
|
||||||
|
|
||||||
for len(auth) >= 400 {
|
for len(auth) >= 400 {
|
||||||
c.write("AUTHENTICATE " + auth)
|
c.write("AUTHENTICATE " + auth)
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
|
||||||
|
|
||||||
"github.com/khlieng/dispatch/pkg/irc"
|
"github.com/khlieng/dispatch/pkg/irc"
|
||||||
"github.com/khlieng/dispatch/storage"
|
"github.com/khlieng/dispatch/storage"
|
||||||
@ -17,12 +16,12 @@ func createNickInUseHandler(i *irc.Client, state *State) func(string) string {
|
|||||||
|
|
||||||
if newNick == i.GetNick() {
|
if newNick == i.GetNick() {
|
||||||
state.sendJSON("nick_fail", NickFail{
|
state.sendJSON("nick_fail", NickFail{
|
||||||
Server: i.Host,
|
Server: i.Host(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
state.sendJSON("error", IRCError{
|
state.sendJSON("error", IRCError{
|
||||||
Server: i.Host,
|
Server: i.Host(),
|
||||||
Message: fmt.Sprintf("Nickname %s is unavailable, trying %s instead", nick, newNick),
|
Message: fmt.Sprintf("Nickname %s is unavailable, trying %s instead", nick, newNick),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -31,57 +30,53 @@ func createNickInUseHandler(i *irc.Client, state *State) func(string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func connectIRC(server *storage.Server, state *State, srcIP []byte) *irc.Client {
|
func connectIRC(server *storage.Server, state *State, srcIP []byte) *irc.Client {
|
||||||
i := irc.NewClient(server.Nick, server.Username)
|
|
||||||
i.TLS = server.TLS
|
|
||||||
i.Realname = server.Realname
|
|
||||||
i.Version = fmt.Sprintf("Dispatch %s (git: %s)", version.Tag, version.Commit)
|
|
||||||
i.Source = "https://github.com/khlieng/dispatch"
|
|
||||||
i.HandleNickInUse = createNickInUseHandler(i, state)
|
|
||||||
|
|
||||||
address := server.Host
|
|
||||||
if server.Port != "" {
|
|
||||||
address = net.JoinHostPort(server.Host, server.Port)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg := state.srv.Config()
|
cfg := state.srv.Config()
|
||||||
|
|
||||||
|
ircCfg := irc.Config{
|
||||||
|
Host: server.Host,
|
||||||
|
Port: server.Port,
|
||||||
|
TLS: server.TLS,
|
||||||
|
Nick: server.Nick,
|
||||||
|
Username: server.Username,
|
||||||
|
Realname: server.Realname,
|
||||||
|
Version: fmt.Sprintf("Dispatch %s (git: %s)", version.Tag, version.Commit),
|
||||||
|
Source: "https://github.com/khlieng/dispatch",
|
||||||
|
}
|
||||||
|
|
||||||
|
if server.TLS {
|
||||||
|
ircCfg.TLSConfig = &tls.Config{
|
||||||
|
InsecureSkipVerify: !cfg.VerifyCertificates,
|
||||||
|
}
|
||||||
|
|
||||||
|
if cert := state.user.GetCertificate(); cert != nil {
|
||||||
|
ircCfg.TLSConfig.Certificates = []tls.Certificate{*cert}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if cfg.HexIP {
|
if cfg.HexIP {
|
||||||
i.Username = hex.EncodeToString(srcIP)
|
ircCfg.Username = hex.EncodeToString(srcIP)
|
||||||
} else if i.Username == "" {
|
|
||||||
i.Username = server.Nick
|
|
||||||
}
|
|
||||||
|
|
||||||
if i.Realname == "" {
|
|
||||||
i.Realname = server.Nick
|
|
||||||
}
|
|
||||||
|
|
||||||
if server.ServerPassword == "" &&
|
|
||||||
cfg.Defaults.ServerPassword != "" &&
|
|
||||||
address == cfg.Defaults.Host {
|
|
||||||
i.Password = cfg.Defaults.ServerPassword
|
|
||||||
} else {
|
|
||||||
i.Password = server.ServerPassword
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.Account != "" && server.Password != "" {
|
if server.Account != "" && server.Password != "" {
|
||||||
i.SASL = &irc.SASLPlain{
|
ircCfg.SASL = &irc.SASLPlain{
|
||||||
Username: server.Account,
|
Username: server.Account,
|
||||||
Password: server.Password,
|
Password: server.Password,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if i.TLS {
|
if server.ServerPassword == "" &&
|
||||||
i.TLSConfig = &tls.Config{
|
cfg.Defaults.ServerPassword != "" &&
|
||||||
InsecureSkipVerify: !cfg.VerifyCertificates,
|
server.Host == cfg.Defaults.Host {
|
||||||
|
ircCfg.Password = cfg.Defaults.ServerPassword
|
||||||
|
} else {
|
||||||
|
ircCfg.Password = server.ServerPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
if cert := state.user.GetCertificate(); cert != nil {
|
i := irc.NewClient(ircCfg)
|
||||||
i.TLSConfig.Certificates = []tls.Certificate{*cert}
|
i.Config.HandleNickInUse = createNickInUseHandler(i, state)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state.setIRC(server.Host, i)
|
state.setIRC(server.Host, i)
|
||||||
i.Connect(address)
|
i.Connect()
|
||||||
go newIRCHandler(i, state).run()
|
go newIRCHandler(i, state).run()
|
||||||
|
|
||||||
return i
|
return i
|
||||||
|
@ -52,15 +52,15 @@ func (i *ircHandler) run() {
|
|||||||
select {
|
select {
|
||||||
case msg, ok := <-i.client.Messages:
|
case msg, ok := <-i.client.Messages:
|
||||||
if !ok {
|
if !ok {
|
||||||
i.state.deleteIRC(i.client.Host)
|
i.state.deleteIRC(i.client.Host())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
i.dispatchMessage(msg)
|
i.dispatchMessage(msg)
|
||||||
|
|
||||||
case state := <-i.client.ConnectionChanged:
|
case state := <-i.client.ConnectionChanged:
|
||||||
i.state.sendJSON("connection_update", newConnectionUpdate(i.client.Host, state))
|
i.state.sendJSON("connection_update", newConnectionUpdate(i.client.Host(), state))
|
||||||
i.state.setConnectionState(i.client.Host, state)
|
i.state.setConnectionState(i.client.Host(), state)
|
||||||
|
|
||||||
if state.Error != nil && (lastConnErr == nil ||
|
if state.Error != nil && (lastConnErr == nil ||
|
||||||
state.Error.Error() != lastConnErr.Error()) {
|
state.Error.Error() != lastConnErr.Error()) {
|
||||||
@ -89,7 +89,7 @@ func (i *ircHandler) run() {
|
|||||||
func (i *ircHandler) dispatchMessage(msg *irc.Message) {
|
func (i *ircHandler) dispatchMessage(msg *irc.Message) {
|
||||||
if msg.Command[0] == '4' && !isExcludedError(msg.Command) {
|
if msg.Command[0] == '4' && !isExcludedError(msg.Command) {
|
||||||
err := IRCError{
|
err := IRCError{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Message: msg.LastParam(),
|
Message: msg.LastParam(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,36 +112,36 @@ func (i *ircHandler) dispatchMessage(msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) nick(msg *irc.Message) {
|
func (i *ircHandler) nick(msg *irc.Message) {
|
||||||
i.state.sendJSON("nick", Nick{
|
i.state.sendJSON("nick", Nick{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Old: msg.Nick,
|
Old: msg.Nick,
|
||||||
New: msg.LastParam(),
|
New: msg.LastParam(),
|
||||||
})
|
})
|
||||||
|
|
||||||
channelStore.RenameUser(msg.Nick, msg.LastParam(), i.client.Host)
|
channelStore.RenameUser(msg.Nick, msg.LastParam(), i.client.Host())
|
||||||
|
|
||||||
if i.client.Is(msg.LastParam()) {
|
if i.client.Is(msg.LastParam()) {
|
||||||
go i.state.user.SetNick(msg.LastParam(), i.client.Host)
|
go i.state.user.SetNick(msg.LastParam(), i.client.Host())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) join(msg *irc.Message) {
|
func (i *ircHandler) join(msg *irc.Message) {
|
||||||
i.state.sendJSON("join", Join{
|
i.state.sendJSON("join", Join{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
User: msg.Nick,
|
User: msg.Nick,
|
||||||
Channels: msg.Params,
|
Channels: msg.Params,
|
||||||
})
|
})
|
||||||
|
|
||||||
channel := msg.Params[0]
|
channel := msg.Params[0]
|
||||||
channelStore.AddUser(msg.Nick, i.client.Host, channel)
|
channelStore.AddUser(msg.Nick, i.client.Host(), channel)
|
||||||
|
|
||||||
if i.client.Is(msg.Nick) {
|
if i.client.Is(msg.Nick) {
|
||||||
// In case no topic is set and there's a cached one that needs to be cleared
|
// In case no topic is set and there's a cached one that needs to be cleared
|
||||||
i.client.Topic(channel)
|
i.client.Topic(channel)
|
||||||
|
|
||||||
i.state.sendLastMessages(i.client.Host, channel, 50)
|
i.state.sendLastMessages(i.client.Host(), channel, 50)
|
||||||
|
|
||||||
go i.state.user.AddChannel(&storage.Channel{
|
go i.state.user.AddChannel(&storage.Channel{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Name: channel,
|
Name: channel,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ func (i *ircHandler) join(msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) part(msg *irc.Message) {
|
func (i *ircHandler) part(msg *irc.Message) {
|
||||||
part := Part{
|
part := Part{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
User: msg.Nick,
|
User: msg.Nick,
|
||||||
Channel: msg.Params[0],
|
Channel: msg.Params[0],
|
||||||
}
|
}
|
||||||
@ -160,10 +160,10 @@ func (i *ircHandler) part(msg *irc.Message) {
|
|||||||
|
|
||||||
i.state.sendJSON("part", part)
|
i.state.sendJSON("part", part)
|
||||||
|
|
||||||
channelStore.RemoveUser(msg.Nick, i.client.Host, part.Channel)
|
channelStore.RemoveUser(msg.Nick, i.client.Host(), part.Channel)
|
||||||
|
|
||||||
if i.client.Is(msg.Nick) {
|
if i.client.Is(msg.Nick) {
|
||||||
go i.state.user.RemoveChannel(i.client.Host, part.Channel)
|
go i.state.user.RemoveChannel(i.client.Host(), part.Channel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,13 +171,13 @@ func (i *ircHandler) mode(msg *irc.Message) {
|
|||||||
target := msg.Params[0]
|
target := msg.Params[0]
|
||||||
if len(msg.Params) > 2 && isChannel(target) {
|
if len(msg.Params) > 2 && isChannel(target) {
|
||||||
mode := parseMode(msg.Params[1])
|
mode := parseMode(msg.Params[1])
|
||||||
mode.Server = i.client.Host
|
mode.Server = i.client.Host()
|
||||||
mode.Channel = target
|
mode.Channel = target
|
||||||
mode.User = msg.Params[2]
|
mode.User = msg.Params[2]
|
||||||
|
|
||||||
i.state.sendJSON("mode", mode)
|
i.state.sendJSON("mode", mode)
|
||||||
|
|
||||||
channelStore.SetMode(i.client.Host, target, msg.Params[2], mode.Add, mode.Remove)
|
channelStore.SetMode(i.client.Host(), target, msg.Params[2], mode.Add, mode.Remove)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ func (i *ircHandler) message(msg *irc.Message) {
|
|||||||
|
|
||||||
message := Message{
|
message := Message{
|
||||||
ID: betterguid.New(),
|
ID: betterguid.New(),
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
From: msg.Nick,
|
From: msg.Nick,
|
||||||
Content: msg.LastParam(),
|
Content: msg.LastParam(),
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ func (i *ircHandler) message(msg *irc.Message) {
|
|||||||
i.state.sendJSON("pm", message)
|
i.state.sendJSON("pm", message)
|
||||||
|
|
||||||
if !msg.IsFromServer() {
|
if !msg.IsFromServer() {
|
||||||
i.state.user.AddOpenDM(i.client.Host, message.From)
|
i.state.user.AddOpenDM(i.client.Host(), message.From)
|
||||||
}
|
}
|
||||||
|
|
||||||
target = message.From
|
target = message.From
|
||||||
@ -216,38 +216,38 @@ func (i *ircHandler) message(msg *irc.Message) {
|
|||||||
|
|
||||||
if target != "*" && !msg.IsFromServer() {
|
if target != "*" && !msg.IsFromServer() {
|
||||||
go i.state.user.LogMessage(message.ID,
|
go i.state.user.LogMessage(message.ID,
|
||||||
i.client.Host, msg.Nick, target, msg.LastParam())
|
i.client.Host(), msg.Nick, target, msg.LastParam())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) quit(msg *irc.Message) {
|
func (i *ircHandler) quit(msg *irc.Message) {
|
||||||
i.state.sendJSON("quit", Quit{
|
i.state.sendJSON("quit", Quit{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
User: msg.Nick,
|
User: msg.Nick,
|
||||||
Reason: msg.LastParam(),
|
Reason: msg.LastParam(),
|
||||||
})
|
})
|
||||||
|
|
||||||
channelStore.RemoveUserAll(msg.Nick, i.client.Host)
|
channelStore.RemoveUserAll(msg.Nick, i.client.Host())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) info(msg *irc.Message) {
|
func (i *ircHandler) info(msg *irc.Message) {
|
||||||
if msg.Command == irc.RPL_WELCOME {
|
if msg.Command == irc.RPL_WELCOME {
|
||||||
i.state.sendJSON("nick", Nick{
|
i.state.sendJSON("nick", Nick{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
New: msg.Params[0],
|
New: msg.Params[0],
|
||||||
})
|
})
|
||||||
|
|
||||||
_, needsUpdate := channelIndexes.Get(i.client.Host)
|
_, needsUpdate := channelIndexes.Get(i.client.Host())
|
||||||
if needsUpdate {
|
if needsUpdate {
|
||||||
i.listBuffer = storage.NewMapChannelListIndex()
|
i.listBuffer = storage.NewMapChannelListIndex()
|
||||||
i.client.List()
|
i.client.List()
|
||||||
}
|
}
|
||||||
|
|
||||||
go i.state.user.SetNick(msg.Params[0], i.client.Host)
|
go i.state.user.SetNick(msg.Params[0], i.client.Host())
|
||||||
}
|
}
|
||||||
|
|
||||||
i.state.sendJSON("pm", Message{
|
i.state.sendJSON("pm", Message{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
From: msg.Nick,
|
From: msg.Nick,
|
||||||
Content: strings.Join(msg.Params[1:], " "),
|
Content: strings.Join(msg.Params[1:], " "),
|
||||||
})
|
})
|
||||||
@ -255,13 +255,13 @@ func (i *ircHandler) info(msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) features(msg *irc.Message) {
|
func (i *ircHandler) features(msg *irc.Message) {
|
||||||
i.state.sendJSON("features", Features{
|
i.state.sendJSON("features", Features{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Features: i.client.Features.Map(),
|
Features: i.client.Features.Map(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if name := i.client.Features.String("NETWORK"); name != "" {
|
if name := i.client.Features.String("NETWORK"); name != "" {
|
||||||
go func() {
|
go func() {
|
||||||
server, err := i.state.user.GetServer(i.client.Host)
|
server, err := i.state.user.GetServer(i.client.Host())
|
||||||
if err == nil && server.Name == "" {
|
if err == nil && server.Name == "" {
|
||||||
i.state.user.SetServerName(name, server.Host)
|
i.state.user.SetServerName(name, server.Host)
|
||||||
}
|
}
|
||||||
@ -303,24 +303,24 @@ func (i *ircHandler) topic(msg *irc.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i.state.sendJSON("topic", Topic{
|
i.state.sendJSON("topic", Topic{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
Topic: msg.LastParam(),
|
Topic: msg.LastParam(),
|
||||||
Nick: nick,
|
Nick: nick,
|
||||||
})
|
})
|
||||||
|
|
||||||
channelStore.SetTopic(msg.LastParam(), i.client.Host, channel)
|
channelStore.SetTopic(msg.LastParam(), i.client.Host(), channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) noTopic(msg *irc.Message) {
|
func (i *ircHandler) noTopic(msg *irc.Message) {
|
||||||
channel := msg.Params[1]
|
channel := msg.Params[1]
|
||||||
|
|
||||||
i.state.sendJSON("topic", Topic{
|
i.state.sendJSON("topic", Topic{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
})
|
})
|
||||||
|
|
||||||
channelStore.SetTopic("", i.client.Host, channel)
|
channelStore.SetTopic("", i.client.Host(), channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) names(msg *irc.Message) {
|
func (i *ircHandler) names(msg *irc.Message) {
|
||||||
@ -334,17 +334,17 @@ func (i *ircHandler) namesEnd(msg *irc.Message) {
|
|||||||
users := i.userBuffers[channel]
|
users := i.userBuffers[channel]
|
||||||
|
|
||||||
i.state.sendJSON("users", Userlist{
|
i.state.sendJSON("users", Userlist{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
Users: users,
|
Users: users,
|
||||||
})
|
})
|
||||||
|
|
||||||
channelStore.SetUsers(users, i.client.Host, channel)
|
channelStore.SetUsers(users, i.client.Host(), channel)
|
||||||
delete(i.userBuffers, channel)
|
delete(i.userBuffers, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) motdStart(msg *irc.Message) {
|
func (i *ircHandler) motdStart(msg *irc.Message) {
|
||||||
i.motdBuffer.Server = i.client.Host
|
i.motdBuffer.Server = i.client.Host()
|
||||||
i.motdBuffer.Title = msg.LastParam()
|
i.motdBuffer.Title = msg.LastParam()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ func (i *ircHandler) motdEnd(msg *irc.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) list(msg *irc.Message) {
|
func (i *ircHandler) list(msg *irc.Message) {
|
||||||
if i.listBuffer == nil && i.state.Bool("update_chanlist_"+i.client.Host) {
|
if i.listBuffer == nil && i.state.Bool("update_chanlist_"+i.client.Host()) {
|
||||||
i.listBuffer = storage.NewMapChannelListIndex()
|
i.listBuffer = storage.NewMapChannelListIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,11 +374,11 @@ func (i *ircHandler) list(msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) listEnd(msg *irc.Message) {
|
func (i *ircHandler) listEnd(msg *irc.Message) {
|
||||||
if i.listBuffer != nil {
|
if i.listBuffer != nil {
|
||||||
i.state.Set("update_chanlist_"+i.client.Host, false)
|
i.state.Set("update_chanlist_"+i.client.Host(), false)
|
||||||
|
|
||||||
go func(idx storage.ChannelListIndex) {
|
go func(idx storage.ChannelListIndex) {
|
||||||
idx.Finish()
|
idx.Finish()
|
||||||
channelIndexes.Set(i.client.Host, idx)
|
channelIndexes.Set(i.client.Host(), idx)
|
||||||
}(i.listBuffer)
|
}(i.listBuffer)
|
||||||
|
|
||||||
i.listBuffer = nil
|
i.listBuffer = nil
|
||||||
@ -387,14 +387,14 @@ func (i *ircHandler) listEnd(msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) badNick(msg *irc.Message) {
|
func (i *ircHandler) badNick(msg *irc.Message) {
|
||||||
i.state.sendJSON("nick_fail", NickFail{
|
i.state.sendJSON("nick_fail", NickFail{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) forward(msg *irc.Message) {
|
func (i *ircHandler) forward(msg *irc.Message) {
|
||||||
if len(msg.Params) > 2 {
|
if len(msg.Params) > 2 {
|
||||||
i.state.sendJSON("channel_forward", ChannelForward{
|
i.state.sendJSON("channel_forward", ChannelForward{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Old: msg.Params[1],
|
Old: msg.Params[1],
|
||||||
New: msg.Params[2],
|
New: msg.Params[2],
|
||||||
})
|
})
|
||||||
@ -403,7 +403,7 @@ func (i *ircHandler) forward(msg *irc.Message) {
|
|||||||
|
|
||||||
func (i *ircHandler) error(msg *irc.Message) {
|
func (i *ircHandler) error(msg *irc.Message) {
|
||||||
i.state.sendJSON("error", IRCError{
|
i.state.sendJSON("error", IRCError{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
Message: msg.LastParam(),
|
Message: msg.LastParam(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -424,7 +424,7 @@ func (i *ircHandler) receiveDCCSend(pack *irc.DCCSend, msg *irc.Message) {
|
|||||||
i.state.setPendingDCC(pack.File, pack)
|
i.state.setPendingDCC(pack.File, pack)
|
||||||
|
|
||||||
i.state.sendJSON("dcc_send", DCCSend{
|
i.state.sendJSON("dcc_send", DCCSend{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
From: msg.Nick,
|
From: msg.Nick,
|
||||||
Filename: pack.File,
|
Filename: pack.File,
|
||||||
URL: fmt.Sprintf("%s://%s/downloads/%s/%s",
|
URL: fmt.Sprintf("%s://%s/downloads/%s/%s",
|
||||||
@ -476,12 +476,12 @@ func (i *ircHandler) initHandlers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) log(v ...interface{}) {
|
func (i *ircHandler) log(v ...interface{}) {
|
||||||
log.Println("[IRC]", i.state.user.ID, i.client.Host, fmt.Sprint(v...))
|
log.Println("[IRC]", i.state.user.ID, i.client.Host(), fmt.Sprint(v...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) sendDCCInfo(message string, log bool, a ...interface{}) {
|
func (i *ircHandler) sendDCCInfo(message string, log bool, a ...interface{}) {
|
||||||
msg := Message{
|
msg := Message{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host(),
|
||||||
From: "@dcc",
|
From: "@dcc",
|
||||||
Content: fmt.Sprintf(message, a...),
|
Content: fmt.Sprintf(message, a...),
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,11 @@ func dispatchMessage(msg *irc.Message) WSResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func dispatchMessageMulti(msg *irc.Message) chan WSResponse {
|
func dispatchMessageMulti(msg *irc.Message) chan WSResponse {
|
||||||
c := irc.NewClient("nick", "user")
|
c := irc.NewClient(irc.Config{
|
||||||
c.Host = "host.com"
|
Nick: "nick",
|
||||||
|
Username: "user",
|
||||||
|
Host: "host.com",
|
||||||
|
})
|
||||||
s := NewState(user, nil)
|
s := NewState(user, nil)
|
||||||
|
|
||||||
newIRCHandler(c, s).dispatchMessage(msg)
|
newIRCHandler(c, s).dispatchMessage(msg)
|
||||||
@ -200,8 +203,11 @@ func TestHandleIRCWelcome(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleIRCWhois(t *testing.T) {
|
func TestHandleIRCWhois(t *testing.T) {
|
||||||
c := irc.NewClient("nick", "user")
|
c := irc.NewClient(irc.Config{
|
||||||
c.Host = "host.com"
|
Nick: "nick",
|
||||||
|
Username: "user",
|
||||||
|
Host: "host.com",
|
||||||
|
})
|
||||||
s := NewState(nil, nil)
|
s := NewState(nil, nil)
|
||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
@ -268,8 +274,11 @@ func TestHandleIRCNoTopic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleIRCNames(t *testing.T) {
|
func TestHandleIRCNames(t *testing.T) {
|
||||||
c := irc.NewClient("nick", "user")
|
c := irc.NewClient(irc.Config{
|
||||||
c.Host = "host.com"
|
Nick: "nick",
|
||||||
|
Username: "user",
|
||||||
|
Host: "host.com",
|
||||||
|
})
|
||||||
s := NewState(nil, nil)
|
s := NewState(nil, nil)
|
||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
@ -294,8 +303,11 @@ func TestHandleIRCNames(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleIRCMotd(t *testing.T) {
|
func TestHandleIRCMotd(t *testing.T) {
|
||||||
c := irc.NewClient("nick", "user")
|
c := irc.NewClient(irc.Config{
|
||||||
c.Host = "host.com"
|
Nick: "nick",
|
||||||
|
Username: "user",
|
||||||
|
Host: "host.com",
|
||||||
|
})
|
||||||
s := NewState(nil, nil)
|
s := NewState(nil, nil)
|
||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
@ -321,8 +333,11 @@ func TestHandleIRCMotd(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleIRCBadNick(t *testing.T) {
|
func TestHandleIRCBadNick(t *testing.T) {
|
||||||
c := irc.NewClient("nick", "user")
|
c := irc.NewClient(irc.Config{
|
||||||
c.Host = "host.com"
|
Nick: "nick",
|
||||||
|
Username: "user",
|
||||||
|
Host: "host.com",
|
||||||
|
})
|
||||||
s := NewState(nil, nil)
|
s := NewState(nil, nil)
|
||||||
i := newIRCHandler(c, s)
|
i := newIRCHandler(c, s)
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ func (h *wsHandler) reconnect(b []byte) {
|
|||||||
data.UnmarshalJSON(b)
|
data.UnmarshalJSON(b)
|
||||||
|
|
||||||
if i, ok := h.state.getIRC(data.Server); ok && !i.Connected() {
|
if i, ok := h.state.getIRC(data.Server); ok && !i.Connected() {
|
||||||
if i.TLS {
|
if i.Config.TLS {
|
||||||
i.TLSConfig.InsecureSkipVerify = data.SkipVerify
|
i.Config.TLSConfig.InsecureSkipVerify = data.SkipVerify
|
||||||
}
|
}
|
||||||
i.Reconnect()
|
i.Reconnect()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user