2023-09-09 04:00:00 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
|
|
|
|
"forge.cadoles.com/wpetit/rebound"
|
2023-09-21 05:54:08 +02:00
|
|
|
"forge.cadoles.com/wpetit/rebound/http"
|
|
|
|
"forge.cadoles.com/wpetit/rebound/ssh"
|
2023-09-09 04:00:00 +02:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
opts := rebound.DefaultOptions()
|
2023-09-21 05:54:08 +02:00
|
|
|
|
|
|
|
if err := opts.ParseEnv(); err != nil {
|
2023-09-09 04:00:00 +02:00
|
|
|
log.Fatalf("[ERROR] %+v", errors.WithStack(err))
|
|
|
|
}
|
|
|
|
|
|
|
|
server := rebound.NewServer(
|
2023-09-24 17:33:20 +02:00
|
|
|
rebound.WithAddress(opts.Address),
|
2023-09-21 05:54:08 +02:00
|
|
|
rebound.WithSSHOption(
|
2023-09-24 17:33:20 +02:00
|
|
|
ssh.WithSockDir(opts.SSH.SockDir),
|
|
|
|
ssh.WithPublicHost(opts.SSH.PublicHost),
|
|
|
|
ssh.WithPublicPort(opts.SSH.PublicPort),
|
|
|
|
ssh.WithHostKey(opts.SSH.HostKey),
|
2023-09-21 05:54:08 +02:00
|
|
|
),
|
|
|
|
rebound.WitHTTPOption(
|
2023-09-24 17:33:20 +02:00
|
|
|
http.WithCustomDir(opts.HTTP.CustomDir),
|
|
|
|
http.WithTemplateData(opts.HTTP.TemplateData),
|
2023-09-21 05:54:08 +02:00
|
|
|
),
|
2023-09-09 04:00:00 +02:00
|
|
|
)
|
|
|
|
|
2023-09-21 05:54:08 +02:00
|
|
|
if err := server.Start(); err != nil {
|
|
|
|
log.Fatalf("[FATAL] %+v", errors.WithStack(err))
|
|
|
|
}
|
2023-09-09 04:00:00 +02:00
|
|
|
|
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(c, os.Interrupt)
|
|
|
|
|
|
|
|
<-c
|
|
|
|
|
|
|
|
if err := server.Stop(); err != nil {
|
|
|
|
log.Fatalf("[FATAL] %+v", errors.WithStack(err))
|
|
|
|
}
|
|
|
|
}
|