Skip to content

Commit

Permalink
Add Authority to GRPC Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cyc0der committed Oct 4, 2024
1 parent ef05ba0 commit 79049d6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions xray/protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type GeneralConfig struct {
SNI string
ALPN string
TlsFingerprint string
Authority string
ServiceName string
Mode string
Type string
Expand Down Expand Up @@ -110,6 +111,7 @@ type Vless struct {
TlsFingerprint string `json:"fp"` // TLS fingerprint
Type string `json:"type"` // Network
Remark string `json:"ps"` // Config's name
Authority string `json:"authority"` // GRPC
ServiceName string `json:"serviceName"` // GRPC
Mode string `json:"mode"` // GRPC
OrigLink string `json:"-"` // Original link
Expand Down Expand Up @@ -142,6 +144,7 @@ type Trojan struct {
AllowInsecure string `json:"allowInsecure"` // Insecure TLS
Type string `json:"type"` // Network
Remark string // Config's name
Authority string `json:"authority"` // GRPC
ServiceName string `json:"serviceName"` // GRPC
Mode string `json:"mode"` // GRPC

Expand Down
6 changes: 5 additions & 1 deletion xray/trojan.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ func (t *Trojan) DetailsStr() string {
if copyV.ServiceName == "" {
copyV.ServiceName = "none"
}
info += fmt.Sprintf("%s: %s\n", color.RedString("ServiceName"), copyV.ServiceName)
info += fmt.Sprintf("%s: %s\n%s: %s\n",
color.RedString("ServiceName"), copyV.ServiceName,
color.RedString("Authority"), copyV.Authority)
}

if copyV.Security == "reality" {
Expand Down Expand Up @@ -174,6 +176,7 @@ func (t *Trojan) ConvertToGeneralConfig() GeneralConfig {
g.TLS = t.Security
}
g.TlsFingerprint = t.TlsFingerprint
g.Authority = t.Authority
g.ServiceName = t.ServiceName
g.Mode = t.Mode
g.Type = t.Type
Expand Down Expand Up @@ -261,6 +264,7 @@ func (t *Trojan) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDe
HealthCheckTimeout: 20,
MultiMode: multiMode,
IdleTimeout: 60,
Authority: t.Authority,
ServiceName: t.ServiceName,
}

Expand Down
9 changes: 8 additions & 1 deletion xray/vless.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ func (v *Vless) DetailsStr() string {
if copyV.ServiceName == "" {
copyV.ServiceName = "none"
}
info += fmt.Sprintf("%s: %s\n", color.RedString("ServiceName"), copyV.ServiceName)
if copyV.Authority == "" {
copyV.Authority = "none"
}
info += fmt.Sprintf("%s: %s\n%s: %s\n",
color.RedString("ServiceName"), copyV.ServiceName,
color.RedString("Authority"), copyV.Authority)
}

if copyV.Security == "reality" {
Expand Down Expand Up @@ -171,6 +176,7 @@ func (v *Vless) ConvertToGeneralConfig() GeneralConfig {
g.SNI = v.SNI
g.ALPN = v.ALPN
g.TlsFingerprint = v.TlsFingerprint
g.Authority = v.Authority
g.ServiceName = v.ServiceName
g.Mode = v.Mode
g.Type = v.Type
Expand Down Expand Up @@ -256,6 +262,7 @@ func (v *Vless) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDet
multiMode = true
}
s.GRPCConfig = &conf.GRPCConfig{
Authority: v.Authority,
ServiceName: v.ServiceName,
MultiMode: multiMode,
IdleTimeout: 60,
Expand Down
5 changes: 4 additions & 1 deletion xray/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ func (v *Vmess) DetailsStr() string {
if copyV.Host == "" {
copyV.Host = "none"
}
info += fmt.Sprintf("%s: %s\n", color.RedString("ServiceName"), copyV.Path)
info += fmt.Sprintf("%s: %s\n%s: %s\n",
color.RedString("ServiceName"), copyV.Path,
color.RedString("Authority"), copyV.Host)
}

if len(copyV.TLS) != 0 && copyV.TLS != "none" {
Expand Down Expand Up @@ -297,6 +299,7 @@ func (v *Vmess) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDet
HealthCheckTimeout: 20,
MultiMode: multiMode,
IdleTimeout: 60,
Authority: v.Host,
ServiceName: v.Path,
}
case "quic":
Expand Down

0 comments on commit 79049d6

Please sign in to comment.