From e34c2a61afa52bf8cc245c1ff75cca10b231050e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 1 Jan 2017 14:19:09 -0800 Subject: Add more words to README. --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++-- config.go | 5 +++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b74ca69..dff5524 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,41 @@ -This is a TLS proxy that routes connections to backends based on the TLS SNI (Server Name Indication) field of the TLS handshake. It carries no encryption keys and cannot decode the traffic that it proxies. +# TLS SNI router -This is not an official Google product. +[![license](https://img.shields.io/github/license/google/tlsrouter.svg?maxAge=2592000)](https://github.com/google/tlsrouter/blob/master/LICENSE) [![Travis](https://img.shields.io/travis/google/tlsrouter.svg?maxAge=2592000)](https://travis-ci.org/google/tlsrouter) [![api](https://img.shields.io/badge/api-unstable-red.svg)](https://godoc.org/go.universe.tf/tlsrouter) + +TLSRouter is a TLS proxy that routes connections to backends based on the TLS SNI (Server Name Indication) of the TLS handshake. It carries no encryption keys and cannot decode the traffic that it proxies. + +This is not an official Google project. + +## Installation + +Install TLSRouter via `go get`: + +```shell +go get go.universe.tf/tlsrouter +``` + +## Usage + +TLSRouter requires a configuration file that tells it what backend to +use for a given hostname. The config file looks like: + +``` +# Basic hostname -> backend mapping +go.universe.tf localhost:1234 + +# DNS wildcards are understoor as well. +*.go.universe.tf 1.2.3.4:8080 + +# DNS wildcards can go anywhere in name. +google.* 10.20.30.40:443 + +# RE2 regexes are also available +/(alpha|beta|gamma)\.mon(itoring)?\.dave\.tf/ 100.200.100.200:443 +``` + +TLSRouter takes 2 commandline arguments: the listen address (":443" by default), and +configuration to use. + +```shell +tlsrouter -listen 1.2.3.4:443 -conf tlsrouter.conf +``` diff --git a/config.go b/config.go index e0a135a..949d426 100644 --- a/config.go +++ b/config.go @@ -73,6 +73,11 @@ func (c *Config) Read(r io.Reader) error { s := bufio.NewScanner(r) for s.Scan() { + if strings.HasPrefix(strings.TrimSpace(s.Text()), "#") { + // Comment, ignore. + continue + } + fs := strings.Fields(s.Text()) switch len(fs) { case 0: -- cgit v1.2.3