-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
59 lines (46 loc) · 1.33 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
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/adrianmoye/ssh-gateway/src/log"
"github.com/adrianmoye/ssh-gateway/src/proxy"
"github.com/adrianmoye/ssh-gateway/src/sshserver"
)
/*
env GOOS=linux GOARCH=amd64 go build sshd.go
*/
var config gwConfig
func main() {
config = setupConfig()
log.Info("Starting Proxy", "server")
config.Listener = proxy.Server(proxy.Config{
OperationMode: config.OperationMode,
SkipHeaders: config.SkipHeaders,
Port: config.Port,
Certs: config.ProxyCert,
})
log.Info("Starting SSH server", "server")
sshserver.Server(sshserver.Config{
Port: config.Port,
ServerConfig: config.SSH,
Listener: *config.Listener,
ProxyCA: config.ProxyCA,
})
// a liveness probe
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
})
//log.Println("registering http handler")
http.Handle("/metrics", promhttp.HandlerFor(
prometheus.DefaultGatherer,
promhttp.HandlerOpts{
// Opt into OpenMetrics to support exemplars.
EnableOpenMetrics: true,
},
))
// lets hang on the metrics server
log.Info("Starting metrics server", "server")
log.Info(fmt.Sprint(http.ListenAndServe(":4141", nil)), "server")
}