From 6fde11a35f3cdec3ea138057a5f22877bcf9d99d Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Sat, 16 Feb 2013 10:39:23 -0800 Subject: [PATCH] Don't store the password. Be a good citizen. --- client/connection.go | 12 ++++-------- client/handlers.go | 4 ++-- client/handlers_test.go | 4 +--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/client/connection.go b/client/connection.go index 0deca91..019e123 100644 --- a/client/connection.go +++ b/client/connection.go @@ -16,10 +16,9 @@ import ( // An IRC connection is represented by this struct. type Conn struct { // Connection Hostname and Nickname - Host string - Me *state.Nick - Network string - password string + Host string + Me *state.Nick + Network string // Replaceable function to customise the 433 handler's new nick NewNick func(string) string @@ -173,12 +172,9 @@ func (conn *Conn) Connect(host string, pass ...string) error { } } conn.Host = host - if len(pass) > 0 { - conn.password = pass[0] - } conn.Connected = true conn.postConnect() - conn.ED.Dispatch(INIT, conn, &Line{}) + conn.ED.Dispatch(INIT, conn, &Line{Args: pass}) return nil } diff --git a/client/handlers.go b/client/handlers.go index 028267b..1cd9112 100644 --- a/client/handlers.go +++ b/client/handlers.go @@ -60,8 +60,8 @@ func (conn *Conn) addIntHandlers() { // Password/User/Nick broadcast on connection. func (conn *Conn) h_INIT(line *Line) { - if conn.password != "" { - conn.Pass(conn.password) + if len(line.Args) > 0 { + conn.Pass(line.Args[0]) } conn.Nick(conn.Me.Nick) conn.User(conn.Me.Ident, conn.Me.Name) diff --git a/client/handlers_test.go b/client/handlers_test.go index e622da0..36b43c5 100644 --- a/client/handlers_test.go +++ b/client/handlers_test.go @@ -31,10 +31,9 @@ func TestINIT(t *testing.T) { s.nc.Expect("USER test 12 * :Testing IRC") s.nc.ExpectNothing() - c.password = "12345" c.Me.Ident = "idiot" c.Me.Name = "I've got the same combination on my luggage!" - c.h_INIT(&Line{}) + c.h_INIT(&Line{Args: []string{"12345"}}) s.nc.Expect("PASS 12345") s.nc.Expect("NICK test") s.nc.Expect("USER idiot 12 * :I've got the same combination on my luggage!") @@ -278,7 +277,6 @@ func TestMODE(t *testing.T) { t.Errorf("Channel.ParseModes() not called correctly.") } - // Send a nick mode line, returning Me gomock.InOrder( s.st.EXPECT().GetChannel("test").Return(nil),