// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage vnetimport ()// Deliver directly send packet to vnet or real-server.// For example, we can use this API to simulate the REPLAY ATTACK.func ( *UDPProxy) (, net.Addr, []byte) ( int, error) { .workers.Range(func(, interface{}) bool {if , = .(*aUDPProxyWorker).Deliver(, , ); != nil {returnfalse// Fail, abort. } elseif == len() {returnfalse// Done. }returntrue// Deliver by next worker. })return}func ( *aUDPProxyWorker) (, net.Addr, []byte) ( int, error) { , := .(*net.UDPAddr)if ! {return0, fmt.Errorf("invalid addr %v", ) // nolint:goerr113 }// nolint:godox // TODO: Support deliver packet from real server to vnet. // If packet is from vnet, proxy to real server.var *net.UDPConn , := .endpoints.Load(.String())if ! {return0, nil } = .(*net.UDPConn) // nolint:forcetypeassert// Send to real server.if , := .Write(); != nil {return0, }returnlen(), nil}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.