Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.08 KB

File metadata and controls

57 lines (42 loc) · 1.08 KB

Extending the Project

Adding a New Protocol

To add support for a new protocol (e.g., WireGuard or SOCKS5), implement the ProxyLink interface:

// internal/wireguard/wireguard.go
package wireguard

import (
    "regexp"
    "strings"
)

type WireGuardLink struct{}

func (w WireGuardLink) Matches(s string) bool {
    return strings.HasPrefix(s, "wg://")
}

func (w WireGuardLink) Process(s string) (string, string) {
    // Parse and validate WireGuard link
    // Returns: (cleaned link, country)
    return s, "US" // example
}

Then register in pkg/service/service.go:

// In createProxyProcessors add:
processors["wireguard"] = &wireguard.WireGuardLink{}

Adding a New Validation Rule

Add to config/rules.yaml:

wireguard:
  required_params: [public_key, endpoint]
  forbidden_values:
    endpoint: ["localhost", "127.0.0.1"]

Testing

Create wireguard_test.go with unit tests:

func TestWireGuardLink_Matches(t *testing.T) {
    wg := WireGuardLink{}
    assert.True(t, wg.Matches("wg://..."))
    assert.False(t, wg.Matches("ss://..."))
}