mirror of https://github.com/elisescu/tty-share
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
7 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"flag"
|
||
|
"os"
|
||
|
"os/signal"
|
||
|
|
||
|
logrus "github.com/sirupsen/logrus"
|
||
|
)
|
||
|
|
||
|
// MainLogger is the logger that will be used across the whole main package. I whish I knew of a better way
|
||
|
var MainLogger = logrus.New()
|
||
|
|
||
|
func main() {
|
||
|
webAddress := flag.String("web_address", ":80", "The bind address for the web interface")
|
||
|
senderAddress := flag.String("sender_address", ":6543", "The bind address for the tty_sender connections")
|
||
|
url := flag.String("url", "http://localhost", "The public web URL the server will be accessible at")
|
||
|
flag.Parse()
|
||
|
|
||
|
log := MainLogger
|
||
|
log.SetLevel(logrus.DebugLevel)
|
||
|
|
||
|
config := TTYProxyServerConfig{
|
||
|
WebAddress: *webAddress,
|
||
|
TTYSenderAddress: *senderAddress,
|
||
|
ServerURL: *url,
|
||
|
}
|
||
|
|
||
|
server := NewTTYProxyServer(config)
|
||
|
|
||
|
// Install a signal and wait until we get Ctrl-C
|
||
|
c := make(chan os.Signal, 1)
|
||
|
signal.Notify(c, os.Interrupt)
|
||
|
|
||
|
go func() {
|
||
|
s := <-c
|
||
|
log.Debug("Received signal <", s, ">. Stopping the server")
|
||
|
server.Stop()
|
||
|
}()
|
||
|
|
||
|
log.Info("Listening on address: http://", config.WebAddress, ", and TCP://", config.TTYSenderAddress)
|
||
|
err := server.Listen()
|
||
|
|
||
|
log.Debug("Exiting. Error: ", err)
|
||
|
}
|