Browse Source

Add SSL for HTTP

tags/v0.1.0
Russ Garrett 7 years ago
parent
commit
cca0d5924d
No account linked to committer's email address
3 changed files with 9 additions and 1 deletions
  1. 5
    1
      httplistener/httplistener.go
  2. 3
    0
      irccat.json
  3. 1
    0
      main.go

+ 5
- 1
httplistener/httplistener.go View File

@@ -29,6 +29,10 @@ func New(irc *irc.Connection) (*HTTPListener, error) {
29 29
 
30 30
 	hl.http.Handler = mux
31 31
 	log.Infof("Listening for HTTP requests on %s", viper.GetString("http.listen"))
32
-	go hl.http.ListenAndServe()
32
+	if viper.GetBool("http.ssl") {
33
+		go hl.http.ListenAndServeTLS(viper.GetString("http.ssl_cert"), viper.GetString("http.ssl_key"))
34
+	} else {
35
+		go hl.http.ListenAndServe()
36
+	}
33 37
 	return &hl, nil
34 38
 }

+ 3
- 0
irccat.json View File

@@ -2,6 +2,9 @@
2 2
   "tcp_listen": ":12345",
3 3
   "http": {
4 4
     "listen": ":8045",
5
+    "ssl": false,
6
+    "ssl_key": "",
7
+    "ssl_cert": "",
5 8
     "listeners": {
6 9
       "grafana": "#russtest"
7 10
     }

+ 1
- 0
main.go View File

@@ -97,6 +97,7 @@ func (i *IRCCat) connectIRC() error {
97 97
 }
98 98
 
99 99
 func (i *IRCCat) handleWelcome(e *irc.Event) {
100
+	log.Infof("Connected, joining channels...")
100 101
 	for _, channel := range viper.GetStringSlice("irc.channels") {
101 102
 		i.irc.Join(channel)
102 103
 	}

Loading…
Cancel
Save