Skip to content

Commit

Permalink
Merge branch 'main' into socket_options
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
arror committed Apr 2, 2024
2 parents 72c572d + ec22249 commit 52940ae
Show file tree
Hide file tree
Showing 103 changed files with 1,490 additions and 649 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
- [HiddifyNG](https://github.com/hiddify/HiddifyNG)
- [X-flutter](https://github.com/XTLS/X-flutter)
- iOS & macOS arm64
- [Mango](https://github.com/arror/Mango)
- [FoXray](https://apps.apple.com/app/foxray/id6448898396)
- [Streisand](https://apps.apple.com/app/streisand/id6450534064)
- macOS arm64 & x64
Expand Down
2 changes: 1 addition & 1 deletion app/commander/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/dispatcher/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/dns/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/dns/fakedns/fakedns.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/dns/nameserver_quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServ
newError("DNS: created Local DNS-over-QUIC client for ", url.String()).AtInfo().WriteToLog()

var err error
port := net.Port(784)
port := net.Port(853)
if url.Port() != "" {
port, err = net.PortFromString(url.Port())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/log/command/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/log/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/metrics/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/observatory/burst/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/observatory/command/command.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/observatory/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/policy/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/proxyman/command/command.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 32 additions & 22 deletions app/proxyman/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/proxyman/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ message SenderConfig {
xray.transport.internet.StreamConfig stream_settings = 2;
xray.transport.internet.ProxyConfig proxy_settings = 3;
MultiplexingConfig multiplex_settings = 4;
string via_cidr = 5;
}

message MultiplexingConfig {
Expand Down
22 changes: 21 additions & 1 deletion app/proxyman/outbound/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"errors"
"io"
"math/rand"
gonet "net"
"os"

"github.com/xtls/xray-core/app/proxyman"
Expand Down Expand Up @@ -269,7 +271,11 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti
outbound = new(session.Outbound)
ctx = session.ContextWithOutbound(ctx, outbound)
}
outbound.Gateway = h.senderSettings.Via.AsAddress()
if h.senderSettings.ViaCidr == "" {
outbound.Gateway = h.senderSettings.Via.AsAddress()
} else { //Get a random address.
outbound.Gateway = ParseRandomIPv6(h.senderSettings.Via.AsAddress(), h.senderSettings.ViaCidr)
}
}
}

Expand Down Expand Up @@ -312,3 +318,17 @@ func (h *Handler) Close() error {
common.Close(h.mux)
return nil
}

// Return random IPv6 in a CIDR block
func ParseRandomIPv6(address net.Address, prefix string) net.Address {
addr := address.IP().String()
_, network, _ := gonet.ParseCIDR(addr + "/" + prefix)

ipv6 := network.IP.To16()
prefixLen, _ := network.Mask.Size()
for i := prefixLen / 8; i < 16; i++ {
ipv6[i] = byte(rand.Intn(256))
}

return net.ParseAddress(gonet.IP(ipv6).String())
}
2 changes: 1 addition & 1 deletion app/reverse/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions app/router/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ func (s *routingServer) OverrideBalancerTarget(ctx context.Context, request *Ove
return nil, newError("unsupported router implementation")
}

func (s *routingServer) AddRule(ctx context.Context, request *AddRuleRequest) (*AddRuleResponse, error) {
if bo, ok := s.router.(routing.Router); ok {
return &AddRuleResponse{}, bo.AddRule(request.Config, request.ShouldAppend)
}
return nil, newError("unsupported router implementation")

}
func (s *routingServer) RemoveRule(ctx context.Context, request *RemoveRuleRequest) (*RemoveRuleResponse, error) {
if bo, ok := s.router.(routing.Router); ok {
return &RemoveRuleResponse{}, bo.RemoveRule(request.RuleTag)
}
return nil, newError("unsupported router implementation")
}

// NewRoutingServer creates a statistics service with statistics manager.
func NewRoutingServer(router routing.Router, routingStats stats.Channel) RoutingServiceServer {
return &routingServer{
Expand Down
Loading

0 comments on commit 52940ae

Please sign in to comment.