Skip to content

Commit 9f91efe

Browse files
committed
chore: make project OSS-friendly (license, CI, layout, source rename)
- Add MIT LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, CHANGELOG.md. - Add .editorconfig and .clang-format (extracted from the .vscode style pref). - Add CI workflow building on Ubuntu + macOS plus a curl smoke test, GitHub issue templates, and a PR template. - Move conf/grammar.md -> docs/grammar.md. - Move conf/servio.conf -> examples/servio.conf, add examples/minimal.conf (non-privileged port; used by CI). - Add docs/architecture.md describing the module tour and request lifecycle. - Rewrite README with badges, quick start, directive cheatsheet, layout map. - Rewrite Makefile: wildcard source discovery, build/ tree, MODE= asan/debug/release, install/uninstall, dependency files via -MMD -MP. - Drop the redundant sio_ filename prefix throughout src/ (the directory already namespaces files). A few files renamed for clarity: http_codes -> status_codes http_range -> range request_body -> body cmdline_opts -> options servio -> server (top-level core module) - Rename the static sio_sendfile helper to sendfileTo for consistency. - Update the CLI -h text (was advertising the wrong default config path). - Untrack runtime log placeholders (logs/*.log), add logs/.gitkeep. - Broaden .gitignore (.vscode/, .idea/, .dSYM/, build/, OS files).
1 parent 814199f commit 9f91efe

65 files changed

Lines changed: 818 additions & 362 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
BasedOnStyle: Google
3+
Standard: c++03
4+
IndentWidth: 4
5+
TabWidth: 4
6+
UseTab: ForIndentation
7+
IndentCaseLabels: false
8+
AlignConsecutiveDeclarations: true
9+
ColumnLimit: 0
10+
AllowShortFunctionsOnASingleLine: Inline
11+
AllowShortIfStatementsOnASingleLine: false
12+
AllowShortLoopsOnASingleLine: false
13+
PointerAlignment: Right
14+
SortIncludes: false
15+
SpaceAfterCStyleCast: false
16+
SpaceBeforeParens: ControlStatements
17+
BreakBeforeBraces: Attach
18+
NamespaceIndentation: None
19+
...

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.{cpp,hpp,tpp,c,h}]
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[Makefile]
14+
indent_style = tab
15+
16+
[*.{md,yml,yaml,json}]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[*.conf]
21+
indent_style = space
22+
indent_size = 4
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Report something that is not working as expected
4+
labels: bug
5+
---
6+
7+
## Description
8+
9+
A clear, concise description of what the bug is.
10+
11+
## Steps to reproduce
12+
13+
1. Run `./servio -c ...`
14+
2. Issue request `curl ...`
15+
3. Observe `<actual behavior>`
16+
17+
## Expected behavior
18+
19+
What you expected to happen instead.
20+
21+
## Environment
22+
23+
- OS / version (e.g. Ubuntu 22.04, macOS 14.4)
24+
- Compiler / version (`c++ --version`)
25+
- ServIO commit (`git rev-parse HEAD`)
26+
- Build flags (default debug+ASan? `make release`? other?)
27+
28+
## Relevant configuration
29+
30+
```nginx
31+
# paste the smallest config snippet that reproduces the issue
32+
```
33+
34+
## Logs / output
35+
36+
```
37+
# server stderr, curl -v output, ASan/UBSan reports, etc.
38+
```

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Security report
4+
url: https://github.com/BlaanTeam/serv-io/security/advisories/new
5+
about: Please report security vulnerabilities privately, not as a public issue.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Feature request
3+
about: Suggest a new directive, protocol feature, or improvement
4+
labels: enhancement
5+
---
6+
7+
## Summary
8+
9+
One or two sentences describing the feature.
10+
11+
## Motivation / use case
12+
13+
What are you trying to do? What's the workflow that this feature would
14+
enable or simplify?
15+
16+
## Proposed behavior
17+
18+
How would the feature work end-to-end? If it adds a new configuration
19+
directive, sketch the syntax and where it would live (HTTP / server /
20+
location block).
21+
22+
## Prior art
23+
24+
NGINX (or another server) directive name, RFC section, or related projects —
25+
anything that helps establish the expected semantics.
26+
27+
## Alternatives considered
28+
29+
What workarounds are available today, and why are they insufficient?

.github/pull_request_template.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Summary
2+
3+
<!-- 1-3 bullet points describing what changes and why. -->
4+
5+
## Test plan
6+
7+
<!--
8+
- [ ] `make re` succeeds (debug + ASan)
9+
- [ ] `make release` succeeds
10+
- [ ] `./servio -t -c examples/servio.conf` reports success
11+
- [ ] Smoke check: GET, range, upload all behave as expected
12+
-->
13+
14+
## Checklist
15+
16+
- [ ] Branched off the right base (`master` for stable, `v2` for the active
17+
development branch)
18+
- [ ] Commit messages follow Conventional Commits (`feat:`, `fix:`,
19+
`refactor:`, `chore:`, `docs:`)
20+
- [ ] `make format` was run (no whitespace-only churn introduced)
21+
- [ ] No `Co-Authored-By` trailer for AI assistants
22+
- [ ] CI is green

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [master, v2]
6+
pull_request:
7+
branches: [master, v2]
8+
9+
jobs:
10+
build:
11+
name: build (${{ matrix.os }})
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Linux build deps
22+
if: runner.os == 'Linux'
23+
run: |
24+
sudo apt-get update
25+
sudo apt-get install -y build-essential
26+
27+
- name: Build (debug + ASan)
28+
run: make -j$(getconf _NPROCESSORS_ONLN)
29+
30+
- name: Syntax-check example config
31+
run: ./servio -t -c examples/minimal.conf
32+
33+
- name: Smoke test (background server + curl)
34+
run: |
35+
./servio -c examples/minimal.conf &
36+
SERVIO_PID=$!
37+
sleep 1
38+
set -e
39+
curl -sS -o /tmp/index.html -w "GET / -> %{http_code}\n" http://localhost:8081/ | grep -q 200
40+
curl -sS -o /tmp/range.bin -H "Range: bytes=0-99" http://localhost:8081/ | true
41+
echo "hello-ci" > /tmp/ci.txt
42+
curl -sS -F file=@/tmp/ci.txt http://localhost:8081/upload | grep -qi "201\|Upload"
43+
kill $SERVIO_PID || true
44+
45+
- name: Build (release)
46+
run: |
47+
make fclean
48+
make release

.gitignore

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,38 @@
1-
# Created by https://www.toptal.com/developers/gitignore/api/c++
2-
# Edit at https://www.toptal.com/developers/gitignore?templates=c++
3-
4-
### C++ ###
5-
# Prerequisites
1+
# Compiled output
62
*.d
7-
8-
# Compiled Object files
9-
*.slo
10-
*.lo
113
*.o
124
*.obj
13-
14-
# Precompiled Headers
155
*.gch
166
*.pch
17-
18-
# Compiled Dynamic libraries
197
*.so
208
*.dylib
219
*.dll
22-
23-
# Fortran module files
24-
*.mod
25-
*.smod
26-
27-
# Compiled Static libraries
28-
*.lai
29-
*.la
3010
*.a
3111
*.lib
32-
33-
# Executables
12+
*.lai
13+
*.la
3414
*.exe
3515
*.out
3616
*.app
17+
*.dSYM/
3718
servio
3819

39-
# End of https://www.toptal.com/developers/gitignore/api/c++
20+
# Build directories
21+
build/
4022

41-
# ignore prefixed files with ign_*
42-
ign_*
23+
# Editor / IDE
24+
.vscode/
25+
.idea/
26+
*.swp
27+
*.swo
28+
*~
29+
30+
# OS
31+
.DS_Store
32+
Thumbs.db
4333

34+
# Logs (runtime-generated)
35+
logs/*.log
4436

45-
# ignore the html folder
46-
html/*
37+
# Project convention: ignore prefixed scratch files
38+
ign_*

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Changelog
2+
3+
All notable changes to ServIO are documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and the project tries to follow [Semantic Versioning](https://semver.org/).
7+
8+
## [Unreleased] — v2 branch
9+
10+
### Added
11+
- `StreamSearch` — a streamsearch-inspired needle scanner used to find
12+
multipart boundaries across `recv()` chunks without per-byte stream reads.
13+
- `sendfile(2)` path for static file responses (Darwin + Linux, with a
14+
`pread + send` fallback for other platforms). Range responses pass the
15+
kernel an offset directly.
16+
- OSS scaffolding: `LICENSE` (MIT), `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`,
17+
`SECURITY.md`, `CHANGELOG.md`, `.editorconfig`, `.clang-format`,
18+
GitHub issue and pull request templates, CI workflow.
19+
- `docs/architecture.md` and `docs/grammar.md` (moved from `conf/`).
20+
- `examples/servio.conf` (sample configuration).
21+
22+
### Changed
23+
- Request parser is now `(const char*, size_t)`-driven instead of being fed
24+
from a `queue<stringstream*>`. The first-line and header parsers are a
25+
small byte-oriented state machine with length-bounded URI and header
26+
lines and CRLF/LF tolerance.
27+
- Body parsers (lengthed / chunked / multipart) share a single
28+
bytes-consumed contract. Multipart writes part data straight from the
29+
recv buffer to per-part tmp files.
30+
- `recv()` buffer bumped from 1 KiB to 16 KiB.
31+
- Source files dropped the redundant `sio_` prefix (the directory already
32+
namespaces them); a handful were renamed for clarity
33+
(`http_codes``status_codes`, `request_body``body`,
34+
`cmdline_opts``options`, `utils``time_utils`,
35+
`servio.cpp``server.cpp`).
36+
- Build artifacts now land in `build/` instead of polluting `src/`.
37+
38+
### Fixed
39+
- Replaced the deprecated `sprintf` in `Content-Range` formatting with
40+
`snprintf`, restoring the `-Werror` build on recent toolchains.
41+
- Self-referential `Body`/`Request` state no longer dangles when these
42+
objects are copied through `ClientMap` (`Body` is now its own
43+
`StreamSearch::Sink`).
44+
45+
## [1.0.0] — initial release
46+
47+
- HTTP/1.1 server inspired by NGINX configuration syntax.
48+
- Static file serving, CGI, file uploads, redirects, virtual hosts, range
49+
requests, directory listings, custom error pages.
50+
- `poll(2)`-driven non-blocking I/O.

CODE_OF_CONDUCT.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic
9+
status, nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our standards
16+
17+
Examples of behavior that contributes to a positive environment:
18+
19+
- Demonstrating empathy and kindness toward other people
20+
- Being respectful of differing opinions, viewpoints, and experiences
21+
- Giving and gracefully accepting constructive feedback
22+
- Accepting responsibility and apologizing to those affected by our mistakes,
23+
and learning from the experience
24+
- Focusing on what is best not just for us as individuals, but for the overall
25+
community
26+
27+
Examples of unacceptable behavior:
28+
29+
- The use of sexualized language or imagery, and sexual attention or advances
30+
- Trolling, insulting or derogatory comments, and personal or political
31+
attacks
32+
- Public or private harassment
33+
- Publishing others' private information without their explicit permission
34+
- Other conduct which could reasonably be considered inappropriate in a
35+
professional setting
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
40+
reported to the maintainers at the email address listed in the project's
41+
GitHub profile. All complaints will be reviewed and investigated promptly and
42+
fairly.
43+
44+
## Attribution
45+
46+
This Code of Conduct is adapted from the
47+
[Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).

0 commit comments

Comments
 (0)