Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/.vscode
/.vscode
/testing_staff
164 changes: 154 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "casino_contest"
name = "easy_contest"
version = "0.1.0"
edition = "2024"

[features]
root=[]

[dependencies]
nix = "0.29.0"
libc = "0.2.172"
nix = "0.30.1"
shellexpand = "3.0"
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[растпобеда.рф](https://растпобеда.рф)

# **EasyContest**
EasyContest - one day this will be a selfmade programming contest platform focused on ease of use and extendability, but now it's just beginning)

## Container module
Incapsulates running compiled executables in separate "container jail" with limited resources and permissions. Right on only statically linked binaries supported.
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Incapsulates' to 'Encapsulates'.

Suggested change
Incapsulates running compiled executables in separate "container jail" with limited resources and permissions. Right on only statically linked binaries supported.
Encapsulates running compiled executables in separate "container jail" with limited resources and permissions. Right on only statically linked binaries supported.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammatical error: 'Right on only' should be 'Right now only' or 'Currently only'.

Suggested change
Incapsulates running compiled executables in separate "container jail" with limited resources and permissions. Right on only statically linked binaries supported.
Incapsulates running compiled executables in separate "container jail" with limited resources and permissions. Right now, only statically linked binaries are supported.

Copilot uses AI. Check for mistakes.

In `container.conf` you set your own settings to run executable

8 changes: 8 additions & 0 deletions container.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
RAM_LIMIT=# memory limit in B, MB, KB, GB
CPU_LIMIT=# cpu limit in percents (optional, 100% by default)
TIME_LIMIT=# time limit in seconds (optional, no limit by default)
JAIL_DIR=# directory to store container jails
EXE_PATH=# path to the compiled, statically linked executable
STDIN_PATH=# path to redirected stdin file (optional)
STDOUT_PATH=# path to redirected stdout file (optional)
STDERR_PATH=# path to redirected stderr file (optional)
40 changes: 40 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use std::io::{BufRead, BufReader};

#[macro_export]
macro_rules! mem_size {
($value:expr, B) => {
$value
};

($value:expr, KB) => {
$value * 1024
};

($value:expr, MB) => {
$value * 1024 * 1024
};

($value:expr, GB) => {
$value * 1024 * 1024 * 1024
};
}

pub fn get_from_config(variable: &str) -> Option<String> {
let conf_file = std::fs::OpenOptions::new()
.read(true)
.open("./container.conf")
.expect("Opening .conf file");

let conf_file = BufReader::new(conf_file);
for line in conf_file.lines() {
let line = line.expect("Reading line from .conf");

if let Some((key, val)) = line.split_once('=') {
if key == variable && !val.trim().starts_with('#') {
return Some(val.trim().to_string());
}
}
}

None
}
Loading