feat: add additional configuration functions

This commit is contained in:
wpetit 2020-10-22 21:22:36 +02:00
parent 6e1aca1622
commit 1fc335418b
2 changed files with 12 additions and 0 deletions

View File

@ -31,6 +31,12 @@ func DefaultClientConfig() *ClientConfig {
} }
} }
func WithClientServerAddress(addr string) ClientConfigFunc {
return func(conf *ClientConfig) {
conf.ServerAddress = addr
}
}
func WithClientCredentials(credentials interface{}) ClientConfigFunc { func WithClientCredentials(credentials interface{}) ClientConfigFunc {
return func(conf *ClientConfig) { return func(conf *ClientConfig) {
conf.Credentials = credentials conf.Credentials = credentials

View File

@ -37,6 +37,12 @@ func DefaultServerConfig() *ServerConfig {
type ServerConfigFunc func(c *ServerConfig) type ServerConfigFunc func(c *ServerConfig)
func WithServerAddress(address string) ServerConfigFunc {
return func(conf *ServerConfig) {
conf.Address = address
}
}
func WithServerAESBlockCrypt(pass, salt string) ServerConfigFunc { func WithServerAESBlockCrypt(pass, salt string) ServerConfigFunc {
return func(conf *ServerConfig) { return func(conf *ServerConfig) {
key := pbkdf2.Key([]byte(pass), []byte(salt), 1024, 32, sha1.New) key := pbkdf2.Key([]byte(pass), []byte(salt), 1024, 32, sha1.New)