config

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultJWTSecret = "relaymesh-secret-key-change-in-production"

DefaultJWTSecret 是历史版本内置的 JWT 签名密钥默认值。

它随开源代码公开,任何人都能用它伪造管理员令牌,因此现在只作为「未配置」的哨兵值: 启动时若环境变量缺省或强度不足,会被自动生成并持久化的随机密钥取代,永远不会被用于签名。

View Source
const (
	// MinJWTSecretLength 是 JWT 签名密钥的最小字节数(HS256 至少应有 256 bit 熵的量级,README 亦要求不少于 32 字符)。
	MinJWTSecretLength = 32
)

Variables

This section is empty.

Functions

func EnsureDataDir added in v1.2.0

func EnsureDataDir(dataDir string) error

EnsureDataDir creates the data directory and its certs subdirectory with secure permissions (0700).

func IsStrongJWTSecret added in v1.6.3

func IsStrongJWTSecret(secret string) bool

IsStrongJWTSecret 是 JWTSecretWeakness 的布尔形式,供终端硬门禁等需要「是/否」判断的场景使用。

func JWTSecretWeakness added in v1.6.3

func JWTSecretWeakness(secret string) string

JWTSecretWeakness 判断 JWT 签名密钥是否足够强。返回空字符串表示合格,否则返回不合格的原因(不含密钥内容,可安全写入日志)。

func ResolveDataDir added in v1.2.0

func ResolveDataDir(mode string) string

ResolveDataDir resolves the base directory for database and certificates based on the runtime mode. For "stdio" mode, it defaults to the OS-standard user data directory to avoid polluting the workspace. For "serve" mode (or empty), it defaults to the relative "data" directory to preserve backward compatibility.

Types

type Config

type Config struct {
	Mode                     string
	DataDir                  string
	Host                     string
	Port                     int
	HostName                 string
	DBPath                   string
	ProjectID                string
	MCPToken                 string
	ConfigureToken           string
	ExecutionToken           string
	WebUsername              string
	WebPassword              string
	JWTSecret                string
	AllowNonLoopback         bool
	TrustedProxies           string // RELAYMESH_TRUSTED_PROXIES,语义与校验见 api.ResolveTrustedProxies
	WaitAfterMinutes         int
	MaxNoFeedbackChecks      int
	WaitInstruction          string
	WaitExhaustedInstruction string
	FeedbackTimeoutSeconds   int
	WaitCountdownMinutes     int
	ASRAPIURL                string
	ASRAPIKey                string
	ASRModel                 string
	HTTPSPort                int
	TLSEnabled               bool
	TLSCertPath              string
	TLSKeyPath               string
	DevMode                  bool
	AutoOpenBrowser          bool
	Version                  string
}

func Load

func Load() *Config

func LoadWithMode added in v1.2.0

func LoadWithMode(mode string) *Config

LoadWithMode loads configuration tailored for the given runtime mode ("serve" or "stdio").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL