2022-01-10 18:43:13 +01:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
2022-01-17 14:01:58 +01:00
|
|
|
"github.com/wiretrustee/wiretrustee/iface"
|
2022-01-10 18:43:13 +01:00
|
|
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
|
|
|
"io"
|
|
|
|
"net"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
const DefaultWgKeepAlive = 25 * time.Second
|
|
|
|
|
2022-03-01 14:07:33 +01:00
|
|
|
type Type string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TypeNoProxy Type = "NoProxy"
|
|
|
|
TypeWireguard Type = "Wireguard"
|
|
|
|
TypeDummy Type = "Dummy"
|
|
|
|
)
|
|
|
|
|
2022-01-10 18:43:13 +01:00
|
|
|
type Config struct {
|
|
|
|
WgListenAddr string
|
|
|
|
RemoteKey string
|
2022-01-17 14:01:58 +01:00
|
|
|
WgInterface iface.WGIface
|
2022-01-10 18:43:13 +01:00
|
|
|
AllowedIps string
|
|
|
|
PreSharedKey *wgtypes.Key
|
|
|
|
}
|
|
|
|
|
|
|
|
type Proxy interface {
|
|
|
|
io.Closer
|
|
|
|
// Start creates a local remoteConn and starts proxying data from/to remoteConn
|
|
|
|
Start(remoteConn net.Conn) error
|
2022-03-01 14:07:33 +01:00
|
|
|
Type() Type
|
2022-01-10 18:43:13 +01:00
|
|
|
}
|