Add trojan over xtls support (#334)

* Add trojan over xtls support

* Add comments

* improve PR quality

* improve PR quality

* add xtls-rprx-origin-udp443 and xtls-rprx-direct-udp443

Co-authored-by: Eken Chan <maskedeken@yahoo.com>
This commit is contained in:
ekenchan
2020-10-20 10:44:31 +00:00
committed by GitHub
co-authored by Eken Chan
parent b562f21ca2
commit 3fc985dd0e
8 changed files with 288 additions and 332 deletions
+4
View File
@@ -21,6 +21,7 @@ type TrojanServerTarget struct {
Password string `json:"password"`
Email string `json:"email"`
Level byte `json:"level"`
Flow string `json:"flow"`
}
// TrojanClientConfig is configuration of trojan servers
@@ -49,6 +50,7 @@ func (c *TrojanClientConfig) Build() (proto.Message, error) {
}
account := &trojan.Account{
Password: rec.Password,
Flow: rec.Flow,
}
trojan := &protocol.ServerEndpoint{
Address: rec.Address.Build(),
@@ -84,6 +86,7 @@ type TrojanUserConfig struct {
Password string `json:"password"`
Level byte `json:"level"`
Email string `json:"email"`
Flow string `json:"flow"`
}
// TrojanServerConfig is Inbound configuration
@@ -106,6 +109,7 @@ func (c *TrojanServerConfig) Build() (proto.Message, error) {
user := new(protocol.User)
account := &trojan.Account{
Password: rawUser.Password,
Flow: rawUser.Flow,
}
user.Email = rawUser.Email
+4 -4
View File
@@ -188,8 +188,8 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) {
if err != nil {
return nil, err
}
if ss.SecurityType == serial.GetMessageType(&xtls.Config{}) && !strings.EqualFold(c.Protocol, "vless") {
return nil, newError("XTLS only supports VLESS for now.")
if ss.SecurityType == serial.GetMessageType(&xtls.Config{}) && !strings.EqualFold(c.Protocol, "vless") && !strings.EqualFold(c.Protocol, "trojan") {
return nil, newError("XTLS doesn't supports " + c.Protocol + " for now.")
}
receiverSettings.StreamSettings = ss
}
@@ -258,8 +258,8 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
if err != nil {
return nil, err
}
if ss.SecurityType == serial.GetMessageType(&xtls.Config{}) && !strings.EqualFold(c.Protocol, "vless") {
return nil, newError("XTLS only supports VLESS for now.")
if ss.SecurityType == serial.GetMessageType(&xtls.Config{}) && !strings.EqualFold(c.Protocol, "vless") && !strings.EqualFold(c.Protocol, "trojan") {
return nil, newError("XTLS doesn't supports " + c.Protocol + " for now.")
}
senderSettings.StreamSettings = ss
}