mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-07-04 15:32:19 +02:00
Compare commits
2 Commits
7dbcb18ebf
...
4971ad9d42
Author | SHA1 | Date | |
---|---|---|---|
|
4971ad9d42 | ||
|
192b777ac3 |
@ -19,6 +19,7 @@ package account
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"golang.org/x/crypto/argon2"
|
"golang.org/x/crypto/argon2"
|
||||||
)
|
)
|
||||||
@ -34,13 +35,13 @@ const (
|
|||||||
ArgonKeySize = 32
|
ArgonKeySize = 32
|
||||||
ArgonSaltSize = 16
|
ArgonSaltSize = 16
|
||||||
|
|
||||||
ArgonMaxInstances = 16
|
|
||||||
|
|
||||||
UUIDSize = 16
|
UUIDSize = 16
|
||||||
TokenSize = 32
|
TokenSize = 32
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
ArgonMaxInstances = runtime.NumCPU()
|
||||||
|
|
||||||
isValidUsername = regexp.MustCompile(`^\w{1,16}$`).MatchString
|
isValidUsername = regexp.MustCompile(`^\w{1,16}$`).MatchString
|
||||||
semaphore = make(chan bool, ArgonMaxInstances)
|
semaphore = make(chan bool, ArgonMaxInstances)
|
||||||
)
|
)
|
||||||
|
9
db/db.go
9
db/db.go
@ -21,9 +21,11 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
var handle *sql.DB
|
var handle *sql.DB
|
||||||
@ -36,7 +38,10 @@ func Init(username, password, protocol, address, database string) error {
|
|||||||
return fmt.Errorf("failed to open database connection: %s", err)
|
return fmt.Errorf("failed to open database connection: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.SetMaxOpenConns(1000)
|
handle.SetMaxIdleConns(256)
|
||||||
|
handle.SetMaxOpenConns(256)
|
||||||
|
handle.SetConnMaxIdleTime(time.Second * 30)
|
||||||
|
handle.SetConnMaxLifetime(time.Minute)
|
||||||
|
|
||||||
tx, err := handle.Begin()
|
tx, err := handle.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user