Skip to content

Commit

Permalink
Merge pull request #46 from mysteriumnetwork/1273-limit-bandwidth-exp…
Browse files Browse the repository at this point in the history
…ose-tunnel-device-name

Expose tunnel interface name from openvpn process
  • Loading branch information
tadaskay committed Oct 3, 2019
2 parents 22fe4c7 + 06d0c38 commit 75afeb4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions openvpn/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ func (openvpn *OpenvpnProcess) Stop() {

openvpn.tunnelSetup.Stop()
}

// DeviceName returns tunnel device name
func (openvpn *OpenvpnProcess) DeviceName() string {
return openvpn.tunnelSetup.DeviceName()
}
1 change: 1 addition & 0 deletions openvpn/process_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ type Process interface {
Start() error
Wait() error
Stop()
DeviceName() string
}
5 changes: 5 additions & 0 deletions openvpn/tunnel/setup_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ func (ds *DefaultSetup) Setup(config *config.GenericConfig) error {
func (ds *DefaultSetup) Stop() {

}

// DeviceName returns tunnel device name
func (ds *DefaultSetup) DeviceName() string {
return "tun"
}
5 changes: 5 additions & 0 deletions openvpn/tunnel/setup_noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ func (gts *NoopSetup) Setup(config *config.GenericConfig) error {
func (gts *NoopSetup) Stop() {

}

// DeviceName returns tunnel device name
func (gts *NoopSetup) DeviceName() string {
return ""
}
1 change: 1 addition & 0 deletions openvpn/tunnel/setup_tun_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ var ErrNoFreeTunDevice = errors.New("no free tun device found")
type Setup interface {
Setup(config *config.GenericConfig) error
Stop()
DeviceName() string
}
5 changes: 5 additions & 0 deletions openvpn/tunnel/setup_tun_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ func (service *LinuxTunDeviceManager) Stop() {
}
}

// DeviceName returns tunnel device name
func (service *LinuxTunDeviceManager) DeviceName() string {
return service.device.Name
}

func (service *LinuxTunDeviceManager) createTunDevice(deviceName string) (err error) {
cmd := exec.Command("sudo", "ip", "tuntap", "add", "dev", deviceName, "mode", "tun")
if output, err := cmd.CombinedOutput(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion openvpn3/callback_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

package openvpn3

import "testing"
import (
"testing"

"github.com/stretchr/testify/assert"
)

Expand Down

0 comments on commit 75afeb4

Please sign in to comment.