From a529261893f5d09051ab92e142a89f5a0c4010c4 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Sat, 1 Jan 2022 00:44:31 +0800 Subject: [PATCH] vmess: support zero security --- README.md | 4 ++-- config.go | 4 ++-- main.go | 2 +- proxy/vmess/client.go | 7 +++++-- service/dhcpd/dhcpd.go | 6 +++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b6df850..f253673 100644 --- a/README.md +++ b/README.md @@ -213,8 +213,8 @@ VMess scheme: vmess://[security:]uuid@host:port[?alterID=num] if alterID=0 or not set, VMessAEAD will be enabled -Available securities for vmess: - none, aes-128-gcm, chacha20-poly1305 +Available security for vmess: + zero, none, aes-128-gcm, chacha20-poly1305 VLESS scheme: vless://uuid@host:port[?fallback=127.0.0.1:80] diff --git a/config.go b/config.go index a88e634..d7a31a9 100644 --- a/config.go +++ b/config.go @@ -186,8 +186,8 @@ func usage() { fmt.Fprintf(w, " if alterID=0 or not set, VMessAEAD will be enabled\n") fmt.Fprintf(w, "\n") - fmt.Fprintf(w, "Available securities for vmess:\n") - fmt.Fprintf(w, " none, aes-128-gcm, chacha20-poly1305\n") + fmt.Fprintf(w, "Available security for vmess:\n") + fmt.Fprintf(w, " zero, none, aes-128-gcm, chacha20-poly1305\n") fmt.Fprintf(w, "\n") fmt.Fprintf(w, "VLESS scheme:\n") diff --git a/main.go b/main.go index e25693d..0e98ae2 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ import ( ) var ( - version = "0.15.2" + version = "0.15.3" config = parseConfig() ) diff --git a/proxy/vmess/client.go b/proxy/vmess/client.go index 628f9e5..412e3d8 100644 --- a/proxy/vmess/client.go +++ b/proxy/vmess/client.go @@ -27,7 +27,7 @@ const ( OptBasicFormat byte = 0 OptChunkStream byte = 1 // OptReuseTCPConnection byte = 2 - OptMetadataObfuscate byte = 4 + OptChunkMasking byte = 4 ) // Security types @@ -93,7 +93,7 @@ func NewClient(uuidStr, security string, alterID int, aead bool) (*Client, error c.users = append(c.users, user.GenAlterIDUsers(alterID)...) c.count = len(c.users) - c.opt = OptChunkStream | OptMetadataObfuscate + c.opt = OptChunkStream | OptChunkMasking c.aead = aead security = strings.ToLower(security) @@ -104,6 +104,9 @@ func NewClient(uuidStr, security string, alterID int, aead bool) (*Client, error c.security = SecurityChacha20Poly1305 case "none": c.security = SecurityNone + case "zero": + c.security = SecurityNone + c.opt = OptBasicFormat case "": c.security = SecurityChacha20Poly1305 if runtime.GOARCH == "amd64" || runtime.GOARCH == "s390x" || runtime.GOARCH == "arm64" { diff --git a/service/dhcpd/dhcpd.go b/service/dhcpd/dhcpd.go index 5d90511..0e2a48b 100644 --- a/service/dhcpd/dhcpd.go +++ b/service/dhcpd/dhcpd.go @@ -99,7 +99,7 @@ func handleDHCP(serverIP net.IP, mask net.IPMask, pool *Pool) server4.Handler { return } - replyIp, err := pool.LeaseIP(m.ClientHWAddr) + replyIP, err := pool.LeaseIP(m.ClientHWAddr) if err != nil { log.F("[dpcpd] can not assign IP, error %s", err) return @@ -109,7 +109,7 @@ func handleDHCP(serverIP net.IP, mask net.IPMask, pool *Pool) server4.Handler { dhcpv4.WithMessageType(replyType), dhcpv4.WithServerIP(serverIP), dhcpv4.WithNetmask(mask), - dhcpv4.WithYourIP(replyIp), + dhcpv4.WithYourIP(replyIP), dhcpv4.WithRouter(serverIP), dhcpv4.WithDNS(serverIP), // RFC 2131, Section 4.3.1. Server Identifier: MUST @@ -131,7 +131,7 @@ func handleDHCP(serverIP net.IP, mask net.IPMask, pool *Pool) server4.Handler { return } - log.F("[dpcpd] lease %v to client %v", replyIp, reply.ClientHWAddr) + log.F("[dpcpd] lease %v to client %v", replyIP, reply.ClientHWAddr) } }