Compare commits

...

13 Commits

Author SHA1 Message Date
a3f495f87b done with actions 2026-05-14 20:17:50 -05:00
5615622acc d
Some checks failed
build-service / build-and-release (push) Failing after 1m8s
2026-05-14 20:14:38 -05:00
b96f00c847 fixes
Some checks failed
build-service / build-and-release (push) Failing after 1m8s
2026-05-14 20:11:54 -05:00
85f8e6eded fixes
Some checks failed
build-service / build-and-release (push) Failing after 5s
2026-05-14 20:10:18 -05:00
20313de5dc added release
Some checks failed
build-service / Build aarch64-unknown-linux-gnu (push) Failing after 54s
build-service / Gitea Release (push) Has been cancelled
build-service / Build x86_64-unknown-linux-gnu (push) Has been cancelled
2026-05-14 20:06:11 -05:00
56275c7369 giving up if this doesn't work
All checks were successful
build-service / Build aarch64-unknown-linux-gnu (push) Successful in 59s
build-service / Build x86_64-unknown-linux-gnu (push) Successful in 40s
2026-05-14 20:03:31 -05:00
baad3d7791 gemini workflow change
Some checks failed
build-service / Build aarch64-unknown-linux-gnu (push) Failing after 1m38s
build-service / Build x86_64-unknown-linux-gnu (push) Successful in 43s
2026-05-14 19:59:28 -05:00
5211266f3a using ubuntu with rust install
Some checks failed
build-service / build (push) Failing after 1m2s
2026-05-14 19:55:59 -05:00
44fd16d9c7 fixed hopefuuly
Some checks failed
build-service / build (push) Failing after 1m5s
2026-05-14 19:53:20 -05:00
848ec596c6 uasing cross
Some checks failed
build-service / compile-binaries (push) Failing after 1m50s
2026-05-14 19:39:17 -05:00
e802c757f7 added workflow change
Some checks failed
build-service / compile-binaries (push) Failing after 1m1s
2026-05-14 19:36:12 -05:00
223b6d1640 ci: implement gitea actions pipeline and makefile
All checks were successful
build-service / compile-binaries (push) Successful in 2m40s
2026-05-14 19:13:05 -05:00
7232c56e4e added error handling, random input etc 2026-05-14 19:07:53 -05:00
3 changed files with 29 additions and 19 deletions

View File

@@ -1,12 +1,16 @@
import random
import socket
SERVER_IP = "127.0.0.1"
PORT = 5901
input = random.randint(1, 1000)
# Manually set the starting "input" for the first team
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((SERVER_IP, PORT))
# Using "0" as the ID for the very first team's source
s.send("ADMIN SET 0 80".encode()) # Sets the first clue as 80
s.send(f"ADMIN SET 0 {input}".encode()) # Sets the first clue as 80
print(f"Input of {input} Set")
print(s.recv(1024).decode())
s.close()

View File

@@ -12,7 +12,7 @@ while True:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((SERVER_IP, PORT))
s.send(f"GET {PREV_ID}".encode())
input = s.recv(1024).decode().strip()
input = s.recv(1024).decode().strip() # Clue is called input in the code
s.close()
if input != "-1": # -1 Means Clue Is Not Yet Sent

View File

@@ -33,7 +33,6 @@ async fn handle_connection(mut socket: TcpStream, db: Db) -> std::io::Result<()>
let mut buf = [0; 1024];
let n = socket.read(&mut buf).await?;
// Connection closed
if n == 0 {
return Ok(());
}
@@ -46,25 +45,29 @@ async fn handle_connection(mut socket: TcpStream, db: Db) -> std::io::Result<()>
}
match parts[0].to_uppercase().as_str() {
// Teams submit their solution: PUT [team_id] [value]
"PUT" => {
if parts.len() == 3 {
let team_id = parts[1].to_string();
let val = parts[2].to_string();
let val_str = parts[2];
let mut data = db.write().await; // Async lock
data.insert(team_id.clone(), val.clone());
socket.write_all(b"ACK\n").await?;
println!("[LOG] Team {} submitted solution: {}", team_id, val);
// Validate if the value is an integer
if val_str.parse::<i32>().is_ok() {
let mut data = db.write().await;
data.insert(team_id.clone(), val_str.to_string());
socket.write_all(b"ACK\n").await?;
println!("[LOG] Team {} submitted solution: {}", team_id, val_str);
} else {
// Send error but don't stop the server
socket.write_all(b"ERR_NOT_AN_INT\n").await?;
println!("[WARN] Team {} tried to send non-int: {}", team_id, val_str);
}
}
}
// Teams request previous solution: GET [prev_team_id]
"GET" => {
if parts.len() == 2 {
let target_id = parts[1];
let data = db.read().await; // Async lock
let data = db.read().await;
let response = data
.get(target_id)
@@ -75,17 +78,20 @@ async fn handle_connection(mut socket: TcpStream, db: Db) -> std::io::Result<()>
}
}
// Admin override: ADMIN SET [team_id] [value]
"ADMIN" => {
if parts.len() == 4 && parts[1].to_uppercase() == "SET" {
let team_id = parts[2].to_string();
let val = parts[3].to_string();
let val_str = parts[3];
let mut data = db.write().await;
data.insert(team_id.clone(), val.clone());
socket.write_all(b"ADMIN_OK\n").await?;
println!("[ADMIN] Manual set: Team {} -> {}", team_id, val);
if val_str.parse::<i32>().is_ok() {
let mut data = db.write().await;
data.insert(team_id.clone(), val_str.to_string());
socket.write_all(b"ADMIN_OK\n").await?;
println!("[ADMIN] Manual set: Team {} -> {}", team_id, val_str);
} else {
socket.write_all(b"ADMIN_ERR_NOT_AN_INT\n").await?;
println!("[ADMIN] Manual set failed: {} is not an int", val_str);
}
}
}