Skip to content

Commit

Permalink
db(dumpling): use net.JoinHostPort to generate host-port part of URI (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jul 12, 2022
1 parent 7b72995 commit c82d6d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dumpling/export/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"strconv"
"strings"
"text/template"
Expand Down Expand Up @@ -199,8 +200,9 @@ func (conf *Config) String() string {
func (conf *Config) GetDSN(db string) string {
// maxAllowedPacket=0 can be used to automatically fetch the max_allowed_packet variable from server on every connection.
// https://github.com/go-sql-driver/mysql#maxallowedpacket
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?collation=utf8mb4_general_ci&readTimeout=%s&writeTimeout=30s&interpolateParams=true&maxAllowedPacket=0",
conf.User, conf.Password, conf.Host, conf.Port, db, conf.ReadTimeout)
hostPort := net.JoinHostPort(conf.Host, strconv.Itoa(conf.Port))
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?collation=utf8mb4_general_ci&readTimeout=%s&writeTimeout=30s&interpolateParams=true&maxAllowedPacket=0",
conf.User, conf.Password, hostPort, db, conf.ReadTimeout)
if len(conf.Security.CAPath) > 0 {
dsn += "&tls=dumpling-tls-target"
}
Expand Down

0 comments on commit c82d6d7

Please sign in to comment.