This commit is contained in:
jdl 2025-08-26 16:20:47 +02:00
parent 3c4534f620
commit 31c48fbafd

View File

@ -163,24 +163,16 @@ func (r *Remote) sendControl(conf remoteConfig, data []byte) {
return
}
// Direct:
if conf.Direct {
r.sendControlDirect(conf, data)
} else {
r.sendControlRelayed(conf, data)
}
}
func (r *Remote) sendControlToAddr(buf []byte, addr netip.AddrPort) {
enc := r.encryptControl(r.conf(), buf)
r.sendUDP(enc, addr)
}
func (r *Remote) sendControlDirect(conf remoteConfig, data []byte) {
enc := r.encryptControl(conf, data)
r.sendUDP(enc, conf.DirectAddr)
}
return
}
// Relayed:
func (r *Remote) sendControlRelayed(conf remoteConfig, data []byte) {
relay := r.RelayHandler.Load()
if relay == nil {
@ -191,6 +183,11 @@ func (r *Remote) sendControlRelayed(conf remoteConfig, data []byte) {
relay.relayData(conf.Peer.PeerIP, r.encryptControl(conf, data))
}
func (r *Remote) sendControlToAddr(buf []byte, addr netip.AddrPort) {
enc := r.encryptControl(r.conf(), buf)
r.sendUDP(enc, addr)
}
func (r *Remote) forwardPacket(data []byte) {
conf := r.conf()
if !conf.Up || !conf.Direct {