init: Initial commit

This commit is contained in:
Björn Benouarets
2025-12-15 14:13:43 +01:00
commit c6b269cf35
10 changed files with 657 additions and 0 deletions

37
app/config/config.go Normal file
View File

@@ -0,0 +1,37 @@
package config
import (
"fmt"
"os"
"gopkg.in/yaml.v3"
)
// Config represents the proxy configuration
type Config struct {
Listen struct {
Address string `yaml:"address"`
Port int `yaml:"port"`
} `yaml:"listen"`
Mappings []struct {
External string `yaml:"external"`
Internal string `yaml:"internal"`
Port int `yaml:"port"` // Optional, defaults to listen port
} `yaml:"mappings"`
Debug bool `yaml:"debug"`
}
// loadConfig loads configuration from YAML file
func LoadConfig(configPath string) (*Config, error) {
data, err := os.ReadFile(configPath)
if err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err)
}
var config Config
if err := yaml.Unmarshal(data, &config); err != nil {
return nil, fmt.Errorf("failed to parse config file: %w", err)
}
return &config, nil
}