{"id":21707675,"url":"https://github.com/merkez/wg","last_synced_at":"2025-04-12T16:15:42.240Z","repository":{"id":56454033,"uuid":"284332746","full_name":"merkez/wg","owner":"merkez","description":"gRPC wrapped wireguard service with and without Docker.","archived":false,"fork":false,"pushed_at":"2023-07-05T20:57:56.000Z","size":92,"stargazers_count":7,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T16:15:17.675Z","etag":null,"topics":["grpc","linux","wireguard"],"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/merkez.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":"2020-08-01T20:20:02.000Z","updated_at":"2022-11-09T18:08:50.000Z","dependencies_parsed_at":"2024-06-19T05:31:25.729Z","dependency_job_id":null,"html_url":"https://github.com/merkez/wg","commit_stats":null,"previous_names":["mrturkmencom/wg"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merkez%2Fwg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merkez%2Fwg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merkez%2Fwg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merkez%2Fwg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/merkez","download_url":"https://codeload.github.com/merkez/wg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248594190,"owners_count":21130316,"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":["grpc","linux","wireguard"],"created_at":"2024-11-25T22:18:54.285Z","updated_at":"2025-04-12T16:15:42.202Z","avatar_url":"https://github.com/merkez.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wg\n\nWireguard backed and gRPC wrapped server which is responsible  to create VPN connection through gRPC requests. \nThe idea is basically having remote control to gRPC endpoint to be able to setup a VPN connection from your client. \n\nAs initial step, dockerization of wg is dismissed for now, however it will be added. \n\n## Installation of wireguard\n\nMost of the cases [official installation page](https://www.wireguard.com/install/) is enough to install wireguard however, \nin some cases, the instructions are misleading on official page, hence I am including installation\nsteps for Debian.  (-in case of error in official installation following steps could be followed -) \n\n```bash \n$ sudo apt update\n$ sudo apt upgrade\n$ sudo sh -c \"echo 'deb http://deb.debian.org/debian buster-backports main contrib non-free' \u003e /etc/apt/sources.list.d/buster-backports.list\"\n$ sudo apt update\n$ apt search wireguard\n$ sudo apt install wireguard\n# in some cases command line tools does not  work for wireguard in that case do following \n$ apt-get install wireguard-dkms wireguard-tools linux-headers-$(uname -r)\n```\n\n## How to run through Docker Container\n\n```bash \n$ docker build -t wg .\n \n$ docker run -e CONFIG_PATH=/app/ \\ \n            --name=wireguard-service\n            --net=host \\\n            --cap-add=NET_ADMIN  \\\n            --cap-add=SYS_MODULE \\ \n            -v /path/to/service/config:/app/\n            -v /lib/modules:/lib/modules \\  \n            --sysctl=\"net.ipv4.conf.all.src_valid_mark=1\" \\ \n             wg \n```\n\nDocker will run only in Linux machines.`--net=host` is required because Wireguard service generates VPN endpoint ports randomly. \n\n\n## Available gRPC calls\n\n- **GenPrivateKey**\n    - Generates private key which is required to initialize wireguard interface.gRPC call requires only name of the file,\n    which will have private key in it. \n    \n    Example Usage: \n    ````go\n    privKeyResp, err := client.GenPrivateKey(context.Background(), \u0026wg.PrivKeyReq{PrivateKeyName: \"random_privatekey\"})\n    if err != nil {\n    \tfmt.Println(fmt.Sprintf(\"Error happened in creating private key %v\", err))\n    \tpanic(err)\n    }\n    fmt.Println(privKeyResp.Message)\n    ````\n    Private key will be availabe in defined configuration directory in config.yml file.\n    \n- **GenPublicKey**\n    - Generates pair of private key as public key, in order to use this functionality, it requires\n    existing private key name (which is generated in earlier step) then public key name (-which will be generated-)\n    \n    Example Usage: \n    ````go\n    publicKeyResp, err := client.GenPublicKey(context.Background(), \u0026wg.PubKeyReq{PrivKeyName: \"random_privatekey\", PubKeyName: \"random_publickey\"})\n    if err != nil {\n    \tfmt.Println(fmt.Sprintf(\"Error happened in creating public key %s\", err.Error()))\n    \tpanic(err)\n    }\n    if publicKeyResp != nil {\n    \tfmt.Println(publicKeyResp.Message)\n    }\n    ````\n\n- **GetPrivateKey**\n\n    - Despite of GenPrivateKey functionality, this one returns existing private key content. \n      \n      Example Usage: \n      ````go\n      privateKey, err := client.GetPrivateKey(context.Background(), \u0026wg.PrivKeyReq{PrivateKeyName: \"random_privatekey\"})\n      if err != nil {\n      \tfmt.Println(fmt.Sprintf(\"Get content of private key error %s\", err.Error()))\n      \tpanic(err)       \n\t  }\t      \n      if privateKey != nil {\n      \tfmt.Println(privateKey.Message)      \n      }\n      ````\n- **GetPublicKey**\n\n    - Returns content of existing public key content\n    ````go\n    publicKey, err := client.GetPublicKey(context.Background(), \u0026wg.PubKeyReq{PubKeyName: \"random_publickey\"})\n    if err != nil {\n    \tfmt.Println(fmt.Sprintf(\"Get content of public key error %s\", err.Error()))\n    \tpanic(err)\n    }\n    if publicKey != nil {\n    \tfmt.Println(publicKey.Message)\n    }\n    ````\n\n- **InitializeI**\n    -  It is for initializing wireguard interface in configuration folder which is provided in configuration file. It requires\n       wireguard interface specifications, which are \n       ```raw\n       Address: \u003csubnet-of-interface\u003e\n       ListenPort: \u003cwhere-users-will-be-connected-to\u003e\n       SaveConfig: \u003cwhether-save-config-or-not\u003e\n       PrivateKey: \u003cprivate-key-of-server\u003e \n       Eth : \u003cmain-ethernet-point-to-outside\u003e\n       IName: \u003cinterface-name-required-in-grpc-call\u003e \n       ```  \n       Example usage: \n       ````go\n       interfaceGenResp, err := client.InitializeI(context.Background(), \u0026wg.IReq{\n       \t\tAddress:    \"10.0.2.1/24\",\n       \t\tListenPort: 4000,\n       \t\tSaveConfig: true,\n       \t\tPrivateKey: privateKey.Message,\n       \t\tEth:        \"eth0\",\n       \t\tIName:      \"wg1\",\n       \t})\n       \tif err != nil {\n       \t\tfmt.Println(fmt.Sprintf(\" Initializing interface error %v\", err.Error()))\n       \t\n       \t}\n       \tif interfaceGenResp != nil {\n       \t\tfmt.Println(interfaceGenResp.Message)\n       \t}\n       fmt.Println(interfaceGenResp.Message)\n       ````\n       \n- **GetNICInfo**\n    - Returns information regarding to requested wireguard interface. \n   \n   Example Usage:\n   \n   ````go\n  \tnicInfoResp, err := client.GetNICInfo(context.Background(), \u0026wg.NICInfoReq{Interface: \"wg1\"})\n  \tif err != nil {\n  \t\tfmt.Println(fmt.Sprintf(\"Getting information of interface error %s\", err.Error()))\n  \t\tpanic(err)\n  \t}\n  \tif nicInfoResp != nil {\n  \t\tfmt.Println(nicInfoResp.Message)\n  \t}\n   ````\n \n- **ManageNIC**\n    - It can up or down given wg interface. \n   \n   Example Usage: \n   ````go \n   downI, err := client.ManageNIC(context.Background(), \u0026wg.ManageNICReq{Cmd: \"down\", Nic: \"wg1\"})\n   \tif err != nil {\n   \t\tfmt.Println(fmt.Sprintf(\"down interface is failed %s\", err.Error()))\n   \t\tpanic(err)\n   \t}\n   fmt.Println(downI.Message) \n   ````\n  \n- **ListPeers** \n   - Returns the content of command line which is `wg show \u003cwg-interface\u003e`\n   \n   Example Usage: \n   ```go\n   \tresp, err := client.ListPeers(context.Background(), \u0026wg.ListPeersReq{Nicname: \"wg0\"})\n   \tif err != nil {\n   \t\tfmt.Printf(\"List peers error %v \", err)\n   \t\tpanic(err)\n   \t}\n   \tfmt.Println(resp.Response)\n  ```\n      \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerkez%2Fwg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerkez%2Fwg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerkez%2Fwg/lists"}