-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmain.go
38 lines (32 loc) · 842 Bytes
/
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
package main
import (
"github.com/sirupsen/logrus"
"github.com/Gurpartap/logrus-stack"
"github.com/tsurubee/sshr/sshr"
"errors"
)
func init() {
logrus.SetLevel(logrus.DebugLevel)
stackLevels := []logrus.Level{logrus.PanicLevel, logrus.FatalLevel}
logrus.AddHook(logrus_stack.NewHook(stackLevels, stackLevels))
}
func main() {
confFile := "./example.toml"
sshServer, err := sshr.NewSSHServer(confFile)
if err != nil {
logrus.Fatal(err)
}
sshServer.ProxyConfig.FindUpstreamHook = FindUpstreamByUsername
if err := sshServer.Run(); err != nil {
logrus.Fatal(err)
}
}
func FindUpstreamByUsername(username string) (string, error) {
if username == "tsurubee" {
return "host-tsurubee", nil
} else if username == "hoge" {
return "host-hoge", nil
} else {
return "", errors.New(username + "'s host is not found!")
}
}