mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-16 12:35:54 +00:00
1. **Fixed XPadding Placement Dropdown**: - Added the missing `cookie` and `query` options to `xPaddingPlacement` (`stream_xhttp.html`). - *Why:* Previously, users wanting `cookie` obfuscation were forced to use the `header` placement string. This caused Xray-core to blindly intercept the entire monolithic HTTP Cookie header, failing internal padding-length validations and causing the inbound to silently drop the connection. 2. **Fixed Uplink Data Placement Validation**: - Replaced the unsupported `query` option with `cookie` in `uplinkDataPlacement`. - *Why:* Xray-core's `transport_internet.go` explicitly forbids `query` as an uplink placement option. Selecting it from the UI previously sent a payload that would cause Xray-core to instantly throw an `unsupported uplink data placement: query` panic. Adding `cookie` perfectly aligns the UI with Xray-core restrictions. ### Related Issues - Resolves #3992
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Package net is a drop-in replacement to Golang's net package, with some more functionalities.
|
|
package net // import "github.com/xtls/xray-core/common/net"
|
|
|
|
import (
|
|
"net"
|
|
"sync/atomic"
|
|
"time"
|
|
|
|
"github.com/xtls/xray-core/common/errors"
|
|
)
|
|
|
|
// defines the maximum time an idle TCP session can survive in the tunnel, so
|
|
// it should be consistent across HTTP versions and with other transports.
|
|
const ConnIdleTimeout = 300 * time.Second
|
|
|
|
// consistent with quic-go
|
|
const QuicgoH3KeepAlivePeriod = 10 * time.Second
|
|
|
|
// consistent with chrome
|
|
const ChromeH2KeepAlivePeriod = 45 * time.Second
|
|
|
|
var ErrNotLocal = errors.New("the source address is not from local machine.")
|
|
|
|
type localIPCacheEntry struct {
|
|
addrs []net.Addr
|
|
lastUpdate time.Time
|
|
}
|
|
|
|
var localIPCache = atomic.Pointer[localIPCacheEntry]{}
|
|
|
|
func IsLocal(ip net.IP) (bool, error) {
|
|
var addrs []net.Addr
|
|
if entry := localIPCache.Load(); entry == nil || time.Since(entry.lastUpdate) > time.Minute {
|
|
var err error
|
|
addrs, err = net.InterfaceAddrs()
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
localIPCache.Store(&localIPCacheEntry{
|
|
addrs: addrs,
|
|
lastUpdate: time.Now(),
|
|
})
|
|
} else {
|
|
addrs = entry.addrs
|
|
}
|
|
for _, addr := range addrs {
|
|
if ipnet, ok := addr.(*net.IPNet); ok {
|
|
if ipnet.IP.Equal(ip) {
|
|
return true, nil
|
|
}
|
|
}
|
|
}
|
|
return false, nil
|
|
}
|