-
Notifications
You must be signed in to change notification settings - Fork 10
/
mock.go
41 lines (32 loc) · 926 Bytes
/
mock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2016-2018 Christian Saide <supernomad>
// Licensed under the MPL-2.0, for details see https://github.com/supernomad/quantum/blob/master/LICENSE
package device
import (
"github.com/supernomad/quantum/common"
)
// Mock device struct to use for testing.
type Mock struct {
}
// Name of the mock device.
func (mock *Mock) Name() string {
return "Mocked Device"
}
// Read which just returns the supplied buffer in the form of a *common.Payload.
func (mock *Mock) Read(queue int, buf []byte) (*common.Payload, bool) {
return common.NewTunPayload(buf, common.MTU), true
}
// Write which is a noop.
func (mock *Mock) Write(queue int, payload *common.Payload) bool {
return true
}
// Close which is a noop.
func (mock *Mock) Close() error {
return nil
}
// Queues which is a noop.
func (mock *Mock) Queues() []int {
return nil
}
func newMock(cfg *common.Config) (Device, error) {
return &Mock{}, nil
}