summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go44
1 files changed, 41 insertions, 3 deletions
diff --git a/main.go b/main.go
index ae254ca..e87162c 100644
--- a/main.go
+++ b/main.go
@@ -62,7 +62,7 @@ func main() {
continue
}
log.Info("portmap enabled for port", pm.Listen, "to", pm.Connect)
- go gus3000(int(pm.Listen), pm.Connect)
+ go gus3000(pm)
}
startHTTP()
os.Exit(0)
@@ -75,14 +75,47 @@ func main() {
continue
}
log.Info("portmap enabled for port", pm.Listen, "to", pm.Connect)
- go gus3000(int(pm.Listen), pm.Connect)
+ go gus3000(pm)
}
// go NewWatchdog()
go startHTTP()
doGui()
}
-func gus3000(port int, connect string) {
+// func doME(pm *Portmap, gus listener.Accept) {
+func doME(pm *Portmap, gus net.Listener) {
+ localport := int(pm.Listen)
+ where := pm.Connect
+
+ /*
+ // Listen on local port 3000
+ s := fmt.Sprintf("0.0.0.0:%d", port)
+ listener, err := net.Listen("tcp", s)
+ if err != nil {
+ log.Fatalf("Failed to listen on %s: %v", s, err)
+ }
+ defer listener.Close()
+ log.Info("Listening on ", s)
+ */
+
+ // Accept incoming connection
+ clientConn, err := gus.Accept()
+ if err != nil {
+ log.Printf("Failed to accept client connection: %v", err)
+ return
+ }
+ // log.Printf("Client connected: %s", clientConn.RemoteAddr())
+
+ // make a new event from this new connection
+ log.Printf("Connected on port %d from client: %s to where = %s\n", localport, clientConn.RemoteAddr(), where)
+ // Handle the connection in a separate goroutine
+ // go handleConnection(clientConn, connect, port)
+}
+
+func gus3000(pm *Portmap) {
+ port := int(pm.Listen)
+ connect := pm.Connect
+
// Listen on local port 3000
s := fmt.Sprintf("0.0.0.0:%d", port)
listener, err := net.Listen("tcp", s)
@@ -92,6 +125,11 @@ func gus3000(port int, connect string) {
defer listener.Close()
log.Info("Listening on ", s)
+ if pm.UseME {
+ doME(pm, listener)
+ return
+ }
+
for {
// Accept incoming connection
clientConn, err := listener.Accept()