Browse Source

Auth list improvements

tags/v0.1.5
Russ Garrett 7 years ago
parent
commit
82eea9a65e
No account linked to committer's email address
3 changed files with 19 additions and 3 deletions
  1. 4
    2
      README.md
  2. 11
    0
      auth.go
  3. 4
    1
      main.go

+ 4
- 2
README.md View File

@@ -13,10 +13,10 @@ Download the [latest
13 13
 release](https://github.com/irccloud/irccat/releases) from Github, put
14 14
 the [example
15 15
 config](https://github.com/irccloud/irccat/blob/master/examples/irccat.json)
16
-in `/etc/irccat.json` or the local directory, and run!
16
+in `/etc/irccat.json` or the local directory and customise it, and run!
17 17
 
18 18
 ## TCP → IRC
19
-Just cat a string to the TCP port - it'll be sent to the first channel
19
+Just cat a string to the TCP port -- it'll be sent to the first channel
20 20
 defined in your channel list:
21 21
 
22 22
     echo "Hello world" | nc -q 0 irccat-host 12345
@@ -42,6 +42,8 @@ There are also endpoints which support app-specific webhooks, currently:
42 42
 * Grafana alerts can be sent to `/grafana`. They will be sent to the
43 43
   channel defined in `http.listeners.grafana`.
44 44
 
45
+More HTTP listeners welcome!
46
+
45 47
 Note that there is (currently) no authentication on the HTTP endpoints,
46 48
 so you should make sure you firewall them from the world.
47 49
 

+ 11
- 0
auth.go View File

@@ -22,6 +22,10 @@ func (i *IRCCat) handlePart(e *irc.Event) {
22 22
 	}
23 23
 }
24 24
 
25
+func (i *IRCCat) handleQuit(e *irc.Event) {
26
+	delete(i.auth_users, e.Nick)
27
+}
28
+
25 29
 func (i *IRCCat) handleNames(e *irc.Event) {
26 30
 	if e.Arguments[2] == i.auth_channel {
27 31
 		nicks := strings.Split(e.Arguments[3], " ")
@@ -32,3 +36,10 @@ func (i *IRCCat) handleNames(e *irc.Event) {
32 36
 		}
33 37
 	}
34 38
 }
39
+
40
+func (i *IRCCat) handleNick(e *irc.Event) {
41
+	if i.auth_users[e.Nick] {
42
+		delete(i.auth_users, e.Nick)
43
+		i.auth_users[e.Arguments[0]] = true
44
+	}
45
+}

+ 4
- 1
main.go View File

@@ -84,6 +84,7 @@ func (i *IRCCat) signalHandler() {
84 84
 
85 85
 func (i *IRCCat) connectIRC() error {
86 86
 	irccon := irc.IRC(viper.GetString("irc.nick"), viper.GetString("irc.realname"))
87
+	irccon.Debug = true
87 88
 	irccon.UseTLS = viper.GetBool("irc.tls")
88 89
 	if viper.GetBool("irc.tls_skip_verify") {
89 90
 		irccon.TLSConfig = &tls.Config{InsecureSkipVerify: true}
@@ -104,7 +105,9 @@ func (i *IRCCat) connectIRC() error {
104 105
 	irccon.AddCallback("353", i.handleNames)
105 106
 	irccon.AddCallback("JOIN", i.handleJoin)
106 107
 	irccon.AddCallback("PART", i.handlePart)
107
-	irccon.AddCallback("QUIT", i.handlePart)
108
+	irccon.AddCallback("QUIT", i.handleQuit)
109
+	irccon.AddCallback("KILL", i.handleQuit)
110
+	irccon.AddCallback("NICK", i.handleNick)
108 111
 
109 112
 	i.irc = irccon
110 113
 	return nil

Loading…
Cancel
Save