// udpobfs -- simple point-to-point UDP obfuscation proxy // Copyright (C) 2023-2024 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package udpobfs import ( "io" "log" "net" "time" ) const BufLen = 1 << 14 var ( PingDuration = 10 * time.Second LifetimeDuration = time.Minute ) func MustWrite(w io.Writer, data []byte) { if n, err := w.Write(data); err != nil || n != len(data) { log.Fatal("non full write") } } func Incr(buf []byte) (overflow bool) { for i := len(buf) - 1; i >= 0; i-- { buf[i]++ if buf[i] != 0 { return } } overflow = true return } func MustResolveUDPAddr(addr string) *net.UDPAddr { a, err := net.ResolveUDPAddr("udp", addr) if err != nil { log.Fatal(err) } return a } func MustResolveTCPAddr(addr string) *net.TCPAddr { a, err := net.ResolveTCPAddr("tcp", addr) if err != nil { log.Fatal(err) } return a } type Buf struct { Buf *[BufLen]byte N int }