|
|
|
@ -155,7 +155,7 @@ func LoadConfigs() { |
|
|
|
|
if len(DbCfg.Passwd) == 0 { |
|
|
|
|
DbCfg.Passwd = sec.Key("PASSWD").String() |
|
|
|
|
} |
|
|
|
|
DbCfg.SSLMode = sec.Key("SSL_MODE").String() |
|
|
|
|
DbCfg.SSLMode = sec.Key("SSL_MODE").MustString("disable") |
|
|
|
|
DbCfg.Path = sec.Key("PATH").MustString("data/gitea.db") |
|
|
|
|
DbCfg.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500) |
|
|
|
|
|
|
|
|
@ -222,13 +222,16 @@ func getEngine() (*xorm.Engine, error) { |
|
|
|
|
} |
|
|
|
|
switch DbCfg.Type { |
|
|
|
|
case "mysql": |
|
|
|
|
connType := "tcp" |
|
|
|
|
if DbCfg.Host[0] == '/' { // looks like a unix socket
|
|
|
|
|
connStr = fmt.Sprintf("%s:%s@unix(%s)/%s%scharset=utf8&parseTime=true", |
|
|
|
|
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param) |
|
|
|
|
} else { |
|
|
|
|
connStr = fmt.Sprintf("%s:%s@tcp(%s)/%s%scharset=utf8&parseTime=true", |
|
|
|
|
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name, Param) |
|
|
|
|
connType = "unix" |
|
|
|
|
} |
|
|
|
|
tls := DbCfg.SSLMode |
|
|
|
|
if tls == "disable" { // allow (Postgres-inspired) default value to work in MySQL
|
|
|
|
|
tls = "false" |
|
|
|
|
} |
|
|
|
|
connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=utf8&parseTime=true&tls=%s", |
|
|
|
|
DbCfg.User, DbCfg.Passwd, connType, DbCfg.Host, DbCfg.Name, Param, tls) |
|
|
|
|
case "postgres": |
|
|
|
|
connStr = getPostgreSQLConnectionString(DbCfg.Host, DbCfg.User, DbCfg.Passwd, DbCfg.Name, Param, DbCfg.SSLMode) |
|
|
|
|
case "mssql": |
|
|
|
|