{"id":25184006,"url":"https://github.com/samicpp/tcp-services","last_synced_at":"2026-03-10T14:32:11.905Z","repository":{"id":268118290,"uuid":"903349306","full_name":"samicpp/tcp-services","owner":"samicpp","description":"A webserver that fully supports HTTP/1.1, WebSocket and HTTP/2 with TLS","archived":false,"fork":false,"pushed_at":"2025-07-10T20:13:03.000Z","size":20295,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-11T02:28:50.690Z","etag":null,"topics":["deno","http","http-server","http2","http2-server","library","server","tls-support","typescript","webserver","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samicpp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-14T11:29:45.000Z","updated_at":"2025-04-14T18:48:19.000Z","dependencies_parsed_at":"2024-12-14T13:40:21.869Z","dependency_job_id":"0d486586-4530-4803-84e0-bb2823b9ab7c","html_url":"https://github.com/samicpp/tcp-services","commit_stats":null,"previous_names":["samicpp/tcp-services"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/samicpp/tcp-services","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samicpp%2Ftcp-services","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samicpp%2Ftcp-services/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samicpp%2Ftcp-services/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samicpp%2Ftcp-services/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samicpp","download_url":"https://codeload.github.com/samicpp/tcp-services/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samicpp%2Ftcp-services/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30337214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T12:41:07.687Z","status":"ssl_error","status_checked_at":"2026-03-10T12:41:06.728Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","http","http-server","http2","http2-server","library","server","tls-support","typescript","webserver","websocket"],"created_at":"2025-02-09T19:19:53.585Z","updated_at":"2026-03-10T14:32:11.864Z","avatar_url":"https://github.com/samicpp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tcp Services\nThis project consists of 2 parts: [A library (`engine.ts`)](#engine) and [a handler](#http-serverts) (`http-server.ts` and `main.ts`)\n\n## HTTP\n- [`./engine`](#enginets): HTTP connection handling. [Module](/engine).\n- [`http-server.ts`](#http-serverts): Complex HTTP server using `engine.ts`. [File](/http-server.ts).\n- [`main.ts`](#maints): Responsible for setting up the HTTP server with `http-server.ts` and `engine.ts`. [File](/main.ts).\n\nThis server is running on [www.cppdev.dev](https://www.cppdev.dev/?reff=github). If anything peculiar happens please notify me by [mail](https://gmail.com) to [sami.cplusplus0@gmail.com](mailto:sami.cplusplus0@gmail.com) or make an issue. Same goes for feature requests.\n\n### engine\nA web handling library.\nHandles HTTP/1.1 HTTP/2.0 and WebSockets starting from the TCP/TLS level.\nA simple example is located in `local-test1.sh`.\nTo use it for yourself, youll need to import `./engine/mod.ts`, all methods combined from the import make up Engine.\nYou can also use specific parts such as the HTTP/2.0 handler alone.\nTypes specified in `./engine/lib.engine.d.ts`\n\n\n### http-server.ts\nThis is a webhandler with some complexity that uses [engine.ts](#enginets) for TCP/HTTP handling. See [Behaviour](#behaviour) for more details.\nOn its own this module only exports the handling functions and doesnt actually start a server.\nThis file is located at [`/http-server.ts`](/http-server.ts).\n\n#### Behaviour\nIf the path is a directory it will look for `index.*` or will look for a file that starts with the name of its parent directory.\n\nThe server will read and parse `config.json` everytime when a request happens and will look up which directory it needs to look in based of the hostname and port and will then add the result to `./http/` and read the file starting form that directory. This is stored in SpecialURL.tardir. Optionably can also use a router file.\n\nPaths to directories dont need to start with `/` and files are allowed to end with `/`.\n\nWhen an error occours it will use the error files located in SpecialURL.tardir+`/errors/`+status code.\nIf it can't find an error file it wll send out a default response.\n\nWill cache certain responses and all files. Customizable with the variable `cacheTIme` with miliseconds in `http-server.ts:20:23`.\n\n##### config.json\nIn here you can route certain hosts to certain directories. E.g. upgrade http connections to https.\n\nIn config.json a property is read based of this format: `protocol(commonly http or https)://hostname:port(if applicable. think of defualt port like 80 and 443)`.\nThe value of said property is another json object with 2 properties, where's the second one not mandatory\n- `dir`: Specify the directory which will be looked in. Is a string.\n- `router`: Specify the filename of the router. Is a string and optionable.\n\n#### Dynamic files:\n- `*.dyn.*`: Execute it as a multi line string with parameters Engine.HttpSocket, SpecialURL, the file location as a string. Content type is the same as the file extension\n- `*.mod.ts`: Imports the file, stores the module and first invokes `init` and later invokes `default` with Engine.HttpSocket, SpecialURL, the file location as a string.\n- `*.async.js`: Turns the file into an async function and invokes it with Engine.HttpSocket, SpecialURL, the file location as a string.\n- `*.link`: Contains the path of another file which will be processed as if it were the original file.\n- `*.proxy.json`: Parses the json file and will fetch the destination and show that to the client.\n- `*.ai.json`: Uses ai to generate a response.\n\n\n##### Router files\nThese type of files will be used regardless of the pathname. Can be used for sites independent of the page.\n\nIf said file is a dynamic file (think of `.deno.ts` or `.async.js`) you could continue the connection like normal. The additional parameter `opt` will contain things like the original path to get files, all error handlers, file handler, directory handler and default handler.\n\n### main.ts\nImports engine.ts, http-server.ts and starts a server.\nYou can configure this server with cli parameters or with an .env file.\n- `--http=PORT`: A port to listen on without tls. Can be used multiple times for multiple ports.\n- `--https=PORT`: A port to listen on with tls. Can also be used multiple times for multiple ports.\n- `--dyn=PORT`: A port to listen on with a proxy. The proxy will automatically upgrade the connection to tls if a tls connection was attempted to make (think tls over port 80). The original ip address is given without showing `lo` addresses (like `127.0.0.1`) unlike normally seen with proxies.\n\n#### Env file.\nThe env file contains things like the tls cert paths.\nYou can find the most recent env files in [`example.env`](/example2.env) and [`example2.env`](/example2.env).\nThis is taken from `example.env` at Tuesday March 04 2025 13:45:21 GMT+0100 (Central-European standard time).\n```env\n# main.ts\nenvonly=\"1\"\n\ndyn=\"\"\nhttp=\"8080\"\nhttps=\"1443\"\n\nsilent=\"0\"\n\nuseTls=\"1\"\nkeyfile=\"./localhost.key\"\ncertfile=\"./localhost.crt\"\ncafile=\"\"\nalpn=\"h2;http/1.1\"\n\nlogcatfile=\"./logcat.log\"\nloglevels=\"debug;debug2;info;log;log2;log3;warn;warn2;error;error2\"\n\n# http-server.ts\nopenai_key=\"api key\"\n\ndissallow=\".no;.not\"\n```\nThis example might not be up-to-date.\n\n##### Properties\n- `dissallow`: `http-server.ts` wont send a response if the file ends with any of those file extensions (seperated by `;`).\n- `logcatfile`: Stores console output in there.\n- `loglevels`: Contains a list of log levels (such as `error`, `log`, and `debug`) to output to stdout.\n- `envonly`: Makes `main.ts` ingore cli params.\n- `dyn` `http` `https`: Acts like the cli params `dyn` `http` `https`.\n- `silent`: Won't write logs to stdout.\n- `alpn`: ALPN list seperated by `;`.\n- `useTls`: If `1` will try to read the tls files, if `0` won't.\n- `openai_key`: Contains an openai api key for `*.ai.json` files (Dynamic files)[#dynamicfiles]\n\n#### Run examples\n```bash\n# Run tls and plain tcp on both port 80 and 443\ndeno run --allow-read --allow-write --allow-net ./main.ts --dyn=80 --dyn=443\n\n\n# Standard server\ndeno run --allow-read --allow-write --allow-net ./main.ts --http=80 --https=443\n\n# Env only\ndeno run --allow-read --allow-write --allow-net --env-file ./main.ts\n```\n\n# TODO\nThis is a list of things i might implement in the future.\n\n- [ ] Fix elsint to make project compilable.\n- [x] Make todo list.\n\n## engine.ts\n - [ ] Fix client data reading.\n - [ ] ~~Full HTTP/3 support~~ (no QUIC support).\n - [x] Store system headers (things like `Content-Length`) separate from user configurable headers.\n - [x] Full HTTP/2 support (not just translation).\n - [ ] Fix HPACK decoding.\n\n## http-server.ts\n- [ ] Support FFI and WASM dynamic files.\n- [ ] Improve configurability (e.g. variable error paths).\n\n## main.ts\n- [ ] Read and eval stdin input.\n- [ ] Better CLI arguments.\n- [x] Env support\n\n## ~~tcp-proxy.ts~~\n- [ ] ~~Make the service.~~\n- [ ] ~~TLS decryption.~~\n\n# Credits\nThis project makes use of [Dancrumb's](https://github.com/dancrumb) [hpack repo](https://github.com/dancrumb/hpack).\n\n# License\n\nThis project and everything in it is licensed under the GNU General Public License v3.0. See the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamicpp%2Ftcp-services","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamicpp%2Ftcp-services","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamicpp%2Ftcp-services/lists"}