working commit

This commit is contained in:
2026-06-07 15:06:37 +02:00
parent 52dd2cef20
commit c656b562d8
17 changed files with 291 additions and 85 deletions
+6 -10
View File
@@ -15,9 +15,9 @@ import (
const (
defaultHostname = "localhost"
configFilename = "maind.yaml"
logFilename = "maind.log"
pidFilename = "maind.pid"
configFilename = "mbased.yaml"
logFilename = "mbased.log"
pidFilename = "mbased.pid"
)
var (
@@ -93,12 +93,6 @@ func (conf *Config) ReadFile() error {
if err != nil {
return err
}
conf.Normalize()
err = conf.Validate()
if err != nil {
return err
}
return nil
}
@@ -140,10 +134,12 @@ func (conf *Config) String() (string, error) {
return res, err
}
func (conf *Config) Normalize() {
func (conf *Config) Normalize() error {
var err error
if conf.Service.Portnum == 0 {
conf.Service.Portnum = client.DefaultPort
}
return err
}
func (conf *Config) Validate() error {
+1 -1
View File
@@ -23,7 +23,7 @@ func (hand *Handler) Authentificate(ctx context.Context) (string, error) {
}
username := meta["username"][0]
password := meta["password"][0]
validated, accountID, err := hand.lg.ValidateAcount(ctx, username, password)
validated, accountID, err := hand.lg.ValidateAccount(ctx, username, password)
if !validated {
err := status.Errorf(codes.PermissionDenied, "Wrong auth data")
return accountID, err
+1 -1
View File
@@ -56,7 +56,7 @@ func NewDatabase(datapath string) (*Database, error) {
func (db *Database) OpenDatabase() error {
var err error
dbPath := filepath.Join(db.datapath, "certmanager.db")
dbPath := filepath.Join(db.datapath, "main.db")
db.db, err = sqlx.Open("sqlite3", dbPath)
if err != nil {
return err
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"mbase/pkg/mbctl"
)
func (lg *Logic) ValidateAcount(ctx context.Context, username, password string) (bool, string, error) {
func (lg *Logic) ValidateAccount(ctx context.Context, username, password string) (bool, string, error) {
var err error
var accountID string
var valid bool
+2 -2
View File
@@ -10,8 +10,8 @@ import (
)
const (
defaultSeedUsername = "certman"
defaultSeedPassword = "certman"
defaultSeedUsername = "mbase"
defaultSeedPassword = "mbase"
)
func (lg *Logic) CleanDatabase(ctx context.Context) error {
+1 -1
View File
@@ -62,7 +62,7 @@ func (srv *Server) Configure() error {
if err != nil {
return err
}
srv.sfile = filepath.Join(srv.conf.DataDir, "certmanager.yaml")
srv.sfile = filepath.Join(srv.conf.DataDir, "mbase.yaml")
return err
}