From 96f06e0a8c7c662ebfbe15739fa0bc8232185ff7 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 18 Aug 2023 02:18:31 +0900 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81V2board=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=B8=8B=E5=8F=91private=5Fkey=E5=92=8CshortId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/apimodel.go | 2 ++ api/newV2board/model.go | 5 +++++ api/newV2board/v2board.go | 4 +++- service/controller/inboundbuilder.go | 8 ++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/api/apimodel.go b/api/apimodel.go index 7b89da32c..b3e1c23b3 100644 --- a/api/apimodel.go +++ b/api/apimodel.go @@ -49,6 +49,8 @@ type NodeInfo struct { EnableTLS bool EnableVless bool VlessFlow string + PrivateKey string + ShortId string CypherMethod string ServerKey string ServiceName string diff --git a/api/newV2board/model.go b/api/newV2board/model.go index a1066036d..dcc39dcec 100644 --- a/api/newV2board/model.go +++ b/api/newV2board/model.go @@ -36,6 +36,11 @@ type v2ray struct { Header *json.RawMessage `json:"header"` } `json:"networkSettings"` VlessFlow string `json:"flow"` + TlsSettings struct { + Sni string `json:"server_name"` + PrivateKey string `json:"private_key"` + ShortId string `json:"shortId"` + } `json:"tls_settings"` Tls int `json:"tls"` } diff --git a/api/newV2board/v2board.go b/api/newV2board/v2board.go index 90523c546..bbcd153ae 100644 --- a/api/newV2board/v2board.go +++ b/api/newV2board/v2board.go @@ -386,7 +386,7 @@ func (c *APIClient) parseV2rayNodeResponse(s *serverConfig) (*api.NodeInfo, erro } } - if s.Tls == 1 { + if s.Tls != 0 { enableTLS = true } @@ -402,6 +402,8 @@ func (c *APIClient) parseV2rayNodeResponse(s *serverConfig) (*api.NodeInfo, erro Host: host, EnableVless: c.EnableVless, VlessFlow: s.VlessFlow, + PrivateKey: s.TlsSettings.PrivateKey, + ShortId: s.TlsSettings.ShortId, ServiceName: s.NetworkSettings.ServiceName, Header: header, NameServerConfig: s.parseDNSConfig(), diff --git a/service/controller/inboundbuilder.go b/service/controller/inboundbuilder.go index c531fea22..797d8f49d 100644 --- a/service/controller/inboundbuilder.go +++ b/service/controller/inboundbuilder.go @@ -191,16 +191,20 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I return nil, fmt.Errorf("marshal dest %s config fialed: %s", dest, err) } streamSetting.Security = "reality" + private_key := nodeInfo.PrivateKey + if private_key == "" { + private_key = config.REALITYConfigs.PrivateKey + } streamSetting.REALITYSettings = &conf.REALITYConfig{ Show: config.REALITYConfigs.Show, Dest: dest, Xver: config.REALITYConfigs.ProxyProtocolVer, ServerNames: config.REALITYConfigs.ServerNames, - PrivateKey: config.REALITYConfigs.PrivateKey, + PrivateKey: private_key, MinClientVer: config.REALITYConfigs.MinClientVer, MaxClientVer: config.REALITYConfigs.MaxClientVer, MaxTimeDiff: config.REALITYConfigs.MaxTimeDiff, - ShortIds: config.REALITYConfigs.ShortIds, + ShortIds: append(config.REALITYConfigs.ShortIds, nodeInfo.ShortId), } } else if nodeInfo.EnableTLS && config.CertConfig.CertMode != "none" { streamSetting.Security = "tls"