Proof-of-Concept for proxy TLS support
The code is quite messy, but particularly the argument parsing and volume-mounting. Also, it doesn't support args with spaces, or non-absolute file-paths.
This commit is contained in:
1 parent
4774043295
commit
74afbc5505
9 files changed
+265
-20
No files matched your search
+37
-11
@@ -16,13 +16,29 @@ var (
|
||||
)
|
||||
|
||||
func main() {
|
||||
var target, listen string
|
||||
var withDNS, withIPAM, debug, justVersion bool
|
||||
var (
|
||||
debug bool
|
||||
justVersion bool
|
||||
listen string
|
||||
target string
|
||||
tlsCACert string
|
||||
tlsCert string
|
||||
tlsEnabled bool
|
||||
tlsKey string
|
||||
tlsVerify bool
|
||||
withDNS bool
|
||||
withIPAM bool
|
||||
)
|
||||
|
||||
getopt.BoolVarLong(&debug, "debug", 'd', "log debugging information")
|
||||
getopt.BoolVarLong(&justVersion, "version", 0, "print version and exit")
|
||||
getopt.StringVar(&target, 'H', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultTarget))
|
||||
getopt.StringVar(&listen, 'L', fmt.Sprintf("address on which to listen (default %s)", defaultListen))
|
||||
getopt.StringVar(&target, 'H', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultTarget))
|
||||
getopt.StringVarLong(&tlsCACert, "tlscacert", 0, "Trust certs signed only by this CA")
|
||||
getopt.StringVarLong(&tlsCert, "tlscert", 0, "Path to TLS certificate file")
|
||||
getopt.BoolVarLong(&tlsEnabled, "tls", 0, "Use TLS; implied by --tlsverify")
|
||||
getopt.StringVarLong(&tlsKey, "tlskey", 0, "Path to TLS key file")
|
||||
getopt.BoolVarLong(&tlsVerify, "tlsverify", 0, "Use TLS and verify the remote")
|
||||
getopt.BoolVarLong(&withDNS, "with-dns", 'w', "instruct created containers to use weaveDNS as their nameserver")
|
||||
getopt.BoolVarLong(&withIPAM, "with-ipam", 'i', "automatically allocate addresses for containers without a WEAVE_CIDR")
|
||||
getopt.Parse()
|
||||
@@ -32,6 +48,10 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if debug {
|
||||
InitDefaultLogging(true)
|
||||
}
|
||||
|
||||
if target == "" {
|
||||
target = defaultTarget
|
||||
}
|
||||
@@ -40,18 +60,24 @@ func main() {
|
||||
listen = defaultListen
|
||||
}
|
||||
|
||||
if debug {
|
||||
InitDefaultLogging(true)
|
||||
}
|
||||
|
||||
p, err := proxy.NewProxy(version, target, listen, withDNS, withIPAM)
|
||||
p, err := proxy.NewProxy(
|
||||
version,
|
||||
target,
|
||||
listen,
|
||||
withDNS,
|
||||
withIPAM,
|
||||
&proxy.TLSConfig{
|
||||
Enabled: tlsEnabled,
|
||||
Verify: tlsVerify,
|
||||
Cert: tlsCert,
|
||||
Key: tlsKey,
|
||||
CACert: tlsCACert,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
Error.Fatalf("Could not start proxy: %s", err)
|
||||
}
|
||||
|
||||
Info.Printf("Listening on %s", listen)
|
||||
Info.Printf("Proxying %s", target)
|
||||
|
||||
if err := p.ListenAndServe(); err != nil {
|
||||
Error.Fatalf("Could not listen on %s: %s", listen, err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user