mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00:00
Add option realitySettings.masterKeyLog
This commit is contained in:
parent
961cf9d3b1
commit
0ea2a50264
5 changed files with 44 additions and 13 deletions
|
@ -1,7 +1,9 @@
|
|||
package reality
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/xtls/reality"
|
||||
|
@ -25,6 +27,8 @@ func (c *Config) GetREALITYConfig() *reality.Config {
|
|||
|
||||
NextProtos: nil, // should be nil
|
||||
SessionTicketsDisabled: true,
|
||||
|
||||
KeyLogWriter: KeyLogWriterFromConfig(c),
|
||||
}
|
||||
config.ServerNames = make(map[string]bool)
|
||||
for _, serverName := range c.ServerNames {
|
||||
|
@ -37,6 +41,19 @@ func (c *Config) GetREALITYConfig() *reality.Config {
|
|||
return config
|
||||
}
|
||||
|
||||
func KeyLogWriterFromConfig(c *Config) io.Writer {
|
||||
if len(c.MasterKeyLog) <= 0 || c.MasterKeyLog == "none" {
|
||||
return nil
|
||||
}
|
||||
|
||||
writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)
|
||||
if err != nil {
|
||||
newError("failed to open ", c.MasterKeyLog, " as master key log").AtError().Base(err).WriteToLog()
|
||||
}
|
||||
|
||||
return writer
|
||||
}
|
||||
|
||||
func ConfigFromStreamSettings(settings *internet.MemoryStreamConfig) *Config {
|
||||
if settings == nil {
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue