-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
711 changed files
with
82,154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,52 @@ | ||
# X-ray | ||
X-ray, Penetrate GFWs. The best v2ray-core, with XTLS support. Automatically patch and compile by GitHub Actions, fully compatible configuration. | ||
# Project X | ||
|
||
[Project X](https://github.com/XTLS) originates from XTLS protocol, provides a set of network tools such as [Xray-core](https://github.com/XTLS/Xray-core) and [Xray-flutter](https://github.com/XTLS/Xray-flutter). | ||
|
||
## Installation | ||
|
||
- Linux script | ||
- [Xray-install](https://github.com/XTLS/Xray-install) | ||
|
||
## Usage | ||
|
||
[Xray-examples](https://github.com/XTLS/Xray-examples) / [VLESS-TCP-XTLS-WHATEVER](https://github.com/XTLS/Xray-examples/tree/main/VLESS-TCP-XTLS-WHATEVER) | ||
|
||
## License | ||
|
||
[Mozilla Public License Version 2.0](https://github.com/XTLS/Xray-core/main/LICENSE) | ||
|
||
## Credits | ||
|
||
This repo relies on the following third-party projects: | ||
|
||
- Special thanks: | ||
- [v2fly/v2ray-core](https://github.com/v2fly/v2ray-core) | ||
- In production: | ||
- [gorilla/websocket](https://github.com/gorilla/websocket) | ||
- [lucas-clemente/quic-go](https://github.com/lucas-clemente/quic-go) | ||
- [pires/go-proxyproto](https://github.com/pires/go-proxyproto) | ||
- [seiflotfy/cuckoofilter](https://github.com/seiflotfy/cuckoofilter) | ||
- [google/starlark-go](https://github.com/google/starlark-go) | ||
- For testing only: | ||
- [miekg/dns](https://github.com/miekg/dns) | ||
- [h12w/socks](https://github.com/h12w/socks) | ||
|
||
## Compilation | ||
|
||
### Windows | ||
|
||
``` | ||
go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main | ||
``` | ||
|
||
### Linux / macOS | ||
|
||
``` | ||
go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main | ||
``` | ||
|
||
## Telegram | ||
|
||
[Project X](https://t.me/projectXray) | ||
|
||
[Project X Channel](https://t.me/projectXtls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package app contains feature implementations of Xray. The features may be enabled during runtime. | ||
package app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// +build !confonly | ||
|
||
package commander | ||
|
||
//go:generate go run github.com/xtls/xray-core/v1/common/errors/errorgen | ||
|
||
import ( | ||
"context" | ||
"net" | ||
"sync" | ||
|
||
"google.golang.org/grpc" | ||
|
||
"github.com/xtls/xray-core/v1/common" | ||
"github.com/xtls/xray-core/v1/common/signal/done" | ||
core "github.com/xtls/xray-core/v1/core" | ||
"github.com/xtls/xray-core/v1/features/outbound" | ||
) | ||
|
||
// Commander is a Xray feature that provides gRPC methods to external clients. | ||
type Commander struct { | ||
sync.Mutex | ||
server *grpc.Server | ||
services []Service | ||
ohm outbound.Manager | ||
tag string | ||
} | ||
|
||
// NewCommander creates a new Commander based on the given config. | ||
func NewCommander(ctx context.Context, config *Config) (*Commander, error) { | ||
c := &Commander{ | ||
tag: config.Tag, | ||
} | ||
|
||
common.Must(core.RequireFeatures(ctx, func(om outbound.Manager) { | ||
c.ohm = om | ||
})) | ||
|
||
for _, rawConfig := range config.Service { | ||
config, err := rawConfig.GetInstance() | ||
if err != nil { | ||
return nil, err | ||
} | ||
rawService, err := common.CreateObject(ctx, config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
service, ok := rawService.(Service) | ||
if !ok { | ||
return nil, newError("not a Service.") | ||
} | ||
c.services = append(c.services, service) | ||
} | ||
|
||
return c, nil | ||
} | ||
|
||
// Type implements common.HasType. | ||
func (c *Commander) Type() interface{} { | ||
return (*Commander)(nil) | ||
} | ||
|
||
// Start implements common.Runnable. | ||
func (c *Commander) Start() error { | ||
c.Lock() | ||
c.server = grpc.NewServer() | ||
for _, service := range c.services { | ||
service.Register(c.server) | ||
} | ||
c.Unlock() | ||
|
||
listener := &OutboundListener{ | ||
buffer: make(chan net.Conn, 4), | ||
done: done.New(), | ||
} | ||
|
||
go func() { | ||
if err := c.server.Serve(listener); err != nil { | ||
newError("failed to start grpc server").Base(err).AtError().WriteToLog() | ||
} | ||
}() | ||
|
||
if err := c.ohm.RemoveHandler(context.Background(), c.tag); err != nil { | ||
newError("failed to remove existing handler").WriteToLog() | ||
} | ||
|
||
return c.ohm.AddHandler(context.Background(), &Outbound{ | ||
tag: c.tag, | ||
listener: listener, | ||
}) | ||
} | ||
|
||
// Close implements common.Closable. | ||
func (c *Commander) Close() error { | ||
c.Lock() | ||
defer c.Unlock() | ||
|
||
if c.server != nil { | ||
c.server.Stop() | ||
c.server = nil | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func init() { | ||
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, cfg interface{}) (interface{}, error) { | ||
return NewCommander(ctx, cfg.(*Config)) | ||
})) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.