Move OS package to golibs
This commit is contained in:
@@ -10,10 +10,6 @@ issues:
|
||||
linters:
|
||||
- dupl
|
||||
- maligned
|
||||
- path: internal/os/alias\.go
|
||||
linters:
|
||||
- gochecknoglobals
|
||||
text: IsNotExist is a global variable
|
||||
- path: internal/unix/constants\.go
|
||||
linters:
|
||||
- golint
|
||||
|
||||
@@ -22,8 +22,6 @@ import (
|
||||
gluetunLogging "github.com/qdm12/gluetun/internal/logging"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/openvpn"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/os/user"
|
||||
"github.com/qdm12/gluetun/internal/params"
|
||||
"github.com/qdm12/gluetun/internal/publicip"
|
||||
"github.com/qdm12/gluetun/internal/routing"
|
||||
@@ -36,6 +34,8 @@ import (
|
||||
versionpkg "github.com/qdm12/gluetun/internal/version"
|
||||
"github.com/qdm12/golibs/command"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
"github.com/qdm12/golibs/os/user"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
|
||||
2
go.mod
2
go.mod
@@ -6,7 +6,7 @@ require (
|
||||
github.com/fatih/color v1.10.0
|
||||
github.com/golang/mock v1.4.4
|
||||
github.com/kyokomi/emoji v2.2.4+incompatible
|
||||
github.com/qdm12/golibs v0.0.0-20201227203847-2fd99ffdfdba
|
||||
github.com/qdm12/golibs v0.0.0-20210102015428-6e1d159e61a3
|
||||
github.com/qdm12/ss-server v0.1.0
|
||||
github.com/stretchr/testify v1.6.1
|
||||
github.com/vishvananda/netlink v1.1.0
|
||||
|
||||
8
go.sum
8
go.sum
@@ -78,10 +78,8 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/qdm12/golibs v0.0.0-20201025221346-fe352060c25a h1:v0zUA1FWeVkTEd9KyxfehbRVJeFGOqyMY6FHO/Q9ITU=
|
||||
github.com/qdm12/golibs v0.0.0-20201025221346-fe352060c25a/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc=
|
||||
github.com/qdm12/golibs v0.0.0-20201227203847-2fd99ffdfdba h1:En+jX5OvTswfE5W3Pe41To8Ge8WXtskMbyO5FleofNE=
|
||||
github.com/qdm12/golibs v0.0.0-20201227203847-2fd99ffdfdba/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc=
|
||||
github.com/qdm12/golibs v0.0.0-20210102015428-6e1d159e61a3 h1:tnkjZkYZuAFNga7Wd/j3z3gPJLkv0OXow4q/YTkRdmE=
|
||||
github.com/qdm12/golibs v0.0.0-20210102015428-6e1d159e61a3/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc=
|
||||
github.com/qdm12/ss-server v0.1.0 h1:WV9MkHCDEWRwe4WpnYFeR/zcZAxYoTbfntLDnw9AQ50=
|
||||
github.com/qdm12/ss-server v0.1.0/go.mod h1:ABVUkxubboL3vqBkOwDV9glX1/x7SnYrckBe5d+M/zw=
|
||||
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg=
|
||||
@@ -126,8 +124,6 @@ golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201018121011-98379d014ca7 h1:CNOpL+H7PSxBI7dF/EIUsfOguRSzWp6CQ91yxZE6PG4=
|
||||
golang.org/x/sys v0.0.0-20201018121011-98379d014ca7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
|
||||
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package alpine
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/os/user"
|
||||
"github.com/qdm12/golibs/os"
|
||||
"github.com/qdm12/golibs/os/user"
|
||||
)
|
||||
|
||||
type Configurator interface {
|
||||
|
||||
@@ -3,7 +3,7 @@ package cli
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type CLI interface {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
func (c *cli) ClientKey(args []string, openFile os.OpenFileFunc) error {
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/params"
|
||||
"github.com/qdm12/gluetun/internal/provider"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/gluetun/internal/storage"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
func (c *cli) OpenvpnConfig(os os.OS) error {
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/gluetun/internal/storage"
|
||||
"github.com/qdm12/gluetun/internal/updater"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
func (c *cli) Update(args []string, os os.OS) error {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
func (c *configurator) MakeUnboundConf(ctx context.Context, settings settings.DNS,
|
||||
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/golibs/command"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type Configurator interface {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
// UseDNSInternally is to change the Go program DNS only.
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/os/mock_os"
|
||||
"github.com/qdm12/golibs/logging/mock_logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
"github.com/qdm12/golibs/os/mock_os"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/os/mock_os"
|
||||
"github.com/qdm12/golibs/logging/mock_logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
"github.com/qdm12/golibs/os/mock_os"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/routing"
|
||||
"github.com/qdm12/golibs/command"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
// Configurator allows to change firewall rules and modify network routes.
|
||||
|
||||
@@ -11,12 +11,12 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/provider"
|
||||
"github.com/qdm12/gluetun/internal/routing"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/golibs/command"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type Looper interface {
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/unix"
|
||||
"github.com/qdm12/golibs/command"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type Configurator interface {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package os
|
||||
|
||||
import nativeos "os"
|
||||
|
||||
// Aliases used for convenience so "os" does not have to be imported
|
||||
|
||||
type FileMode nativeos.FileMode
|
||||
|
||||
var IsNotExist = nativeos.IsNotExist
|
||||
@@ -1,16 +0,0 @@
|
||||
package os
|
||||
|
||||
import (
|
||||
nativeos "os"
|
||||
)
|
||||
|
||||
// Constants used for convenience so "os" does not have to be imported
|
||||
|
||||
//nolint:golint
|
||||
const (
|
||||
O_CREATE = nativeos.O_CREATE
|
||||
O_TRUNC = nativeos.O_TRUNC
|
||||
O_WRONLY = nativeos.O_WRONLY
|
||||
O_RDONLY = nativeos.O_RDONLY
|
||||
O_RDWR = nativeos.O_RDWR
|
||||
)
|
||||
@@ -1,15 +0,0 @@
|
||||
package os
|
||||
|
||||
import (
|
||||
"io"
|
||||
nativeos "os"
|
||||
)
|
||||
|
||||
//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . File
|
||||
|
||||
type File interface {
|
||||
io.ReadWriteCloser
|
||||
WriteString(s string) (int, error)
|
||||
Chown(uid, gid int) error
|
||||
Chmod(mode nativeos.FileMode) error
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package os
|
||||
|
||||
import (
|
||||
nativeos "os"
|
||||
)
|
||||
|
||||
type OpenFileFunc func(name string, flag int, perm FileMode) (File, error)
|
||||
type MkdirAllFunc func(name string, perm nativeos.FileMode) error
|
||||
type RemoveFunc func(name string) error
|
||||
type ChownFunc func(name string, uid int, gid int) error
|
||||
@@ -1,121 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/qdm12/gluetun/internal/os (interfaces: File)
|
||||
|
||||
// Package mock_os is a generated GoMock package.
|
||||
package mock_os
|
||||
|
||||
import (
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
os "os"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockFile is a mock of File interface
|
||||
type MockFile struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockFileMockRecorder
|
||||
}
|
||||
|
||||
// MockFileMockRecorder is the mock recorder for MockFile
|
||||
type MockFileMockRecorder struct {
|
||||
mock *MockFile
|
||||
}
|
||||
|
||||
// NewMockFile creates a new mock instance
|
||||
func NewMockFile(ctrl *gomock.Controller) *MockFile {
|
||||
mock := &MockFile{ctrl: ctrl}
|
||||
mock.recorder = &MockFileMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockFile) EXPECT() *MockFileMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Chmod mocks base method
|
||||
func (m *MockFile) Chmod(arg0 os.FileMode) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Chmod", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Chmod indicates an expected call of Chmod
|
||||
func (mr *MockFileMockRecorder) Chmod(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chmod", reflect.TypeOf((*MockFile)(nil).Chmod), arg0)
|
||||
}
|
||||
|
||||
// Chown mocks base method
|
||||
func (m *MockFile) Chown(arg0, arg1 int) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Chown", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Chown indicates an expected call of Chown
|
||||
func (mr *MockFileMockRecorder) Chown(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chown", reflect.TypeOf((*MockFile)(nil).Chown), arg0, arg1)
|
||||
}
|
||||
|
||||
// Close mocks base method
|
||||
func (m *MockFile) Close() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Close")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Close indicates an expected call of Close
|
||||
func (mr *MockFileMockRecorder) Close() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockFile)(nil).Close))
|
||||
}
|
||||
|
||||
// Read mocks base method
|
||||
func (m *MockFile) Read(arg0 []byte) (int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Read", arg0)
|
||||
ret0, _ := ret[0].(int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Read indicates an expected call of Read
|
||||
func (mr *MockFileMockRecorder) Read(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Read", reflect.TypeOf((*MockFile)(nil).Read), arg0)
|
||||
}
|
||||
|
||||
// Write mocks base method
|
||||
func (m *MockFile) Write(arg0 []byte) (int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Write", arg0)
|
||||
ret0, _ := ret[0].(int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Write indicates an expected call of Write
|
||||
func (mr *MockFileMockRecorder) Write(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockFile)(nil).Write), arg0)
|
||||
}
|
||||
|
||||
// WriteString mocks base method
|
||||
func (m *MockFile) WriteString(arg0 string) (int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "WriteString", arg0)
|
||||
ret0, _ := ret[0].(int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// WriteString indicates an expected call of WriteString
|
||||
func (mr *MockFileMockRecorder) WriteString(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteString", reflect.TypeOf((*MockFile)(nil).WriteString), arg0)
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/qdm12/gluetun/internal/os (interfaces: OS)
|
||||
|
||||
// Package mock_os is a generated GoMock package.
|
||||
package mock_os
|
||||
|
||||
import (
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
os "github.com/qdm12/gluetun/internal/os"
|
||||
os0 "os"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockOS is a mock of OS interface
|
||||
type MockOS struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockOSMockRecorder
|
||||
}
|
||||
|
||||
// MockOSMockRecorder is the mock recorder for MockOS
|
||||
type MockOSMockRecorder struct {
|
||||
mock *MockOS
|
||||
}
|
||||
|
||||
// NewMockOS creates a new mock instance
|
||||
func NewMockOS(ctrl *gomock.Controller) *MockOS {
|
||||
mock := &MockOS{ctrl: ctrl}
|
||||
mock.recorder = &MockOSMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockOS) EXPECT() *MockOSMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Chown mocks base method
|
||||
func (m *MockOS) Chown(arg0 string, arg1, arg2 int) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Chown", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Chown indicates an expected call of Chown
|
||||
func (mr *MockOSMockRecorder) Chown(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Chown", reflect.TypeOf((*MockOS)(nil).Chown), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// MkdirAll mocks base method
|
||||
func (m *MockOS) MkdirAll(arg0 string, arg1 os.FileMode) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MkdirAll", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MkdirAll indicates an expected call of MkdirAll
|
||||
func (mr *MockOSMockRecorder) MkdirAll(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MkdirAll", reflect.TypeOf((*MockOS)(nil).MkdirAll), arg0, arg1)
|
||||
}
|
||||
|
||||
// OpenFile mocks base method
|
||||
func (m *MockOS) OpenFile(arg0 string, arg1 int, arg2 os.FileMode) (os.File, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "OpenFile", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(os.File)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// OpenFile indicates an expected call of OpenFile
|
||||
func (mr *MockOSMockRecorder) OpenFile(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpenFile", reflect.TypeOf((*MockOS)(nil).OpenFile), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// Remove mocks base method
|
||||
func (m *MockOS) Remove(arg0 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Remove", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Remove indicates an expected call of Remove
|
||||
func (mr *MockOSMockRecorder) Remove(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockOS)(nil).Remove), arg0)
|
||||
}
|
||||
|
||||
// Stat mocks base method
|
||||
func (m *MockOS) Stat(arg0 string) (os0.FileInfo, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Stat", arg0)
|
||||
ret0, _ := ret[0].(os0.FileInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Stat indicates an expected call of Stat
|
||||
func (mr *MockOSMockRecorder) Stat(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stat", reflect.TypeOf((*MockOS)(nil).Stat), arg0)
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package os
|
||||
|
||||
import nativeos "os"
|
||||
|
||||
//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . OS
|
||||
|
||||
type OS interface {
|
||||
OpenFile(name string, flag int, perm FileMode) (File, error)
|
||||
MkdirAll(name string, perm FileMode) error
|
||||
Remove(name string) error
|
||||
Chown(name string, uid int, gid int) error
|
||||
Stat(name string) (nativeos.FileInfo, error)
|
||||
}
|
||||
|
||||
func New() OS {
|
||||
return &os{}
|
||||
}
|
||||
|
||||
type os struct{}
|
||||
|
||||
func (o *os) OpenFile(name string, flag int, perm FileMode) (File, error) {
|
||||
return nativeos.OpenFile(name, flag, nativeos.FileMode(perm))
|
||||
}
|
||||
func (o *os) MkdirAll(name string, perm FileMode) error {
|
||||
return nativeos.MkdirAll(name, nativeos.FileMode(perm))
|
||||
}
|
||||
func (o *os) Remove(name string) error {
|
||||
return nativeos.Remove(name)
|
||||
}
|
||||
func (o *os) Chown(name string, uid, gid int) error {
|
||||
return nativeos.Chown(name, uid, gid)
|
||||
}
|
||||
func (o *os) Stat(name string) (nativeos.FileInfo, error) {
|
||||
return nativeos.Stat(name)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package user
|
||||
|
||||
import osuser "os/user"
|
||||
|
||||
// Aliases used for convenience so "os/user" does not have to be imported
|
||||
|
||||
type User osuser.User
|
||||
@@ -1,64 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/qdm12/gluetun/internal/os/user (interfaces: OSUser)
|
||||
|
||||
// Package mock_user is a generated GoMock package.
|
||||
package mock_user
|
||||
|
||||
import (
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
user "os/user"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockOSUser is a mock of OSUser interface
|
||||
type MockOSUser struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockOSUserMockRecorder
|
||||
}
|
||||
|
||||
// MockOSUserMockRecorder is the mock recorder for MockOSUser
|
||||
type MockOSUserMockRecorder struct {
|
||||
mock *MockOSUser
|
||||
}
|
||||
|
||||
// NewMockOSUser creates a new mock instance
|
||||
func NewMockOSUser(ctrl *gomock.Controller) *MockOSUser {
|
||||
mock := &MockOSUser{ctrl: ctrl}
|
||||
mock.recorder = &MockOSUserMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockOSUser) EXPECT() *MockOSUserMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Lookup mocks base method
|
||||
func (m *MockOSUser) Lookup(arg0 string) (*user.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Lookup", arg0)
|
||||
ret0, _ := ret[0].(*user.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Lookup indicates an expected call of Lookup
|
||||
func (mr *MockOSUserMockRecorder) Lookup(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Lookup", reflect.TypeOf((*MockOSUser)(nil).Lookup), arg0)
|
||||
}
|
||||
|
||||
// LookupID mocks base method
|
||||
func (m *MockOSUser) LookupID(arg0 string) (*user.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "LookupID", arg0)
|
||||
ret0, _ := ret[0].(*user.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// LookupID indicates an expected call of LookupID
|
||||
func (mr *MockOSUserMockRecorder) LookupID(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupID", reflect.TypeOf((*MockOSUser)(nil).LookupID), arg0)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package user
|
||||
|
||||
import osuser "os/user"
|
||||
|
||||
//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . OSUser
|
||||
|
||||
type OSUser interface {
|
||||
LookupID(uid string) (*osuser.User, error)
|
||||
Lookup(username string) (*osuser.User, error)
|
||||
}
|
||||
|
||||
func New() OSUser {
|
||||
return &osUser{}
|
||||
}
|
||||
|
||||
type osUser struct{}
|
||||
|
||||
func (u *osUser) LookupID(uid string) (*osuser.User, error) {
|
||||
return osuser.LookupId(uid)
|
||||
}
|
||||
|
||||
func (u *osUser) Lookup(username string) (*osuser.User, error) {
|
||||
return osuser.Lookup(username)
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
"github.com/qdm12/golibs/verification"
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/os"
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type cyberghost struct {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type mullvad struct {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type nordvpn struct {
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
gluetunLog "github.com/qdm12/gluetun/internal/logging"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type pia struct {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type privado struct {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
// Provider contains methods to read and modify the openvpn configuration to connect as a client.
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type purevpn struct {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type surfshark struct {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type vyprvpn struct {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/firewall"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type windscribe struct {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package publicip
|
||||
|
||||
import "github.com/qdm12/gluetun/internal/os"
|
||||
import "github.com/qdm12/golibs/os"
|
||||
|
||||
func persistPublicIP(openFile os.OpenFileFunc,
|
||||
filepath string, content string, puid, pgid int) error {
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type Looper interface {
|
||||
|
||||
@@ -2,8 +2,8 @@ package storage
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/os"
|
||||
"github.com/qdm12/golibs/os"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user