{"id":20271909,"url":"https://github.com/point-c/wg","last_synced_at":"2026-05-08T22:01:58.405Z","repository":{"id":215205195,"uuid":"738362916","full_name":"point-c/wg","owner":"point-c","description":"wg is a library designed to help with the creation and management of userland WireGuard networks.","archived":false,"fork":false,"pushed_at":"2024-01-27T05:58:23.000Z","size":401,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T05:50:44.108Z","etag":null,"topics":["golang","golang-library","networking","vpn","wireguard","wireguard-go"],"latest_commit_sha":null,"homepage":"https://point-c.github.io/wg/","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/point-c.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-01-03T03:53:10.000Z","updated_at":"2024-05-07T01:31:24.000Z","dependencies_parsed_at":"2024-01-03T05:29:40.958Z","dependency_job_id":"3476851d-9764-477a-a5b7-c39d62fde46d","html_url":"https://github.com/point-c/wg","commit_stats":null,"previous_names":["point-c/wg"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fwg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fwg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fwg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/point-c%2Fwg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/point-c","download_url":"https://codeload.github.com/point-c/wg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241758963,"owners_count":20015251,"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":["golang","golang-library","networking","vpn","wireguard","wireguard-go"],"created_at":"2024-11-14T12:39:59.594Z","updated_at":"2025-11-30T23:03:41.376Z","avatar_url":"https://github.com/point-c.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wg\n\n[![Wireguard](https://img.shields.io/badge/wireguard-%2388171A.svg?logo=wireguard)](https://www.wireguard.com/)\n[![Go Reference](https://img.shields.io/badge/godoc-reference-%23007d9c.svg)](https://point-c.github.io/wg)\n\nwg is a library designed to facilitate the creation and management of userland WireGuard networks. It interfaces with various components of the wireguard-go library, offering a Go API for network operations.\n\n## Features\n- **Device Management**: Control over WireGuard devices, including creation, configuration, and teardown.\n- **Network Configuration**: Tools for setting up and managing a network stack that communicates through wireguard.\n- **Advanced Networking**: Dial as any address inside the tunnel, allowing remote applications to see the correct remote address.\n\n## Installation\n\nTo use wg in your Go project, install it using `go get`:\n\n```bash\ngo get github.com/point-c/wg\n```\n\n## Usage\n\nConfiguration is handled by the [wgapi](https://github.com/point-c/wgapi) library.\n\n### Basic\n\n```go\nvar cfg wgapi.Configurable // your configuration\nvar n *wg.Net\ndev, err := wg.New(wg.OptionNetDevice(\u0026n), wg.OptionConfig(cfg))\nif err != nil {\n\tpanic(err)\n}\n// Use `n` in place of built in tcp/udp networking\ndev.Close() // Close the device to clean up resources\n```\n\n### Networking\n\n#### TCP\n\n##### Listen\n\n```go\nvar n *wg.Net\n// Listen on port 80 on address 192.168.99.1\nl, err := n.Listen(\u0026net.TCPAddr{IP: net.IPv4(192, 168, 99, 1), Port: 80})\nif err != nil {\n    panic(err)\n}\ndefer l.Close()\n\nfor {\n    conn, err := l.Accept()\n    if err != nil {\n        panic(err)\n    }\n    // Start a goroutine and handle conn\n}\n```\n\n##### Dial\n\n```go\nvar n *wg.Net\n// Dial with address 192.168.99.2\nd := n.Dialer(net.IPv4(192, 168, 99, 2), 0) // Recommended to use port 0, since that will dial with a random open port.\n// Dial port 80 on 192.168.99.1\nconn, err := d.DialTCP(ctx, \u0026net.TCPAddr{IP: net.IPv4(192, 168, 99, 1), Port: 80})\nif err != nil {\n    panic(err)\n}\ndefer conn.Close()\n// Use conn\n```\n\n### Options\n\n#### `OptionNop`\n\nDoes nothing.\n\n#### `OptionErr`\n\nThrows an error on device creation. Used internally.\n\n#### `OptionDevice`\n\nUse your own raw network device.\nEither this option or `OptionNetDevice` is required.\n\n#### `OptionBind`\n\nUse your own UDP device.\nIf not specified `DefaultBind` is used.\n\n#### `OptionLogger`\n\nSpecify a `device.Logger` to pass to the `wireguard-go` library.\n\n##### Logger Utilities\n\n- [**wgevents**](https://github.com/point-c/wgevents): Structured logging from the `wireguard-go` library.\n- [**wglog**](https://github.com/point-c/wglog): Logging utilities for `wireguard-go`.\n\n#### `OptionConfig`\n\nConfiguration to use when configuring `wireguard-go`.\n\n#### `OptionNetDevice`\n\nAutomatically configure a `wg.Net` type for use with this device.\nIt will be closed when the device is closed.\n\n```go\nvar n *wg.Net\ndev, err := wg.New(wg.OptionNetDevice(\u0026n))\n```\n\n#### `OptionCloser`\n\nAdds a function to be called when closing the device.\n\n## Testing\n\nThe package includes tests that demonstrate its functionality. Use Go's testing tools to run the tests:\n\n```bash\ngo test\n```\n\n## Godocs\n\nTo regenerate godocs:\n\n```bash\ngo generate -tags docs ./...\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoint-c%2Fwg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoint-c%2Fwg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoint-c%2Fwg/lists"}