Skip to content

Commit

Permalink
add authentication token support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Cooper committed Nov 21, 2014
1 parent 1f3d267 commit a25d22b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions gumble/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (c *Client) Connect() error {
Username: &c.config.Username,
Password: &c.config.Password,
Opus: proto.Bool(true),
Tokens: c.config.Tokens,
}
c.Send(protoMessage{&versionPacket})
c.Send(protoMessage{&authenticationPacket})
Expand Down Expand Up @@ -274,6 +275,14 @@ func (c *Client) Channels() Channels {
return c.channels
}

// Reauthenticate will resend the tokens from the connection config.
func (c *Client) Reauthenticate() {
authenticationPacket := MumbleProto.Authenticate{
Tokens: c.config.Tokens,
}
c.Send(protoMessage{&authenticationPacket})
}

// Send will send a message to the server.
func (c *Client) Send(message Message) error {
c.sendMutex.Lock()
Expand Down
7 changes: 4 additions & 3 deletions gumble/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
)

type Config struct {
Username string // client username
Password string // client password (usually not required)
Address string // server address, including port (e.g. localhost:64738)
Username string // Client username
Password string // Client password (usually not required)
Address string // Server address, including port (e.g. localhost:64738)
Tokens []string // Server access tokens

TlsConfig tls.Config
Dialer net.Dialer
Expand Down

0 comments on commit a25d22b

Please sign in to comment.