{"id":13840551,"url":"https://github.com/heiher/hev-socks5-core","last_synced_at":"2025-05-14T03:32:19.658Z","repository":{"id":38194373,"uuid":"366426168","full_name":"heiher/hev-socks5-core","owner":"heiher","description":"A simple, lightweight socks5 library. (IPv4/IPv6/TCP/UDP/Client/Server)","archived":false,"fork":false,"pushed_at":"2024-08-02T10:13:04.000Z","size":169,"stargazers_count":32,"open_issues_count":0,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-05T17:25:13.641Z","etag":null,"topics":["library","socks5","tcp","udp"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heiher.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":"2021-05-11T15:14:09.000Z","updated_at":"2024-07-27T06:19:52.000Z","dependencies_parsed_at":"2024-04-09T16:00:03.801Z","dependency_job_id":"ecd5e80e-4264-4d2b-a2ca-cf5e1a4a77bb","html_url":"https://github.com/heiher/hev-socks5-core","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiher%2Fhev-socks5-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiher%2Fhev-socks5-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiher%2Fhev-socks5-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heiher%2Fhev-socks5-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heiher","download_url":"https://codeload.github.com/heiher/hev-socks5-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225274873,"owners_count":17448345,"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":["library","socks5","tcp","udp"],"created_at":"2024-08-04T17:00:50.271Z","updated_at":"2025-05-14T03:32:19.652Z","avatar_url":"https://github.com/heiher.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# HevSocks5Core\n\nHevSocks5Core is a simple, lightweight socks5 library.\n\n**Features**\n* IPv4/IPv6. (dual stack)\n* Standard `CONNECT` command.\n* Standard `UDP ASSOCIATE` command.\n* Extended `FWD UDP` command. (UDP in TCP)\n* Multiple username/password authentication.\n\n**Dependencies**\n* HevTaskSystem - https://github.com/heiher/hev-task-system\n\n## Examples\n\n### Server\n\n```c\n#include \u003cunistd.h\u003e\n\n#include \u003chev-task.h\u003e\n#include \u003chev-task-io.h\u003e\n#include \u003chev-task-io-socket.h\u003e\n#include \u003chev-task-dns.h\u003e\n#include \u003chev-task-system.h\u003e\n\n#include \u003chev-socks5-server.h\u003e\n\nstatic void\nserver_entry (void *data)\n{\n    HevSocks5Server *server = data;\n    hev_socks5_server_run (server);\n    hev_object_unref (HEV_OBJECT (server));\n}\n\nstatic void\nlistener_entry (void *data)\n{\n    struct addrinfo hints = { 0 };\n    struct addrinfo *result;\n    int fd;\n\n    hints.ai_family = AF_INET6;\n    hints.ai_socktype = SOCK_STREAM;\n    hints.ai_flags = AI_PASSIVE;\n\n    hev_task_dns_getaddrinfo (NULL, \"1080\", \u0026hints, \u0026result);\n    fd = hev_task_io_socket_socket (AF_INET6, SOCK_STREAM, 0);\n    bind (fd, result-\u003eai_addr, result-\u003eai_addrlen);\n    freeaddrinfo (result);\n    listen (fd, 5);\n\n    hev_task_add_fd (hev_task_self (), fd, POLLIN);\n\n    for (;;) {\n        HevSocks5Server *server;\n        HevTask *task;\n        int nfd;\n\n        nfd = hev_task_io_socket_accept (fd, NULL, NULL, NULL, NULL);\n\n        task = hev_task_new (-1);\n        server = hev_socks5_server_new (nfd);\n        hev_task_run (task, server_entry, server);\n    }\n\n    close (fd);\n}\n\nint\nmain (int argc, char *argv[])\n{\n    HevTask *task;\n\n    hev_task_system_init ();\n\n    task = hev_task_new (-1);\n    hev_task_run (task, listener_entry, NULL);\n\n    hev_task_system_run ();\n\n    hev_task_system_fini ();\n\n    return 0;\n}\n```\n\n### Client\n\n```c\n#include \u003cstddef.h\u003e\n\n#include \u003chev-task.h\u003e\n#include \u003chev-task-system.h\u003e\n#include \u003chev-socks5-client-tcp.h\u003e\n#include \u003chev-socks5-client-udp.h\u003e\n\nstatic void\ntcp_client_entry (void *data)\n{\n    HevSocks5ClientTCP *tcp;\n\n    tcp = hev_socks5_client_tcp_new_name (\"www.google.com\", 443);\n    hev_socks5_client_connect (HEV_SOCKS5_CLIENT (tcp), \"127.0.0.1\", 1080);\n    hev_socks5_client_handshake (HEV_SOCKS5_CLIENT (tcp));\n\n    /*\n     * splice data to/from a socket fd:\n     *     hev_socks5_tcp_splice (HEV_SOCKS5_TCP (tcp), fd);\n     */\n\n    hev_object_unref (HEV_OBJECT (tcp));\n}\n\nstatic void\nudp_client_entry (void *data)\n{\n    HevSocks5ClientUDP *udp;\n\n    udp = hev_socks5_client_udp_new (HEV_SOCKS5_TYPE_UDP_IN_TCP);\n    hev_socks5_client_connect (HEV_SOCKS5_CLIENT (udp), \"127.0.0.1\", 1080);\n    hev_socks5_client_handshake (HEV_SOCKS5_CLIENT (udp));\n\n    /*\n     * HevSocks5Addr addr;\n     *\n     * send udp packet:\n     *     hev_socks5_udp_sendto (HEV_SOCKS5_UDP (udp), data, len, \u0026addr);\n     *\n     * recv udp packet:\n     *     hev_socks5_udp_recvfrom (HEV_SOCKS5_UDP (udp), data, len, \u0026addr);\n     */\n\n    hev_object_unref (HEV_OBJECT (udp));\n}\n\nint\nmain (int argc, char *argv[])\n{\n    HevTask *task;\n\n    hev_task_system_init ();\n\n    task = hev_task_new (-1);\n    hev_task_run (task, tcp_client_entry, NULL);\n\n    task = hev_task_new (-1);\n    hev_task_run (task, udp_client_entry, NULL);\n\n    hev_task_system_run ();\n\n    hev_task_system_fini ();\n\n    return 0;\n}\n```\n\n## Users\n\n* **HevSocks5Server** - https://github.com/heiher/hev-socks5-server\n* **HevSocks5TProxy** - https://github.com/heiher/hev-socks5-tproxy\n* **HevSocks5Tunnel** - https://github.com/heiher/hev-socks5-tunnel\n\n## Contributors\n* **hev** - https://hev.cc\n* **spider84** - https://github.com/spider84\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheiher%2Fhev-socks5-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheiher%2Fhev-socks5-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheiher%2Fhev-socks5-core/lists"}