summaryrefslogtreecommitdiff
path: root/sni.go
diff options
context:
space:
mode:
Diffstat (limited to 'sni.go')
-rw-r--r--sni.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/sni.go b/sni.go
index e12c744..f0128bf 100644
--- a/sni.go
+++ b/sni.go
@@ -29,13 +29,19 @@ import (
//
// The ipPort is any valid net.Listen TCP address.
func (p *Proxy) AddSNIRoute(ipPort, sni string, dest Target) {
- p.addRoute(ipPort, sniMatch(sni), dest)
+ p.addRoute(ipPort, sniMatch{sni, dest})
}
-type sniMatch string
+type sniMatch struct {
+ sni string
+ target Target
+}
-func (sni sniMatch) match(br *bufio.Reader) bool {
- return clientHelloServerName(br) == string(sni)
+func (m sniMatch) match(br *bufio.Reader) Target {
+ if clientHelloServerName(br) == string(m.sni) {
+ return m.target
+ }
+ return nil
}
// clientHelloServerName returns the SNI server name inside the TLS ClientHello,