The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken) fix(protocol): restore broken share_modules.go and implement VLESS BuildShare The previous commit 658ef5c left share_modules.go starting with 'if' instead of 'package protocol', making the whole module unbuildable. This restores: - package declaration and imports - Trojan / Shadowsocks / Hysteria2 BuildShare methods - the missing VLESSCompiler.BuildShare (expected by share_reality_test.go) Also fixes reality public-key encoding in node/uri_builders.go to use RawURLEncoding (URL-safe) consistently, matching protocol expectations. Fixes: 658ef5c (build was broken)
30 lines
707 B
Go
30 lines
707 B
Go
package node
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRealityPublicKeyUsesRawURLEncoding(t *testing.T) {
|
|
cfg := map[string]interface{}{
|
|
"private-key": "jNXHt1yRo0vDuchQlIP6Z0ZvjT3KtzVI-T4E7RoLJS0",
|
|
}
|
|
|
|
got, err := realityPublicKey(cfg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
const want = "ZKKPN8Up66SimLskEzVwwOmIoPHTJNrDtvU5kXqGz1M"
|
|
if got != want {
|
|
t.Fatalf("public key = %q, want %q", got, want)
|
|
}
|
|
if strings.ContainsAny(got, "+/=") {
|
|
t.Fatalf("public key is not raw URL-safe base64: %q", got)
|
|
}
|
|
if raw, err := base64.RawURLEncoding.DecodeString(got); err != nil || len(raw) != 32 {
|
|
t.Fatalf("public key is not a valid 32-byte raw URL-safe base64 value: %q", got)
|
|
}
|
|
}
|