Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanaei <ho3ein.sanaei@gmail.com>2025-09-07 23:35:38 +0300
committerGitHub <noreply@github.com>2025-09-07 23:35:38 +0300
commitb008ff4ad236f20f0937dd02e747ca6581e776f3 (patch)
treeefcb43872da9f46f3e6a307424fb5e309e0e7737 /web/service/server.go
parentda6b89fdcd2270aa116297d9ff620b6331f39df9 (diff)
Vlessenc (#3426)
* mlkem768 * VlessEnc
Diffstat (limited to 'web/service/server.go')
-rw-r--r--web/service/server.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/web/service/server.go b/web/service/server.go
index 2dc83d77..3078e88b 100644
--- a/web/service/server.go
+++ b/web/service/server.go
@@ -871,3 +871,53 @@ func (s *ServerService) GetNewEchCert(sni string) (interface{}, error) {
"echConfigList": configList,
}, nil
}
+
+type AuthBlock struct {
+ Label string `json:"label"`
+ Decryption string `json:"decryption"`
+ Encryption string `json:"encryption"`
+}
+
+func (s *ServerService) GetNewVlessEnc() (any, error) {
+ cmd := exec.Command(xray.GetBinaryPath(), "vlessenc")
+ var out bytes.Buffer
+ cmd.Stdout = &out
+ if err := cmd.Run(); err != nil {
+ return nil, err
+ }
+
+ lines := strings.Split(out.String(), "\n")
+
+ var blocks []AuthBlock
+ var current *AuthBlock
+
+ for _, line := range lines {
+ line = strings.TrimSpace(line)
+ if strings.HasPrefix(line, "Authentication:") {
+ if current != nil {
+ blocks = append(blocks, *current)
+ }
+ current = &AuthBlock{Label: strings.TrimSpace(strings.TrimPrefix(line, "Authentication:"))}
+ } else if strings.HasPrefix(line, `"decryption"`) || strings.HasPrefix(line, `"encryption"`) {
+ parts := strings.SplitN(line, ":", 2)
+ if len(parts) == 2 && current != nil {
+ key := strings.Trim(parts[0], `" `)
+ val := strings.Trim(parts[1], `" `)
+ switch key {
+ case "decryption":
+ current.Decryption = val
+ case "encryption":
+ current.Encryption = val
+ }
+ }
+ }
+ }
+
+ if current != nil {
+ blocks = append(blocks, *current)
+ }
+
+ return map[string]any{
+ "auths": blocks,
+ }, nil
+}