{"id":36585569,"url":"https://github.com/goxray/tun","last_synced_at":"2026-01-12T08:02:26.925Z","repository":{"id":268494135,"uuid":"903736819","full_name":"goxray/tun","owner":"goxray","description":"🌐 CLI Xray VPN client","archived":false,"fork":false,"pushed_at":"2025-12-29T12:28:22.000Z","size":1503,"stargazers_count":54,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-01T12:49:14.171Z","etag":null,"topics":["go","iptables","tun","tun2socks","vpn","vpn-client","xray-core"],"latest_commit_sha":null,"homepage":"","language":"Go","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/goxray.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-15T12:40:28.000Z","updated_at":"2025-12-29T12:28:27.000Z","dependencies_parsed_at":"2024-12-17T05:34:50.846Z","dependency_job_id":"ea2824e4-7513-4c07-a058-622190df3a92","html_url":"https://github.com/goxray/tun","commit_stats":null,"previous_names":["goxray/tun"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/goxray/tun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxray%2Ftun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxray%2Ftun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxray%2Ftun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxray%2Ftun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goxray","download_url":"https://codeload.github.com/goxray/tun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxray%2Ftun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["go","iptables","tun","tun2socks","vpn","vpn-client","xray-core"],"created_at":"2026-01-12T08:02:26.831Z","updated_at":"2026-01-12T08:02:26.920Z","avatar_url":"https://github.com/goxray.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go VPN client for XRay\n![Static Badge](https://img.shields.io/badge/OS-macOS%20%7C%20Linux-blue?style=flat\u0026logo=linux\u0026logoColor=white\u0026logoSize=auto\u0026color=blue)\n![Static Badge](https://img.shields.io/badge/Go-1.24+-00ADD8?style=flat\u0026logo=go\u0026logoColor=white)\n[![Go Report Card](https://goreportcard.com/badge/github.com/goxray/tun)](https://goreportcard.com/report/github.com/goxray/tun)\n[![Go Reference](https://pkg.go.dev/badge/github.com/goxray/tun.svg)](https://pkg.go.dev/github.com/goxray/tun)\n![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/goxray/tun/total?color=blue)\n\n\nThis project brings fully functioning [XRay](https://github.com/XTLS/Xray-core) VPN client implementation in Go.\n\n\u003e For desktop version see https://github.com/goxray/desktop\n\n\u003cimg alt=\"Terminal example output\" align=\"center\" src=\"/.github/images/carbon.png\"\u003e\n\n\u003e [!NOTE]\n\u003e The program will not damage your routing rules, default route is intact and only additional rules are added for the lifetime of application's TUN device. There are also additional complementary clean up procedures in place.\n\n#### What is XRay?\nPlease visit https://xtls.github.io/en for more info.\n\n#### Tested and supported on:\n- macOS (tested on Sequoia 15.1.1)\n- Linux (tested on Ubuntu 24.10)\n\n\u003e Feel free to test this on your system and let me know in the issues :)\n\n## ✨ Features\n- Stupidly easy to use\n- Supports all [Xray-core](https://github.com/XTLS/Xray-core) protocols (vless, vmess e.t.c.) using link notation (`vless://` e.t.c.)\n- Only soft routing rules are applied, no changes made to default routes\n\n## ⚡️ Installation\n\nThe application can be used standalone, as compiled and thrown somewhere in the directory mentioned in PATH.\n\n##### 📦 3rd party Debian package (maintained by [twdragon](https://github.com/twdragon))\n\nThe client is available from the PPA repository `ppa:twdragon/xray`, maintained by [twdragon](https://github.com/twdragon). The network privileges in specified automatically by the postinstall script. The package is in sync with this repo's release tags. You can check the pipeline at the [dedicated repository](https://github.com/twdragon/xray-debian-pkg). To install, use:\n\n```bash\nsudo add-apt-repository ppa:twdragon/xray\nsudo apt update\nsudo apt install goxray-cli\n```\n\nAfter the installation, the package might be updated automatically, as is done in Ubuntu. Packages are signed by [twdragon](https://github.com/twdragon) and published on [Launchpad](https://launchpad.net/~twdragon/+archive/ubuntu/xray). Experimental builds are also available in [pipeline repository](https://github.com/twdragon/xray-debian-pkg/actions).\n\n## ⚡️ Usage\n\u003e [!IMPORTANT]\n\u003e - `sudo` is required\n\u003e - On linux set `sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip goxray_binary_path`\n\n### Standalone application:\n\nRunning the VPN on your machine is as simple as running this little command:\n```bash\nsudo go run . \u003cproto_link\u003e\n```\n\nWhere `proto_link` is your XRay link (like `vless://example.com...`), you can get this from your VPN provider or get it from your XRay server.\n\n### As library in your own project:\n\u003e [!NOTE]\n\u003e This project is built upon the `core` package, see details and documentation at https://github.com/goxray/core\n\nInstall:\n```bash\ngo get github.com/goxray/tun/pkg/client\n```\n\nExample:\n```go\nlogger := slog.New(slog.NewTextHandler(os.Stdout, \u0026slog.HandlerOptions{Level: slog.LevelError}))\nvpn, _ := client.NewClientWithOpts(client.Config{\n  TLSAllowInsecure: false,\n  Logger:           logger,\n})\n\n_ = vpn.Connect(clientLink)\ndefer vpn.Disconnect(context.Background())\n\ntime.Sleep(60 * time.Second)\n```\n\n\u003e Please refer to godoc for supported methods and types.\n\n### As a dockerized experience\n\nIf you need to use it with Docker - you can look at [this proposed implementation](https://github.com/goxray/tun/pull/8).\n\n## 🛠 Build\n\nThe project compiles like a regular Go program:\n```bash\ngo build -o goxray_cli .\n```\n\n#### Cross-compilation\n\n```bash\nenv GOOS=darwin GOARCH=amd64 go build -o goxray_cli_darwin_amd64 .\n```\n\nTo cross-compile from macOS to Linux arm/amd I use these commands:\n```bash\ndocker run --platform=linux/arm64 -v=${PWD}:/app --workdir=/app arm64v8/golang:1.24 env GOARCH=arm64 go build -o goxray_cli_linux_arm64 .\n```\n```bash\ndocker run --platform=linux/amd64 -v=${PWD}:/app --workdir=/app amd64/golang:1.24 env GOARCH=amd64 go build -o goxray_cli_linux_amd64 .\n```\n\n## How it works\n- Application sets up new TUN device.\n- Adds additional routes to route all system traffic to this newly created TUN device.\n- Adds exception for XRay outbound address (basically your VPN server IP).\n- Tunnel is created to process all incoming IP packets via TCP/IP stack. All outbound traffic is routed through the XRay inbound proxy and all incoming packets are routed back via TUN device.\n\n## 📝 TODO\n- [ ] Add IPV6 support\n\n## 🎯 Motivation\nThere are no available XRay clients implementations in Go on Github, so I decided to do it myself. The attempt proved to be successfull and I wanted to share my findings in a complete and working VPN client.\n\n## Credits\n\n- https://github.com/xtls/xray-core\n- https://github.com/lilendian0x00/xray-knife\n- https://github.com/jackpal/gateway\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoxray%2Ftun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoxray%2Ftun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoxray%2Ftun/lists"}