2022-10-27 17:50:29 +08:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
2022-10-27 19:50:06 +08:00
|
|
|
"github.com/gravitl/netmaker/nm-proxy/wg"
|
2022-10-27 17:50:29 +08:00
|
|
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
defaultBodySize = 10000
|
|
|
|
defaultPort = 51722
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Port int
|
|
|
|
BodySize int
|
|
|
|
Addr string
|
|
|
|
RemoteKey string
|
|
|
|
WgInterface *wg.WGIface
|
|
|
|
AllowedIps []net.IPNet
|
|
|
|
PreSharedKey *wgtypes.Key
|
|
|
|
}
|
|
|
|
|
|
|
|
// Proxy - WireguardProxy proxies
|
|
|
|
type Proxy struct {
|
|
|
|
Ctx context.Context
|
|
|
|
Cancel context.CancelFunc
|
|
|
|
|
|
|
|
Config Config
|
|
|
|
RemoteConn net.Conn
|
|
|
|
LocalConn net.Conn
|
|
|
|
}
|