preliminary /me check

This commit is contained in:
Jeff Carr 2025-03-11 07:38:59 -05:00
parent c325f87217
commit 92f8b42706
1 changed files with 41 additions and 3 deletions

44
main.go
View File

@ -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,19 @@ 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)
@ -91,6 +96,39 @@ func gus3000(port int, connect string) {
}
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)
if err != nil {
log.Fatalf("Failed to listen on %s: %v", s, err)
}
defer listener.Close()
log.Info("Listening on ", s)
if pm.UseME {
doME(pm, listener)
return
}
for {
// Accept incoming connection