mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
Some checks failed
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Failing after 1s
Test / test (1.21, ubuntu-latest) (push) Failing after 1s
Test / test (1.22, ubuntu-latest) (push) Failing after 1s
Test / test (1.23, ubuntu-latest) (push) Failing after 1s
Test / test (1.24, ubuntu-latest) (push) Failing after 1s
Trigger CMFA Update / trigger-CMFA-update (push) Failing after 1s
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package generater
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"fmt"
|
|
|
|
"github.com/metacubex/mihomo/component/ech"
|
|
|
|
"github.com/gofrs/uuid/v5"
|
|
)
|
|
|
|
func Main(args []string) {
|
|
if len(args) < 1 {
|
|
panic("Using: generate uuid/reality-keypair/wg-keypair/ech-keypair")
|
|
}
|
|
switch args[0] {
|
|
case "uuid":
|
|
newUUID, err := uuid.NewV4()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(newUUID.String())
|
|
case "reality-keypair":
|
|
privateKey, err := GeneratePrivateKey()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
publicKey := privateKey.PublicKey()
|
|
fmt.Println("PrivateKey: " + base64.RawURLEncoding.EncodeToString(privateKey[:]))
|
|
fmt.Println("PublicKey: " + base64.RawURLEncoding.EncodeToString(publicKey[:]))
|
|
case "wg-keypair":
|
|
privateKey, err := GeneratePrivateKey()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println("PrivateKey: " + privateKey.String())
|
|
fmt.Println("PublicKey: " + privateKey.PublicKey().String())
|
|
case "ech-keypair":
|
|
if len(args) < 2 {
|
|
panic("Using: generate ech-keypair <plain_server_name>")
|
|
}
|
|
configBase64, keyPem, err := ech.GenECHConfig(args[1])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println("Config:", configBase64)
|
|
fmt.Println("Key:", keyPem)
|
|
}
|
|
}
|