mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
add documentation
This commit is contained in:
parent
f93e047f64
commit
0048d87cad
4 changed files with 72 additions and 31 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"golang.zx2c4.com/wireguard/tun/netstack"
|
||||
)
|
||||
|
||||
// DeviceSetting contains the parameters for setting up a tun interface
|
||||
type DeviceSetting struct {
|
||||
ipcRequest string
|
||||
dns []netip.Addr
|
||||
|
@ -16,6 +17,7 @@ type DeviceSetting struct {
|
|||
mtu int
|
||||
}
|
||||
|
||||
// serialize the config into an IPC request and DeviceSetting
|
||||
func createIPCRequest(conf *DeviceConfig) (*DeviceSetting, error) {
|
||||
request := fmt.Sprintf(`private_key=%s
|
||||
public_key=%s
|
||||
|
@ -28,6 +30,7 @@ allowed_ip=0.0.0.0/0`, conf.SelfSecretKey, conf.PeerPublicKey, conf.PeerEndpoint
|
|||
return setting, nil
|
||||
}
|
||||
|
||||
// StartWireguard creates a tun interface on netstack given a configuration
|
||||
func StartWireguard(conf *DeviceConfig) (*VirtualTun, error) {
|
||||
setting, err := createIPCRequest(conf)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue