mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-07 21:09:53 +00:00
Update Go dependencies and add secure key pair generation
Updated several Go dependencies for enhanced security and performance. Additionally, a command (`-x25519`) has been added for generating a secure key pair using X25519. This provides an easier and safer way for users to generate keys for secure communication. Further instructions have been reflected in the `config.yml.example` file.
This commit is contained in:
parent
551e2d4299
commit
edf02307ad
@ -1,2 +1,36 @@
|
||||
// Package common contains common utilities that are shared among other packages.
|
||||
package common
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/crypto/curve25519"
|
||||
)
|
||||
|
||||
func X25519() {
|
||||
var publicKey []byte
|
||||
privateKey := make([]byte, curve25519.ScalarSize)
|
||||
if _, err := rand.Read(privateKey); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Modify random bytes using algorithm described at:
|
||||
// https://cr.yp.to/ecdh.html.
|
||||
privateKey[0] &= 248
|
||||
privateKey[31] &= 127
|
||||
privateKey[31] |= 64
|
||||
|
||||
publicKey, err := curve25519.X25519(privateKey, curve25519.Basepoint)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
output := fmt.Sprintf("Private key: %v\nPublic key: %v",
|
||||
base64.RawURLEncoding.EncodeToString(privateKey),
|
||||
base64.RawURLEncoding.EncodeToString(publicKey))
|
||||
fmt.Println(output)
|
||||
}
|
||||
|
@ -53,14 +53,14 @@ Nodes:
|
||||
Dest: 80 # Required, Destination of fallback, check https://xtls.github.io/config/features/fallback.html for details.
|
||||
ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for disable
|
||||
DisableLocalREALITYConfig: false # disable local reality config
|
||||
EnableREALITY: true # Enable REALITY
|
||||
EnableREALITY: false # Enable REALITY
|
||||
REALITYConfigs:
|
||||
Show: true # Show REALITY debug
|
||||
Dest: www.smzdm.com:443 # Required, Same as fallback
|
||||
ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for disable
|
||||
ServerNames: # Required, list of available serverNames for the client, * wildcard is not supported at the moment.
|
||||
- www.smzdm.com
|
||||
PrivateKey: YOUR_PRIVATE_KEY # Required, execute './xray x25519' to generate.
|
||||
PrivateKey: YOUR_PRIVATE_KEY # Required, execute './XrayR -x25519' to generate.
|
||||
MinClientVer: # Optional, minimum version of Xray client, format is x.y.z.
|
||||
MaxClientVer: # Optional, maximum version of Xray client, format is x.y.z.
|
||||
MaxTimeDiff: 0 # Optional, maximum allowed time difference, unit is in milliseconds.
|
||||
|
@ -15,12 +15,14 @@ import (
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/XrayR-project/XrayR/common"
|
||||
"github.com/XrayR-project/XrayR/panel"
|
||||
)
|
||||
|
||||
var (
|
||||
configFile = flag.String("config", "", "Config file for XrayR.")
|
||||
printVersion = flag.Bool("version", false, "show version")
|
||||
x25519 = flag.Bool("x25519", false, "Generate key pair for x25519 key exchange")
|
||||
)
|
||||
|
||||
var (
|
||||
@ -71,6 +73,10 @@ func main() {
|
||||
if *printVersion {
|
||||
return
|
||||
}
|
||||
if *x25519 {
|
||||
common.X25519()
|
||||
return
|
||||
}
|
||||
|
||||
config := getConfig()
|
||||
panelConfig := &panel.Config{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user