{"id":15115022,"url":"https://github.com/mmozeiko/derpnet","last_synced_at":"2026-04-27T13:03:50.134Z","repository":{"id":256103745,"uuid":"851362732","full_name":"mmozeiko/derpnet","owner":"mmozeiko","description":"Network library in C for Windows","archived":false,"fork":false,"pushed_at":"2024-09-10T05:34:20.000Z","size":51,"stargazers_count":42,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-26T01:47:11.456Z","etag":null,"topics":["derp","encrypted","nat","network"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmozeiko.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}},"created_at":"2024-09-03T00:43:45.000Z","updated_at":"2024-09-20T20:31:03.000Z","dependencies_parsed_at":"2024-09-10T08:06:21.063Z","dependency_job_id":null,"html_url":"https://github.com/mmozeiko/derpnet","commit_stats":null,"previous_names":["mmozeiko/derpnet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmozeiko%2Fderpnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmozeiko%2Fderpnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmozeiko%2Fderpnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmozeiko%2Fderpnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmozeiko","download_url":"https://codeload.github.com/mmozeiko/derpnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234453720,"owners_count":18835113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["derp","encrypted","nat","network"],"created_at":"2024-09-26T01:43:39.258Z","updated_at":"2025-09-27T19:31:24.519Z","avatar_url":"https://github.com/mmozeiko.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# DerpNet\n\nSimple end-to-end encrypted network library in C for Windows.\n\nUses Tailscale [DERP][] relays for low bandwidth communications between\npeers. This allows exchanging data between peers even when both of them\nare behind NAT.\n\nCommunications are end-to-end encrypted. Nobody, even relays, cannot read\nmessages unless they have your PRIVATE key. You only need to share PUBLIC\nkey to others - which other users will use to send messages to you.\n\n# API\n\nLibrary is single file header: [derpnet.h][] - it has no other dependencies\nthan just Windows system libraries.\n\nBefore including define either `DERPNET_STATIC` or when using it in\nmultiple translation units define `DERPNET_IMPLEMENTATION` in one of them.\n\nTo generate new PRIVATE key and get PUBLIC key use these functions:\n\n```\nvoid DerpNet_CreateNewKey(DerpKey* UserSecret);\nvoid DerpNet_GetPublicKey(const DerpKey* UserSecret, DerpKey* UserPublic);\n```\n\nYou can generate as many keys as you want. They are not stored anywhere\nor used for any registration - it's up to you to manage these keys.\n\nTo connect or disconnect DERP network use:\n```\nbool DerpNet_Open(DerpNet* Net, const char* DerpServer, const DerpKey* UserSecret);\nvoid DerpNet_Close(DerpNet* Net);\n```\n\nYou can choose any server from [DERPMAP][] list. Peers that want to communicate\nmust be connected to the same region - they can be connected to different\nservers in the same region.\n\nTo send \u0026 receive data use:\n\n```\nbool DerpNet_Send(DerpNet* Net, const DerpKey* TargetUserPublicKey, const void* Data, size_t DataSize);\nint DerpNet_Recv(DerpNet* Net, DerpKey* ReceivedUserPublicKey, uint8_t** ReceivedData, uint32_t* ReceivedSize, bool Wait);\n```\n\nThere will be no confirmation if destination peer has received sent data.\nSend returns false if server disconnected.\n\nRecv call returns 1 when received data from other user - all data is received in\nthe same packet size as sent. It returns -1 if server disconnected. Or it returns\n0 if no data currently has been received. If Wait is set to true, then function\nwill never return 0 - function always will wait for new data to come in.\n\n# Examples\n\nTo compile examples simply run `cl.exe file.c` or `clang-cl.exe file.c`\n\nExample code is not optimized for robustness or performance. Many improvements are\npossible to improve error handling and performance. These are just examples.\n\n## derpnet_example\n\n[derpnet_example.c][] - example for API usage to send \u0026 receive message.\n\nTo receives messages, run:\n```\n$ derpnet_example.exe r\nMy PUBLIC key is: a0aaf4763ed56d734672e43b6ffbc9e185da7fda0b40b15c184c4b2385b6d213 - give this to others\nConnecting to server... OK!\nWaiting for messages...\n17998c85c4f1895170c7bfa28bc5a009c9101c652b921cb71ce1e7fcdcb7b24c: Hello World!\n```\n\nTo send a message, run:\n```\n$ derpnet_example.exe s a0aaf4763ed56d734672e43b6ffbc9e185da7fda0b40b15c184c4b2385b6d213 \"Hello World!\"\nConnecting to server... OK!\nSending message... OK!\n```\n\n## derpnet_file\n\n[derpnet_file.c][] - simple file sharing utility.\n\nTo receive file, run:\n```\n$ derpnet_file.exe r\nMy PUBLIC key is: 1fe6abe742051e8c78576e999d9423d3ae97495fafaadfcf9592b6e89d97a558\nConnecting to server... OK!\nWaiting for filename... receiving 'testfile.bin' file\nReceiving: 3808 KB - 470.70 KB/s\nDone!\nReceived 4189 KB in 9.0 seconds = 467.55 KB/s\n```\n\nTo send file - first get public key of receiver, then run:\n```\n$ derpnet_file.exe s 1fe6abe742051e8c78576e999d9423d3ae97495fafaadfcf9592b6e89d97a558 testfile.bin\nConnecting to server... OK!\nSending filename... OK!\nSending: 3936 KB - 482.23 KB/s\nDone!\nSent 4189 KB in 8.7 seconds = 479.26 KB/s\n```\n\n## derpnet_chat\n\n[derpnet_chat.c][] - simple terminal chat application.\n\nApplication sends messages only to single user, but receive messages from multiple ones.\n\nFor example, one user runs:\n```\n$ derpnet_chat.exe\nYour PRIVATE key is: 68246df0cc9bf7d752ab059e792e2219d84cbabf5fc2bae047280618467bf355 - do NOT share this with anyone!\nYour PUBLIC key is:  4cf72c3bf542d4dc3c6ccbf4b180acb0b07126180f78373da7fb24d9efe06a1f - give this to others\nConnecting to server... OK!\nEnter PUBLIC key of user to send messages to: ccec67d6ea737063c08b3ae9c33cfad5552863de9d8a7b96551afdc71f03370c\nEnter message to send: Hello!\nEnter message to send: Testing, 123\nReceived message from ccec67d6ea737063c08b3ae9c33cfad5552863de9d8a7b96551afdc71f03370c: yes, hello hello!\nEnter message to send: 456\nReceived message from ccec67d6ea737063c08b3ae9c33cfad5552863de9d8a7b96551afdc71f03370c: 123 and 456 received, thank you\nReceived message from ccec67d6ea737063c08b3ae9c33cfad5552863de9d8a7b96551afdc71f03370c: goodbye\n```\n\nAnd different user runs:\n```\n$ derpnet_chat.exe\nYour PRIVATE key is: d027684d931de511c6b0d1bec6e579df1aa31d48f2c635fac64b28557c57b473 - do NOT share this with anyone!\nYour PUBLIC key is:  ccec67d6ea737063c08b3ae9c33cfad5552863de9d8a7b96551afdc71f03370c - give this to others\nConnecting to server... OK!\nEnter PUBLIC key of user to send messages to: 4cf72c3bf542d4dc3c6ccbf4b180acb0b07126180f78373da7fb24d9efe06a1f\nReceived message from 4cf72c3bf542d4dc3c6ccbf4b180acb0b07126180f78373da7fb24d9efe06a1f: Hello!\nReceived message from 4cf72c3bf542d4dc3c6ccbf4b180acb0b07126180f78373da7fb24d9efe06a1f: Testing, 123\nEnter message to send: yes, hello hello!\nReceived message from 4cf72c3bf542d4dc3c6ccbf4b180acb0b07126180f78373da7fb24d9efe06a1f: 456\nEnter message to send: 123 and 456 received, thank you\nEnter message to send: goodbye\n```\n\n# derpnet_proxy\n\n[derpnet_proxy.c][] - TCP port tunneling.\n\nExample to create \"proxy\" by tunneling TCP port - this is similar to SSH tunneling\nbut just through DerpNet.\n\nFirst run `s` command to start server exposing port to DerpNet:\n```\n$ derpnet_proxy.exe s 8080\nMy PUBLIC key is: fdb10cf48b7945e3bc9f43c208382939fd9b7b30abd9db6365522271265a3f31\nConnecting to DERP server... OK!\nWaiting for remote connection...\nConnecting to '127.0.0.1:8080' ... OK! Connected!\n```\n\nThen run `c` command to connect to previous peer and accept connections on some port:\n```\n$ derpnet_proxy.exe c fdb10cf48b7945e3bc9f43c208382939fd9b7b30abd9db6365522271265a3f31 8123\nConnecting to DERP server... OK!\nListening on '127.0.0.1:8123' ... OK!\nWaiting for local connection... OK! Connected!\n```\nNow anybody connecting to `127.0.0.1:8123` will be actually having all their TCP\ntraffic redirected to first remote on port `8080`.\n\n# License\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\n\n[DERP]: https://tailscale.com/kb/1232/derp-servers\n[DERPMAP]: https://login.tailscale.com/derpmap/default\n[derpnet.h]: derpnet.h\n[derpnet_example.c]: derpnet_example.c\n[derpnet_file.c]: derpnet_file.c\n[derpnet_chat.c]: derpnet_chat.c\n[derpnet_proxy.c]: derpnet_proxy.c","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmozeiko%2Fderpnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmozeiko%2Fderpnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmozeiko%2Fderpnet/lists"}