Skip to content

Commit

Permalink
Auth list improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
russss committed Jan 15, 2017
1 parent e0013fb commit 82eea9a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Download the [latest
release](https://github.com/irccloud/irccat/releases) from Github, put
the [example
config](https://github.com/irccloud/irccat/blob/master/examples/irccat.json)
in `/etc/irccat.json` or the local directory, and run!
in `/etc/irccat.json` or the local directory and customise it, and run!

## TCP → IRC
Just cat a string to the TCP port - it'll be sent to the first channel
Just cat a string to the TCP port -- it'll be sent to the first channel
defined in your channel list:

echo "Hello world" | nc -q 0 irccat-host 12345
Expand All @@ -42,6 +42,8 @@ There are also endpoints which support app-specific webhooks, currently:
* Grafana alerts can be sent to `/grafana`. They will be sent to the
channel defined in `http.listeners.grafana`.

More HTTP listeners welcome!

Note that there is (currently) no authentication on the HTTP endpoints,
so you should make sure you firewall them from the world.

Expand Down
11 changes: 11 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func (i *IRCCat) handlePart(e *irc.Event) {
}
}

func (i *IRCCat) handleQuit(e *irc.Event) {
delete(i.auth_users, e.Nick)
}

func (i *IRCCat) handleNames(e *irc.Event) {
if e.Arguments[2] == i.auth_channel {
nicks := strings.Split(e.Arguments[3], " ")
Expand All @@ -32,3 +36,10 @@ func (i *IRCCat) handleNames(e *irc.Event) {
}
}
}

func (i *IRCCat) handleNick(e *irc.Event) {
if i.auth_users[e.Nick] {
delete(i.auth_users, e.Nick)
i.auth_users[e.Arguments[0]] = true
}
}
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (i *IRCCat) signalHandler() {

func (i *IRCCat) connectIRC() error {
irccon := irc.IRC(viper.GetString("irc.nick"), viper.GetString("irc.realname"))
irccon.Debug = true
irccon.UseTLS = viper.GetBool("irc.tls")
if viper.GetBool("irc.tls_skip_verify") {
irccon.TLSConfig = &tls.Config{InsecureSkipVerify: true}
Expand All @@ -104,7 +105,9 @@ func (i *IRCCat) connectIRC() error {
irccon.AddCallback("353", i.handleNames)
irccon.AddCallback("JOIN", i.handleJoin)
irccon.AddCallback("PART", i.handlePart)
irccon.AddCallback("QUIT", i.handlePart)
irccon.AddCallback("QUIT", i.handleQuit)
irccon.AddCallback("KILL", i.handleQuit)
irccon.AddCallback("NICK", i.handleNick)

i.irc = irccon
return nil
Expand Down

0 comments on commit 82eea9a

Please sign in to comment.