mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2026-10-14 22:34:18 +03:00
udptlspipe basic implementation
This commit is contained in:
1 parent
3f0a3bcfa0
commit
28bf1e21f0
8 files changed
+174
-21
No files matched your search
@@ -7,7 +7,10 @@ package device
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -187,6 +190,28 @@ func (peer *Peer) Start() {
|
||||
device := peer.device
|
||||
device.log.Verbosef("%v - Starting", peer)
|
||||
|
||||
if !device.serverMode {
|
||||
device.log.Verbosef("Starting udptlspipe")
|
||||
|
||||
if device.udptlspipe != nil {
|
||||
device.udptlspipe.Shutdown(context.TODO())
|
||||
}
|
||||
|
||||
oldEndpoint, _ := netip.ParseAddrPort(peer.endpoint.val.DstToString())
|
||||
peer.endpoint.val, _ = device.net.bind.ParseEndpoint(fmt.Sprintf("127.0.0.1:%d", oldEndpoint.Port()))
|
||||
|
||||
srv, err := device.StartUDPTLSPipe(
|
||||
false,
|
||||
fmt.Sprintf("127.0.0.1:%d", oldEndpoint.Port()),
|
||||
fmt.Sprintf("%s:443", oldEndpoint.Addr().String()),
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
device.udptlspipe = srv
|
||||
}
|
||||
|
||||
// reset routine state
|
||||
peer.stopping.Wait()
|
||||
peer.stopping.Add(2)
|
||||
|
||||
Reference in new issue
Block a user