Skip to content

Commit 52940ae

Browse files
committed
Merge branch 'main' into socket_options
* main: (24 commits) Add "nosni" option to send empty SNI (XTLS#3214) API: add Source IP Block command (XTLS#3211) v1.8.10 Fix TestXrayConfig in xray_test.go Add separate host config for websocket Update proto file for websocket and httpupgrade (breaking) API - Add | Remove Routing Rules (XTLS#3189) Fix host in headers field does not work XTLS#3191 fix: config `burstObservatory` override Bump github.com/sagernet/sing from 0.3.6 to 0.3.8 Add support for HTTPupgrade custom headers improve balancer_info.go Fix(httpupgrade): `X-Forwarded-For` header not read. (XTLS#3172) Allow to send through random IPv6 Update HTTPUpgrade spelling and proto Chore: Clean up legacy `field` usage Update README.md Bump github.com/quic-go/quic-go from 0.41.0 to 0.42.0 Fix HTTPUpgrade transport register HTTPUpgrade 0-RTT (XTLS#3152) ...
2 parents 72c572d + ec22249 commit 52940ae

File tree

103 files changed

+1490
-649
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1490
-649
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
- [HiddifyNG](https://github.com/hiddify/HiddifyNG)
7878
- [X-flutter](https://github.com/XTLS/X-flutter)
7979
- iOS & macOS arm64
80-
- [Mango](https://github.com/arror/Mango)
8180
- [FoXray](https://apps.apple.com/app/foxray/id6448898396)
8281
- [Streisand](https://apps.apple.com/app/streisand/id6450534064)
8382
- macOS arm64 & x64

app/commander/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/dispatcher/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/dns/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/dns/fakedns/fakedns.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/dns/nameserver_quic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServ
4848
newError("DNS: created Local DNS-over-QUIC client for ", url.String()).AtInfo().WriteToLog()
4949

5050
var err error
51-
port := net.Port(784)
51+
port := net.Port(853)
5252
if url.Port() != "" {
5353
port, err = net.PortFromString(url.Port())
5454
if err != nil {

app/log/command/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/log/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/metrics/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/observatory/burst/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/observatory/command/command.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/observatory/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/policy/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/proxyman/command/command.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/proxyman/config.pb.go

+32-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/proxyman/config.proto

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ message SenderConfig {
9191
xray.transport.internet.StreamConfig stream_settings = 2;
9292
xray.transport.internet.ProxyConfig proxy_settings = 3;
9393
MultiplexingConfig multiplex_settings = 4;
94+
string via_cidr = 5;
9495
}
9596

9697
message MultiplexingConfig {

app/proxyman/outbound/handler.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"errors"
66
"io"
7+
"math/rand"
8+
gonet "net"
79
"os"
810

911
"github.com/xtls/xray-core/app/proxyman"
@@ -269,7 +271,11 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti
269271
outbound = new(session.Outbound)
270272
ctx = session.ContextWithOutbound(ctx, outbound)
271273
}
272-
outbound.Gateway = h.senderSettings.Via.AsAddress()
274+
if h.senderSettings.ViaCidr == "" {
275+
outbound.Gateway = h.senderSettings.Via.AsAddress()
276+
} else { //Get a random address.
277+
outbound.Gateway = ParseRandomIPv6(h.senderSettings.Via.AsAddress(), h.senderSettings.ViaCidr)
278+
}
273279
}
274280
}
275281

@@ -312,3 +318,17 @@ func (h *Handler) Close() error {
312318
common.Close(h.mux)
313319
return nil
314320
}
321+
322+
// Return random IPv6 in a CIDR block
323+
func ParseRandomIPv6(address net.Address, prefix string) net.Address {
324+
addr := address.IP().String()
325+
_, network, _ := gonet.ParseCIDR(addr + "/" + prefix)
326+
327+
ipv6 := network.IP.To16()
328+
prefixLen, _ := network.Mask.Size()
329+
for i := prefixLen / 8; i < 16; i++ {
330+
ipv6[i] = byte(rand.Intn(256))
331+
}
332+
333+
return net.ParseAddress(gonet.IP(ipv6).String())
334+
}

app/reverse/config.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/router/command/command.go

+14
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ func (s *routingServer) OverrideBalancerTarget(ctx context.Context, request *Ove
5454
return nil, newError("unsupported router implementation")
5555
}
5656

57+
func (s *routingServer) AddRule(ctx context.Context, request *AddRuleRequest) (*AddRuleResponse, error) {
58+
if bo, ok := s.router.(routing.Router); ok {
59+
return &AddRuleResponse{}, bo.AddRule(request.Config, request.ShouldAppend)
60+
}
61+
return nil, newError("unsupported router implementation")
62+
63+
}
64+
func (s *routingServer) RemoveRule(ctx context.Context, request *RemoveRuleRequest) (*RemoveRuleResponse, error) {
65+
if bo, ok := s.router.(routing.Router); ok {
66+
return &RemoveRuleResponse{}, bo.RemoveRule(request.RuleTag)
67+
}
68+
return nil, newError("unsupported router implementation")
69+
}
70+
5771
// NewRoutingServer creates a statistics service with statistics manager.
5872
func NewRoutingServer(router routing.Router, routingStats stats.Channel) RoutingServiceServer {
5973
return &routingServer{

0 commit comments

Comments
 (0)