Browse Source

Add support for Unix domain sockets.

This adds a new configuration option, socket-path, instead of using
host.
tags/v2.1.0-rc1
Alex Jaspersen 4 years ago
parent
commit
3468a8cb8a
4 changed files with 8 additions and 1 deletions
  1. 2
    0
      conventional.yaml
  2. 1
    0
      irc/mysql/config.go
  3. 3
    1
      irc/mysql/history.go
  4. 2
    0
      oragono.yaml

+ 2
- 0
conventional.yaml View File

@@ -665,6 +665,8 @@ datastore:
665 665
         host: "localhost"
666 666
         # port is unnecessary for connections via unix domain socket:
667 667
         #port: 3306
668
+        # if socket-path is set, it will be used instead of host:port
669
+        #socket-path: "/var/run/mysqld/mysqld.sock"
668 670
         user: "oragono"
669 671
         password: "hunter2"
670 672
         history-database: "oragono_history"

+ 1
- 0
irc/mysql/config.go View File

@@ -12,6 +12,7 @@ type Config struct {
12 12
 	Enabled         bool
13 13
 	Host            string
14 14
 	Port            int
15
+	SocketPath      string `yaml:"socket-path"`
15 16
 	User            string
16 17
 	Password        string
17 18
 	HistoryDatabase string `yaml:"history-database"`

+ 3
- 1
irc/mysql/history.go View File

@@ -88,7 +88,9 @@ func (mysql *MySQL) getExpireTime() (expireTime time.Duration) {
88 88
 
89 89
 func (m *MySQL) Open() (err error) {
90 90
 	var address string
91
-	if m.config.Port != 0 {
91
+	if m.config.SocketPath != "" {
92
+		address = fmt.Sprintf("unix(%s)", m.config.SocketPath)
93
+	} else if m.config.Port != 0 {
92 94
 		address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port)
93 95
 	}
94 96
 

+ 2
- 0
oragono.yaml View File

@@ -686,6 +686,8 @@ datastore:
686 686
         host: "localhost"
687 687
         # port is unnecessary for connections via unix domain socket:
688 688
         #port: 3306
689
+        # if socket-path is set, it will be used instead of host:port
690
+        #socket-path: "/var/run/mysqld/mysqld.sock"
689 691
         user: "oragono"
690 692
         password: "hunter2"
691 693
         history-database: "oragono_history"

Loading…
Cancel
Save