2023-07-26 14:00:47 +02:00
|
|
|
package wgproxy
|
|
|
|
|
2024-05-07 18:50:34 +02:00
|
|
|
import "context"
|
|
|
|
|
2023-07-26 14:00:47 +02:00
|
|
|
type Factory struct {
|
|
|
|
wgPort int
|
|
|
|
ebpfProxy Proxy
|
|
|
|
}
|
|
|
|
|
2024-05-07 18:50:34 +02:00
|
|
|
func (w *Factory) GetProxy(ctx context.Context) Proxy {
|
2023-07-26 14:00:47 +02:00
|
|
|
if w.ebpfProxy != nil {
|
|
|
|
return w.ebpfProxy
|
|
|
|
}
|
2024-05-07 18:50:34 +02:00
|
|
|
return NewWGUserSpaceProxy(ctx, w.wgPort)
|
2023-07-26 14:00:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Factory) Free() error {
|
|
|
|
if w.ebpfProxy != nil {
|
2023-08-07 11:43:32 +02:00
|
|
|
return w.ebpfProxy.Free()
|
2023-07-26 14:00:47 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|