mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 05:19:54 +00:00
add quic support and fixed some bug
This commit is contained in:
parent
9261a6063d
commit
175e46d0b7
@ -37,25 +37,47 @@ type NodeStatus struct {
|
||||
}
|
||||
|
||||
type NodeInfo struct {
|
||||
NodeType string // Must be V2ray, Trojan, and Shadowsocks
|
||||
NodeID int
|
||||
Port uint32
|
||||
SpeedLimit uint64 // Bps
|
||||
AlterID uint16
|
||||
TransportProtocol string
|
||||
FakeType string
|
||||
Host string
|
||||
Path string
|
||||
EnableTLS bool
|
||||
EnableVless bool
|
||||
VlessFlow string
|
||||
CypherMethod string
|
||||
ServerKey string
|
||||
ServiceName string
|
||||
Header json.RawMessage
|
||||
NameServerConfig []*conf.NameServerConfig
|
||||
EnableREALITY bool
|
||||
REALITYConfig *REALITYConfig
|
||||
AcceptProxyProtocol bool
|
||||
Authority string
|
||||
NodeType string // Must be V2ray, Trojan, and Shadowsocks
|
||||
NodeID int
|
||||
Port uint32
|
||||
SpeedLimit uint64 // Bps
|
||||
AlterID uint16
|
||||
TransportProtocol string
|
||||
FakeType string
|
||||
Host string
|
||||
Path string
|
||||
EnableTLS bool
|
||||
EnableSniffing bool
|
||||
RouteOnly bool
|
||||
EnableVless bool
|
||||
VlessFlow string
|
||||
CypherMethod string
|
||||
ServerKey string
|
||||
ServiceName string
|
||||
Method string
|
||||
Header json.RawMessage
|
||||
HttpHeaders map[string]*conf.StringList
|
||||
Headers map[string]string
|
||||
NameServerConfig []*conf.NameServerConfig
|
||||
EnableREALITY bool
|
||||
REALITYConfig *REALITYConfig
|
||||
Show bool
|
||||
EnableTFO bool
|
||||
Dest string
|
||||
ProxyProtocolVer uint64
|
||||
ServerNames []string
|
||||
PrivateKey string
|
||||
MinClientVer string
|
||||
MaxClientVer string
|
||||
MaxTimeDiff uint64
|
||||
ShortIds []string
|
||||
Xver uint64
|
||||
Flow string
|
||||
Security string
|
||||
Key string
|
||||
RejectUnknownSni bool
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
|
@ -177,7 +177,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
c.resp.Store(server)
|
||||
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
nodeInfo, err = c.parseV2rayNodeResponse(server)
|
||||
case "Trojan":
|
||||
nodeInfo, err = c.parseTrojanNodeResponse(server)
|
||||
@ -200,7 +200,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
path := "/api/server/user"
|
||||
|
||||
switch c.NodeType {
|
||||
case "V2ray", "Trojan", "Shadowsocks":
|
||||
case "V2ray", "Trojan", "Shadowsocks", "Vmess", "Vless":
|
||||
break
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported node type: %s", c.NodeType)
|
||||
|
@ -184,7 +184,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
c.resp.Store(server)
|
||||
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
nodeInfo, err = c.parseV2rayNodeResponse(server)
|
||||
case "Trojan":
|
||||
nodeInfo, err = c.parseTrojanNodeResponse(server)
|
||||
@ -207,7 +207,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
path := "/api/v1/server/UniProxy/user"
|
||||
|
||||
switch c.NodeType {
|
||||
case "V2ray", "Trojan", "Shadowsocks":
|
||||
case "V2ray", "Trojan", "Shadowsocks", "Vmess", "Vless":
|
||||
break
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported node type: %s", c.NodeType)
|
||||
|
@ -145,7 +145,7 @@ func (c *APIClient) parseResponse(res *resty.Response, path string, err error) (
|
||||
func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/node/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/node/%d", c.NodeID)
|
||||
@ -166,7 +166,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
}
|
||||
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
nodeInfo, err = c.ParseV2rayNodeResponse(&response.Data)
|
||||
case "Trojan":
|
||||
nodeInfo, err = c.ParseTrojanNodeResponse(&response.Data)
|
||||
@ -188,7 +188,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/userList/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/userList/%d", c.NodeID)
|
||||
@ -209,7 +209,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
}
|
||||
userList := new([]api.UserInfo)
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
userList, err = c.ParseV2rayUserListResponse(&response.Data)
|
||||
case "Trojan":
|
||||
userList, err = c.ParseTrojanUserListResponse(&response.Data)
|
||||
@ -229,7 +229,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) {
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/nodeStatus/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/nodeStatus/%d", c.NodeID)
|
||||
@ -265,7 +265,7 @@ func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) erro
|
||||
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/nodeOnline/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/nodeOnline/%d", c.NodeID)
|
||||
@ -298,7 +298,7 @@ func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) erro
|
||||
func (c *APIClient) ReportUserTraffic(userTraffic *[]api.UserTraffic) error {
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/userTraffic/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/userTraffic/%d", c.NodeID)
|
||||
@ -333,7 +333,7 @@ func (c *APIClient) ReportUserTraffic(userTraffic *[]api.UserTraffic) error {
|
||||
func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/nodeRule/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/nodeRule/%d", c.NodeID)
|
||||
@ -381,7 +381,7 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
|
||||
func (c *APIClient) ReportIllegal(detectResultList *[]api.DetectResult) error {
|
||||
var path string
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
path = fmt.Sprintf("/api/v2ray/v1/trigger/%d", c.NodeID)
|
||||
case "Trojan":
|
||||
path = fmt.Sprintf("/api/trojan/v1/trigger/%d", c.NodeID)
|
||||
|
@ -151,7 +151,7 @@ func (c *APIClient) parseResponse(res *resty.Response, path string, err error) (
|
||||
func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
var nodeType string
|
||||
switch c.NodeType {
|
||||
case "V2ray", "Trojan", "Shadowsocks":
|
||||
case "V2ray", "Vmess", "Vless", "Trojan", "Shadowsocks":
|
||||
nodeType = strings.ToLower(c.NodeType)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
|
||||
@ -183,7 +183,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
}
|
||||
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
nodeInfo, err = c.ParseV2rayNodeResponse(response)
|
||||
case "Trojan":
|
||||
nodeInfo, err = c.ParseTrojanNodeResponse(response)
|
||||
@ -205,7 +205,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
||||
func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
var nodeType string
|
||||
switch c.NodeType {
|
||||
case "V2ray", "Trojan", "Shadowsocks":
|
||||
case "V2ray", "Vmess", "Vless", "Trojan", "Shadowsocks":
|
||||
nodeType = strings.ToLower(c.NodeType)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
|
||||
@ -249,7 +249,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
user.Email = response.Get("data").GetIndex(i).Get("trojan_user").Get("password").MustString()
|
||||
user.SpeedLimit = response.Get("data").GetIndex(i).Get("trojan_user").Get("speed_limit").MustUint64() * 1000000 / 8
|
||||
user.DeviceLimit = response.Get("data").GetIndex(i).Get("trojan_user").Get("device_limit").MustInt()
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
user.UUID = response.Get("data").GetIndex(i).Get("v2ray_user").Get("uuid").MustString()
|
||||
user.Email = response.Get("data").GetIndex(i).Get("v2ray_user").Get("email").MustString()
|
||||
user.AlterID = uint16(response.Get("data").GetIndex(i).Get("v2ray_user").Get("alter_id").MustUint64())
|
||||
@ -263,7 +263,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
if c.DeviceLimit > 0 {
|
||||
user.DeviceLimit = c.DeviceLimit
|
||||
}
|
||||
|
||||
|
||||
userList[i] = user
|
||||
}
|
||||
return &userList, nil
|
||||
|
@ -18,7 +18,7 @@ Nodes:
|
||||
ApiHost: "http://127.0.0.1:667"
|
||||
ApiKey: "123"
|
||||
NodeID: 41
|
||||
NodeType: V2ray # Node type: V2ray, Shadowsocks, Trojan, Shadowsocks-Plugin
|
||||
NodeType: V2ray # Node type: V2ray,vmess,vless, Shadowsocks, Trojan, Shadowsocks-Plugin
|
||||
Timeout: 30 # Timeout for the api request
|
||||
EnableVless: false # Enable Vless for V2ray Type
|
||||
VlessFlow: "xtls-rprx-vision" # Only support vless
|
||||
|
@ -405,7 +405,7 @@ func (c *Controller) addInboundForSSPlugin(newNodeInfo api.NodeInfo) (err error)
|
||||
func (c *Controller) addNewUser(userInfo *[]api.UserInfo, nodeInfo *api.NodeInfo) (err error) {
|
||||
users := make([]*protocol.User, 0)
|
||||
switch nodeInfo.NodeType {
|
||||
case "V2ray":
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
if nodeInfo.EnableVless {
|
||||
users = c.buildVlessUser(userInfo)
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
||||
// SniffingConfig
|
||||
sniffingConfig := &conf.SniffingConfig{
|
||||
Enabled: true,
|
||||
DestOverride: &conf.StringList{"http", "tls"},
|
||||
DestOverride: &conf.StringList{"http", "tls", "quic", "fakedns"},
|
||||
}
|
||||
if config.DisableSniffing {
|
||||
sniffingConfig.Enabled = false
|
||||
@ -57,8 +57,8 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
||||
var proxySetting any
|
||||
// Build Protocol and Protocol setting
|
||||
switch nodeInfo.NodeType {
|
||||
case "V2ray":
|
||||
if nodeInfo.EnableVless {
|
||||
case "V2ray", "Vmess", "Vless":
|
||||
if nodeInfo.EnableVless || nodeInfo.NodeType == "Vless" {
|
||||
protocol = "vless"
|
||||
// Enable fallback
|
||||
if config.EnableFallback {
|
||||
@ -164,6 +164,7 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
||||
headers["Host"] = nodeInfo.Host
|
||||
wsSettings := &conf.WebSocketConfig{
|
||||
AcceptProxyProtocol: config.EnableProxyProtocol,
|
||||
Host: nodeInfo.Host,
|
||||
Path: nodeInfo.Path,
|
||||
Headers: headers,
|
||||
}
|
||||
@ -171,17 +172,34 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
||||
case "http":
|
||||
hosts := conf.StringList{nodeInfo.Host}
|
||||
httpSettings := &conf.HTTPConfig{
|
||||
Host: &hosts,
|
||||
Path: nodeInfo.Path,
|
||||
Host: &hosts,
|
||||
Path: nodeInfo.Path,
|
||||
Method: nodeInfo.Method,
|
||||
Headers: nodeInfo.HttpHeaders,
|
||||
}
|
||||
streamSetting.HTTPSettings = httpSettings
|
||||
case "grpc":
|
||||
grpcSettings := &conf.GRPCConfig{
|
||||
ServiceName: nodeInfo.ServiceName,
|
||||
Authority: nodeInfo.Authority,
|
||||
}
|
||||
streamSetting.GRPCConfig = grpcSettings
|
||||
case "quic":
|
||||
quicSettings := &conf.QUICConfig{
|
||||
Header: nodeInfo.Header,
|
||||
Security: nodeInfo.Security,
|
||||
Key: nodeInfo.Key,
|
||||
}
|
||||
streamSetting.QUICSettings = quicSettings
|
||||
case "httpupgrade":
|
||||
httpupgradeSettings := &conf.HttpUpgradeConfig{
|
||||
Headers: nodeInfo.Headers,
|
||||
Path: nodeInfo.Path,
|
||||
Host: nodeInfo.Host,
|
||||
AcceptProxyProtocol: nodeInfo.AcceptProxyProtocol,
|
||||
}
|
||||
streamSetting.HTTPUPGRADESettings = httpupgradeSettings
|
||||
}
|
||||
|
||||
streamSetting.Network = &transportProtocol
|
||||
|
||||
// Build TLS and REALITY settings
|
||||
|
Loading…
x
Reference in New Issue
Block a user