-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
48 lines (35 loc) · 1.23 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"log"
//"net/http"
//"net/http/httputil"
"os"
//"github.com/caddyserver/certmagic"
)
var (
verbose = flag.Bool("verbose", true, "verbose logging")
bind = flag.String("bind", ":443", "address to listen on")
email = flag.String("email", "[email protected]", "email address for LetsEncrypt")
hostname = flag.String("hostname", "localhost", "hostname for default server")
bindHttp = flag.String("http", "none", "bind address for handling plain http (or \"none\")")
staging = flag.Bool("staging", false, "use LetsEncrypt staging server")
target = flag.String("target", "localhost", "target (=proxied server hostname)")
logger = log.New(os.Stdout, "R2PROXY: ", log.Ldate|log.Ltime|log.Lmicroseconds|log.LUTC)
)
func main() {
flag.Parse()
if *verbose {
logger.Printf("xINFO: https listening on %s\n", *bind)
logger.Printf("INFO: local hostname is %s\n", *hostname)
logger.Printf("INFO: proxy target is %s\n", *target)
logger.Printf("INFO: http handling is %s\n", *bindHttp)
}
var done = make(chan bool)
mux := getAssetMux(*hostname)
mux.Handle("/", getProxyHandler(*target))
go serveHttps(*bind, mux)
go serveHttp(*bindHttp, mux)
<-done
logger.Printf("INFO: done")
}