|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"flag"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"FRMS/internal/pkg/tui"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TUI interface {
|
|
|
|
Start()
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTUI(ip string, port int, ch chan error) TUI {
|
|
|
|
return tui.NewTUI(ip, port, ch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var port int
|
|
|
|
var err error
|
|
|
|
flag.Usage = func() {
|
|
|
|
w := flag.CommandLine.Output()
|
|
|
|
fmt.Fprintf(w,"Usage: %s port \n", os.Args[0])
|
|
|
|
}
|
|
|
|
iptr := flag.String("i","192.168.100.2","ip address of listener")
|
|
|
|
flag.Parse()
|
|
|
|
if flag.NArg() != 1 {
|
|
|
|
flag.Usage()
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
args := flag.Args()
|
|
|
|
if port, err = strconv.Atoi(args[0]); port < 1024 || port > 65536 {
|
|
|
|
flag.Usage()
|
|
|
|
log.Fatal("Port must be between [1023,65535]")
|
|
|
|
} else if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
ip := *iptr
|
|
|
|
ch := make(chan error)
|
|
|
|
t := NewTUI(ip,port,ch)
|
|
|
|
go t.Start()
|
|
|
|
err = <-ch
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|