feat: add http server with a page serving service informations
This commit is contained in:
@ -7,37 +7,48 @@ import (
|
||||
"os/signal"
|
||||
|
||||
"forge.cadoles.com/wpetit/rebound"
|
||||
"github.com/caarlos0/env/v6"
|
||||
"forge.cadoles.com/wpetit/rebound/http"
|
||||
"forge.cadoles.com/wpetit/rebound/ssh"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func main() {
|
||||
opts := rebound.DefaultOptions()
|
||||
if err := env.Parse(opts); err != nil {
|
||||
|
||||
if err := opts.ParseEnv(); err != nil {
|
||||
log.Fatalf("[ERROR] %+v", errors.WithStack(err))
|
||||
}
|
||||
|
||||
// Global Options
|
||||
address := flag.String("address", opts.Address, "server listening address")
|
||||
sockDir := flag.String("sock-dir", opts.SockDir, "sock directory")
|
||||
publicPort := flag.Uint("public-port", opts.PublicPort, "public port")
|
||||
publicHost := flag.String("public-host", opts.PublicHost, "public host")
|
||||
hostKey := flag.String("host-key", opts.HostKey, "host key")
|
||||
|
||||
// SSH Options
|
||||
sockDir := flag.String("ssh-sock-dir", opts.SSH.SockDir, "ssh sock directory")
|
||||
publicPort := flag.Uint("ssh-public-port", opts.SSH.PublicPort, "ssh public port")
|
||||
publicHost := flag.String("ssh-public-host", opts.SSH.PublicHost, "ssh public host")
|
||||
hostKey := flag.String("ssh-host-key", opts.SSH.HostKey, "ssh host key")
|
||||
|
||||
// HTTP Options
|
||||
customDir := flag.String("http-custom-dir", opts.HTTP.CustomDir, "http custom templates/assets directory")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
server := rebound.NewServer(
|
||||
rebound.WithAddress(*address),
|
||||
rebound.WithSockDir(*sockDir),
|
||||
rebound.WithPublicPort(*publicPort),
|
||||
rebound.WithPublicHost(*publicHost),
|
||||
rebound.WithHostKey(*hostKey),
|
||||
rebound.WithSSHOption(
|
||||
ssh.WithSockDir(*sockDir),
|
||||
ssh.WithPublicHost(*publicHost),
|
||||
ssh.WithPublicPort(*publicPort),
|
||||
ssh.WithHostKey(*hostKey),
|
||||
),
|
||||
rebound.WitHTTPOption(
|
||||
http.WithCustomDir(*customDir),
|
||||
),
|
||||
)
|
||||
|
||||
go func() {
|
||||
if err := server.Run(); err != nil {
|
||||
log.Fatalf("[FATAL] %+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
if err := server.Start(); err != nil {
|
||||
log.Fatalf("[FATAL] %+v", errors.WithStack(err))
|
||||
}
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
|
Reference in New Issue
Block a user