1 // udpobfs -- simple point-to-point UDP obfuscation proxy
2 // Copyright (C) 2023-2024 Sergey Matveev <stargrave@stargrave.org>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, version 3 of the License.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
25 const BufLen = 1 << 14
28 PingDuration = 10 * time.Second
29 LifetimeDuration = time.Minute
32 func MustWrite(w io.Writer, data []byte) {
33 if n, err := w.Write(data); err != nil || n != len(data) {
34 log.Fatal("non full write")
38 func Incr(buf []byte) (overflow bool) {
39 for i := len(buf) - 1; i >= 0; i-- {
49 func MustResolveUDPAddr(addr string) *net.UDPAddr {
50 a, err := net.ResolveUDPAddr("udp", addr)
57 func MustResolveTCPAddr(addr string) *net.TCPAddr {
58 a, err := net.ResolveTCPAddr("tcp", addr)