1
0
Esse commit está contido em:
Your Name
2026-04-26 22:00:03 +08:00
commit 2a97f458a9
11 arquivos alterados com 888 adições e 53 exclusões
+20 -6
Ver Arquivo
@@ -3,8 +3,8 @@ package config
import (
"encoding/json"
"fmt"
"os"
"network-topology-discovery/pkg/models"
"os"
)
// Config 应用配置
@@ -14,16 +14,17 @@ type Config struct {
SSH SSHConfig `json:"ssh"`
Web WebConfig `json:"web"`
Scanner ScannerConfig `json:"scanner"`
Auth AuthConfig `json:"auth"`
}
// DeviceConfig 设备配置
type DeviceConfig struct {
IP string `json:"ip"`
IP string `json:"ip"`
Type models.DeviceType `json:"type"`
Username string `json:"username"`
Password string `json:"password"`
KeyFile string `json:"key_file"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
KeyFile string `json:"key_file"`
Port int `json:"port"`
}
// SSHConfig SSH配置
@@ -39,6 +40,13 @@ type WebConfig struct {
Host string `json:"host"`
}
// AuthConfig 认证配置
type AuthConfig struct {
Enabled bool `json:"enabled"`
Username string `json:"username"`
Password string `json:"password"`
}
// ScannerConfig 扫描器配置
type ScannerConfig struct {
Concurrency int `json:"concurrency"`
@@ -122,4 +130,10 @@ func (c *Config) setDefaults() {
if c.Scanner.Timeout == 0 {
c.Scanner.Timeout = 2
}
if c.Auth.Enabled && c.Auth.Username == "" {
c.Auth.Username = "admin"
}
if c.Auth.Enabled && c.Auth.Password == "" {
c.Auth.Password = "admin"
}
}