Common Go code shared between the desktop and Android implementations of Snirect.
Pattern matching library for domain/host patterns with support for:
- Wildcards:
*.example.com,example*,*example.com - Exclusion operator:
pattern^exclude(e.g.,*.yahoo.com^*.media.yahoo.com) - Ignore prefixes:
#,$,^at the start
Certificate Authority management for HTTPS proxy:
- Root CA generation and loading
- Leaf certificate signing
- Certificate caching with automatic cleanup
import "github.com/xihale/snirect/shared/pattern"
matched := pattern.MatchPattern("*.yahoo.com^*.media.yahoo.com", "www.yahoo.com")
// matched == true
matched := pattern.MatchPattern("*.yahoo.com^*.media.yahoo.com", "media.yahoo.com")
// matched == false (excluded)import "github.com/xihale/snirect/shared/cert"
cm, err := cert.NewCertManager(caCertPath, caKeyPath)
if err != nil {
log.Fatal(err)
}
defer cm.Close()
// Sign a leaf certificate for a host
certBytes, privKey, err := cm.SignLeafCert([]string{"example.com"})Run tests:
go test ./...MIT