From a2dfee4a770d324f34a166eeeb43c2f15b9b8deb Mon Sep 17 00:00:00 2001 From: perp Date: Thu, 6 Jun 2024 19:15:27 +0100 Subject: [PATCH] Removed address, added host and port, removed comments --- cmd/config.toml | 29 +++++++++-------------------- internal/config/config.go | 33 ++++++++++----------------------- internal/config/parse.go | 14 -------------- 3 files changed, 19 insertions(+), 57 deletions(-) diff --git a/cmd/config.toml b/cmd/config.toml index aeaad51..f8fcd68 100644 --- a/cmd/config.toml +++ b/cmd/config.toml @@ -1,33 +1,22 @@ -[auth] -# JWT secret -secret = "a secret" -# Disable registration -disabled = false -# bcrypt cost -# https://pkg.go.dev/golang.org/x/crypto/bcrypt#pkg-constants -cost = 10 - [server] -# Listener address -address = "127.0.0.1:8080" -# Read & write timeout -# Warning: Too high can -# cause a slowloris attack +host = "127.0.0.1" +port = 8080 read_timeout = 10 write_timeout = 10 [database] -# Supported drivers: -# sqlite3 driver = "sqlite3" -# URL (For sqlite, use the path) url = "gopay.db" -# Max connections max = 30 -# Max idle connections idle = 30 +[auth] +secret = "a secret" +register = false +# https://pkg.go.dev/golang.org/x/crypto/bcrypt#pkg-constants +cost = 10 + + [log] -# Level for database and server # https://pkg.go.dev/github.com/rs/zerolog#Level level = "debug" diff --git a/internal/config/config.go b/internal/config/config.go index a1e1762..0dd18e7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,37 +1,17 @@ -// Copyright 2024 perp (supernets) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package config // Configuration type Config struct { - Auth *Auth Server *Server Database *Database + Auth *Auth Log *Log } -// Auth configuration -type Auth struct { - Secret string `toml:"secret"` - Disabled bool `toml:"disabled"` - Cost int `toml:"cost"` -} - // Server configuration type Server struct { - Address string `toml:"address"` + Host string `toml:"host"` + Port int `toml:"port"` ReadTimeout int `toml:"read_timeout"` WriteTimeout int `toml:"write_timeout"` } @@ -44,6 +24,13 @@ type Database struct { Idle int `toml:"idle"` } +// Auth configuration +type Auth struct { + Secret string `toml:"secret"` + Register bool `toml:"register"` + Cost int `toml:"cost"` +} + // Log configuration type Log struct { Level string `toml:"level"` diff --git a/internal/config/parse.go b/internal/config/parse.go index c9494ce..d36522e 100644 --- a/internal/config/parse.go +++ b/internal/config/parse.go @@ -1,17 +1,3 @@ -// Copyright 2024 perp (supernets) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package config import (