mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-13 17:54:36 +02:00
conn: introduce new package that splits out the Bind and Endpoint types
The sticky socket code stays in the device package for now, as it reaches deeply into the peer list. This is the first step in an effort to split some code out of the very busy device package. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
6aefb61355
commit
203554620d
@ -5,11 +5,15 @@
|
||||
|
||||
package device
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"golang.zx2c4.com/wireguard/conn"
|
||||
)
|
||||
|
||||
type DummyDatagram struct {
|
||||
msg []byte
|
||||
endpoint Endpoint
|
||||
endpoint conn.Endpoint
|
||||
world bool // better type
|
||||
}
|
||||
|
||||
@ -25,7 +29,7 @@ func (b *DummyBind) SetMark(v uint32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *DummyBind) ReceiveIPv6(buff []byte) (int, Endpoint, error) {
|
||||
func (b *DummyBind) ReceiveIPv6(buff []byte) (int, conn.Endpoint, error) {
|
||||
datagram, ok := <-b.in6
|
||||
if !ok {
|
||||
return 0, nil, errors.New("closed")
|
||||
@ -34,7 +38,7 @@ func (b *DummyBind) ReceiveIPv6(buff []byte) (int, Endpoint, error) {
|
||||
return len(datagram.msg), datagram.endpoint, nil
|
||||
}
|
||||
|
||||
func (b *DummyBind) ReceiveIPv4(buff []byte) (int, Endpoint, error) {
|
||||
func (b *DummyBind) ReceiveIPv4(buff []byte) (int, conn.Endpoint, error) {
|
||||
datagram, ok := <-b.in4
|
||||
if !ok {
|
||||
return 0, nil, errors.New("closed")
|
||||
@ -50,6 +54,6 @@ func (b *DummyBind) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *DummyBind) Send(buff []byte, end Endpoint) error {
|
||||
func (b *DummyBind) Send(buff []byte, end conn.Endpoint) error {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user