Don't store the password. Be a good citizen.

This commit is contained in:
Chris Rhodes 2013-02-16 10:39:23 -08:00
parent c481300217
commit 6fde11a35f
3 changed files with 7 additions and 13 deletions

View File

@ -19,7 +19,6 @@ type Conn struct {
Host string Host string
Me *state.Nick Me *state.Nick
Network string Network string
password string
// Replaceable function to customise the 433 handler's new nick // Replaceable function to customise the 433 handler's new nick
NewNick func(string) string NewNick func(string) string
@ -173,12 +172,9 @@ func (conn *Conn) Connect(host string, pass ...string) error {
} }
} }
conn.Host = host conn.Host = host
if len(pass) > 0 {
conn.password = pass[0]
}
conn.Connected = true conn.Connected = true
conn.postConnect() conn.postConnect()
conn.ED.Dispatch(INIT, conn, &Line{}) conn.ED.Dispatch(INIT, conn, &Line{Args: pass})
return nil return nil
} }

View File

@ -60,8 +60,8 @@ func (conn *Conn) addIntHandlers() {
// Password/User/Nick broadcast on connection. // Password/User/Nick broadcast on connection.
func (conn *Conn) h_INIT(line *Line) { func (conn *Conn) h_INIT(line *Line) {
if conn.password != "" { if len(line.Args) > 0 {
conn.Pass(conn.password) conn.Pass(line.Args[0])
} }
conn.Nick(conn.Me.Nick) conn.Nick(conn.Me.Nick)
conn.User(conn.Me.Ident, conn.Me.Name) conn.User(conn.Me.Ident, conn.Me.Name)

View File

@ -31,10 +31,9 @@ func TestINIT(t *testing.T) {
s.nc.Expect("USER test 12 * :Testing IRC") s.nc.Expect("USER test 12 * :Testing IRC")
s.nc.ExpectNothing() s.nc.ExpectNothing()
c.password = "12345"
c.Me.Ident = "idiot" c.Me.Ident = "idiot"
c.Me.Name = "I've got the same combination on my luggage!" 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("PASS 12345")
s.nc.Expect("NICK test") s.nc.Expect("NICK test")
s.nc.Expect("USER idiot 12 * :I've got the same combination on my luggage!") 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.") t.Errorf("Channel.ParseModes() not called correctly.")
} }
// Send a nick mode line, returning Me // Send a nick mode line, returning Me
gomock.InOrder( gomock.InOrder(
s.st.EXPECT().GetChannel("test").Return(nil), s.st.EXPECT().GetChannel("test").Return(nil),