Skip to content

Commit

Permalink
支持V2board面板下发private_key和shortId
Browse files Browse the repository at this point in the history
  • Loading branch information
wyx2685 committed Aug 17, 2023
1 parent 1e3babf commit 96f06e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/apimodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type NodeInfo struct {
EnableTLS bool
EnableVless bool
VlessFlow string
PrivateKey string
ShortId string
CypherMethod string
ServerKey string
ServiceName string
Expand Down
5 changes: 5 additions & 0 deletions api/newV2board/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
4 changes: 3 additions & 1 deletion api/newV2board/v2board.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (c *APIClient) parseV2rayNodeResponse(s *serverConfig) (*api.NodeInfo, erro
}
}

if s.Tls == 1 {
if s.Tls != 0 {
enableTLS = true
}

Expand All @@ -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(),
Expand Down
8 changes: 6 additions & 2 deletions service/controller/inboundbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 96f06e0

Please sign in to comment.