{"id":37212575,"url":"https://github.com/sikang99/pion-turn-example","last_synced_at":"2026-01-15T00:28:00.929Z","repository":{"id":89332211,"uuid":"200141300","full_name":"sikang99/pion-turn-example","owner":"sikang99","description":"Test example for client \u0026 server of pion turn","archived":false,"fork":false,"pushed_at":"2020-01-01T01:03:29.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-02-27T16:26:46.602Z","etag":null,"topics":["example","turn","webrtc"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sikang99.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":null,"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":"2019-08-02T01:18:35.000Z","updated_at":"2024-06-19T07:53:09.979Z","dependencies_parsed_at":null,"dependency_job_id":"54c0396b-203e-42d1-8a4a-6777d32045f5","html_url":"https://github.com/sikang99/pion-turn-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/sikang99/pion-turn-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikang99%2Fpion-turn-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikang99%2Fpion-turn-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikang99%2Fpion-turn-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikang99%2Fpion-turn-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sikang99","download_url":"https://codeload.github.com/sikang99/pion-turn-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikang99%2Fpion-turn-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28439701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","response_time":107,"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":["example","turn","webrtc"],"created_at":"2026-01-15T00:28:00.223Z","updated_at":"2026-01-15T00:28:00.897Z","avatar_url":"https://github.com/sikang99.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TURN Examples\n\n## turn-server\nA simple TURN server.\nIt demonstrates how to write a TURN server and run it.\n\nIt takes a few environment variables:\n* USERS   : \u0026lt;username\u0026gt;=\u0026lt;password\u0026gt;[,\u0026lt;username\u0026gt;=\u0026lt;password\u0026gt;,...] pairs\n* REALM   : Realm name (defaults to \"pion.ly\")\n* UDP_PORT: Listening port (defaults to 3478)\n\n\n```sh\n$ go build\n$ PIONS_LOG_INFO=all USERS=user=pass REALM=pion.ly ./turn-server\nturn INFO: 2019/07/14 14:40:17 Listening on udp:10.0.0.135:3478\n```\n\n## turn-client\nA simple TURN client.\nIt demonstrates how to write a TURN client and run it.\n\nThe following command simply allocates a relay socket (relayConn), then exits.\n\n```sh\n$ go build\n./turn-client -host \u003cturn-server-name\u003e -user=user=pass\n```\n\nBy adding `-ping`, it will perform a ping test. (it internally creates a 'pinger' and send\na UDP packet every second, 10 times then exits.\n\n```sh\n$ go build\n./turn-client -host \u003cturn-server-name\u003e -user=user=pass -ping\n```\n\nFollowing diagram shows what turn-client does:\n```\n          +----------------+\n          |   TURN Server  |\n          |                |\n          +---o--------o---+\n  TURN port  /^      / ^\\\n       3478_/ |     /  | \\_relayConn (*1)\n              |    /   |\n              |  _/    |\n  mappedAddr_ | /      | ___external IP:port\n       (*2)  \\|v       |/    for pingerConn\n          +---o--------o---+     (*3)\n          |   |   NAT  |   |\n          +----------------+\n              |        |\n  TURN    ___ |        | __pingerConn\n  listen     \\|        |/     (sends `ping` to relayConn)\n  port    +---o--------o---+\n  (conn)  |   turn-client  |\n          +----------------+\n```\n\n\u003e (*1) The relayConn actually lives in the local turn-client, but it acts as if it is\n\u003e listening on the TURN server. In fact, relayConn.LocalAddr() returns a transport address\n\u003e on which the TURN server is listening.\n\n\u003e (*2) For relayConn to send/receive packet to/from (*3), you will need to give relayConn permission\n\u003e to send/receive packet to/from the IP address. In the example code, this is done by sending a\n\u003e packet, \"Hello\" (content does not matter), to the mappedAddr. (assuming the IP address of\n\u003e mappedAddr and the external IP:port (*3) are the same) This process is known as\n\u003e \"UDP hole punching\" and TURN server exhibits \"Address-restricted\" behavior. Once it is done,\n\u003e packets coming from (*3) will be received by relayConn.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsikang99%2Fpion-turn-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsikang99%2Fpion-turn-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsikang99%2Fpion-turn-example/lists"}