Skip to content

Provides an API for connecting to, sending commands to, and receiving messages from an OpenVPN management socket

License

Notifications You must be signed in to change notification settings

cedws/openvpn-mgmt-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openvpn-mgmt-go

Provides an API for connecting to, sending commands to, and receiving messages from an OpenVPN management socket.

Example

package main

import (
	openvpn "github.com/cedws/openvpn-mgmt-go"
	"github.com/cedws/openvpn-mgmt-go/command"
	"github.com/cedws/openvpn-mgmt-go/message"
)

func main() {
	socket, err := openvpn.DialUnix("/run/openvpn/server/management.sock")
	if err != nil {
		// ...
	}

	plugin := AuthPlugin{socket}
	plugin.Init()
}

type AuthPlugin struct {
	socket *openvpn.Socket
}

func (a *AuthPlugin) Init() {
	a.socket.OnClientConnect(a.onClientConnect)
	a.socket.Start()
}

func (a *AuthPlugin) onClientConnect(c message.ClientConnect) {
	// allow the connecting client
	a.socket.Dispatch(command.ClientAuthNt{c.ClientID, c.KeyID})
}

About

Provides an API for connecting to, sending commands to, and receiving messages from an OpenVPN management socket

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages