config

package
v0.0.0-...-604005a Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigFilePath

func GetConfigFilePath() string

GetConfigFilePath 返回配置文件的路径

Types

type DockerConfig

type DockerConfig struct {
	NetworkMode  string `yaml:"network_mode"`  // none, host, bridge
	DisableCache bool   `yaml:"disable_cache"` // 是否禁用缓存
	Timeout      int    `yaml:"timeout"`       // 秒
	TempDir      string `yaml:"temp_dir"`
	MaxMemory    int64  `yaml:"max_memory"`  // MB
	CPULimit     string `yaml:"cpu_limit"`   // CPU限制 (如 "0.5")
	DockerHost   string `yaml:"docker_host"` // Docker守护进程地址
}

DockerConfig 表示Docker配置

type LangSpecificConfig

type LangSpecificConfig struct {
	Image          string   `yaml:"image"`
	Version        string   `yaml:"version"`
	CompileCommand []string `yaml:"compile_command"`
	RunCommand     []string `yaml:"run_command"`
	FileName       string   `yaml:"file_name"`
	Timeout        int      `yaml:"timeout"` // 秒
}

LangSpecificConfig 表示特定语言的配置

type LanguageConfig

type LanguageConfig struct {
	Go     LangSpecificConfig `yaml:"go"`
	Cpp    LangSpecificConfig `yaml:"cpp"`
	Java   LangSpecificConfig `yaml:"java"`
	Python LangSpecificConfig `yaml:"python"`
}

LanguageConfig 表示语言配置

type SandboxConfig

type SandboxConfig struct {
	Server   ServerConfig   `yaml:"server"`
	Docker   DockerConfig   `yaml:"docker"`
	Security SecurityConfig `yaml:"security"`
	Language LanguageConfig `yaml:"language"`
	Storage  StorageConfig  `yaml:"storage"`
}

SandboxConfig 表示沙盒配置

func DefaultConfig

func DefaultConfig() *SandboxConfig

DefaultConfig 返回默认配置

func Load

func Load(configPath string) (*SandboxConfig, error)

Load 从文件加载配置

type SecurityConfig

type SecurityConfig struct {
	DisableFork      bool     `yaml:"disable_fork"`
	DisableNetwork   bool     `yaml:"disable_network"`
	DisableFileWrite bool     `yaml:"disable_file_write"`
	MaxProcesses     int      `yaml:"max_processes"`
	BlockedSyscalls  []string `yaml:"blocked_syscalls"`
	WorkingDirSize   int64    `yaml:"working_dir_size"` // MB
}

SecurityConfig 表示安全配置

type ServerConfig

type ServerConfig struct {
	Port            int    `yaml:"port"`
	Host            string `yaml:"host"`
	MaxConcurrency  int    `yaml:"max_concurrency"`
	ShutdownTimeout int    `yaml:"shutdown_timeout"` // 秒
}

ServerConfig 表示服务器配置

type StorageConfig

type StorageConfig struct {
	Type string `yaml:"type"` // file, memory, etc.
	Path string `yaml:"path"` // 文件存储路径
}

StorageConfig 表示存储配置

Jump to

Keyboard shortcuts

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