summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Anderson <[email protected]>2017-01-01 14:19:09 -0800
committerDavid Anderson <[email protected]>2017-01-01 14:19:09 -0800
commite34c2a61afa52bf8cc245c1ff75cca10b231050e (patch)
treec657a9f5317a8ed6866f9022104b79cfa1f0e7d7
parentb321571464ebd231043ead1e15f23dba1c02970c (diff)
Add more words to README.
-rw-r--r--README.md42
-rw-r--r--config.go5
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: