fix(dialer): correct inverted setMark on FreeBSD/OpenBSD
Fix setMark early-return conditions that were inverted relative to Linux: on FreeBSD (SO_USER_COOKIE) and OpenBSD (SO_RTABLE), a non-zero mark was short-circuited instead of applied, disabling socket marking entirely. Also fix GetClientIP to trim leading whitespace from X-Forwarded-For entries (per RFC 7239), and fix Body.Read to subtract len(b) instead of n from recordSize when a single read exceeds the remaining quota. Add unit tests for internal/net/ (addr, dialer, http, ip, net, pipe, transport, resolve, proxyproto, udp).
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package dialer
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/go-gost/core/logger"
|
||||
)
|
||||
|
||||
type nopLogger struct{}
|
||||
|
||||
func (l *nopLogger) WithFields(map[string]any) logger.Logger { return l }
|
||||
func (l *nopLogger) Trace(args ...any) {}
|
||||
func (l *nopLogger) Tracef(format string, args ...any) {}
|
||||
func (l *nopLogger) Debug(args ...any) {}
|
||||
func (l *nopLogger) Debugf(format string, args ...any) {}
|
||||
func (l *nopLogger) Info(args ...any) {}
|
||||
func (l *nopLogger) Infof(format string, args ...any) {}
|
||||
func (l *nopLogger) Warn(args ...any) {}
|
||||
func (l *nopLogger) Warnf(format string, args ...any) {}
|
||||
func (l *nopLogger) Error(args ...any) {}
|
||||
func (l *nopLogger) Errorf(format string, args ...any) {}
|
||||
func (l *nopLogger) Fatal(args ...any) {}
|
||||
func (l *nopLogger) Fatalf(format string, args ...any) {}
|
||||
func (l *nopLogger) GetLevel() logger.LogLevel { return logger.InfoLevel }
|
||||
func (l *nopLogger) IsLevelEnabled(level logger.LogLevel) bool { return false }
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
logger.SetDefault(&nopLogger{})
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
Reference in New Issue
Block a user