util

package
v0.0.0-...-e15d3bc Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Address      = "http://" + config.GetEnvSettings().EnvironmentSettings.Sandbox.Address + ":" + strconv.Itoa(config.GetEnvSettings().EnvironmentSettings.Sandbox.Port)
	TimeLimit    = config.GetEnvSettings().EnvironmentSettings.Sandbox.TimeLimit * 1000 * 1000
	MemoryLimit  = config.GetEnvSettings().EnvironmentSettings.Sandbox.MemoryLimit * 1024 * 1024
	StackLimit   = config.GetEnvSettings().EnvironmentSettings.Sandbox.StackLimit * 1024 * 1024
	ProcLimit    = config.GetEnvSettings().EnvironmentSettings.Sandbox.ProcLimit
	CpuRateLimit = config.GetEnvSettings().EnvironmentSettings.Sandbox.CpuRateLimit
)

Functions

func ConnectDB

func ConnectDB()

func DeleteFile

func DeleteFile(fileid string)

func GetConn

func GetConn() *gorm.DB

func GetFile

func GetFile(fileid string) string

func HandleNoMethod

func HandleNoMethod(c *gin.Context)

func HandleNoRoute

func HandleNoRoute(c *gin.Context)

func NewCaptcha

func NewCaptcha(c *gin.Context)

图形验证码

func PathExists

func PathExists(path string) (bool, error)

func SendRunReqWithFileid

func SendRunReqWithFileid(fileId string, lanType string) (string, error)
{
    "cmd": [{
        "args": ["/usr/bin/g++", "a.cc", "-o", "a"],
        "env": ["PATH=/usr/bin:/bin"],
        "files": [{
            "content": ""
        }, {
            "name": "stdout",
            "max": 10240
        }, {
            "name": "stderr",
            "max": 10240
        }],
        "cpuLimit": 10000000000,
        "memoryLimit": 104857600,
        "procLimit": 50,
        "copyIn": {
            "a.cc": {
                "content": "#include <iostream>\nusing namespace std;\nint main() {\nint a, b;\ncin >> a >> b;\ncout << a + b << endl;\n}"
            }
        },
        "copyOut": ["stdout", "stderr"],
        "copyOutCached": ["a.cc", "a"],
        "copyOutDir": "1"
    }]
}

func SendStorageReq

func SendStorageReq(filePath string) (string, error)

func VerifyCaptcha

func VerifyCaptcha(captchaID string, captchaAns string) bool

Types

type Cmd

type Cmd struct {
	Args  []string  `json:"args"`
	Env   []string  `json:"env,omitempty"`
	Files []CmdFile `json:"files,omitempty"`

	CPULimit uint64 `json:"cpuLimit"`
	// RealCPULimit      uint64 `json:"realCpuLimit"`
	// ClockLimit        uint64 `json:"clockLimit"`
	MemoryLimit  uint64 `json:"memoryLimit"`
	StackLimit   uint64 `json:"stackLimit"`
	ProcLimit    uint64 `json:"procLimit"`
	CPURateLimit uint64 `json:"cpuRateLimit"`
	// CPUSetLimit       string `json:"cpuSetLimit"`
	// StrictMemoryLimit bool   `json:"strictMemoryLimit"`
	CopyIn  map[string]CmdFile `json:"copyIn"`
	CopyOut []string           `json:"copyOut"`
}

type CmdFile

type CmdFile struct {
	Src     string `json:"src,omitempty"`
	Content string `json:"content,omitempty"`
	FileID  string `json:"fileId,omitempty"`
	Name    string `json:"name,omitempty"`
	Max     int64  `json:"max,omitempty"`
	Pipe    bool   `json:"pipe,omitempty"`
}

type WholeFile

type WholeFile struct {
	Cmd []Cmd
}

Jump to

Keyboard shortcuts

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