agent is now setting up ws connection to server.
Next: adding multiplexing and listening on a socket.
This commit is contained in:
		
							parent
							
								
									f3cbd9012a
								
							
						
					
					
						commit
						6c8e0adccf
					
				| @ -1,7 +1,9 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"cidebug/pkg/iowrappers" | ||||
| 	"fmt" | ||||
| 	"github.com/gorilla/websocket" | ||||
| 	"io" | ||||
| 	"log" | ||||
| 	"net" | ||||
| @ -27,7 +29,7 @@ func SftpHandler(sess ssh.Session) { | ||||
| 	if err != nil { | ||||
| 		log.Printf("sftp tcpserver init error: %s\n", err) | ||||
| 		return | ||||
| 	}F | ||||
| 	} | ||||
| 	if err := server.Serve(); err == io.EOF { | ||||
| 		server.Close() | ||||
| 		fmt.Println("sftp client exited session.") | ||||
| @ -46,7 +48,7 @@ func setWinsize(f *os.File, w, h int) { | ||||
| 		uintptr(unsafe.Pointer(&struct{ h, w, x, y uint16 }{uint16(h), uint16(w), 0, 0}))) | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| func mainSsh() { | ||||
| 	ssh.Handle(func(s ssh.Session) { | ||||
| 		cmd := exec.Command("bash") | ||||
| 		ptyReq, winCh, isPty := s.Pty() | ||||
| @ -100,3 +102,18 @@ func main() { | ||||
| 
 | ||||
| 	//log.Fatal(server.ListenAndServe())
 | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	wsURL := os.Args[1] | ||||
| 	conn, _, err := websocket.DefaultDialer.Dial(wsURL, nil) | ||||
| 	if err != nil { | ||||
| 		log.Println("WebSocket connection error:", err) | ||||
| 		return | ||||
| 	} | ||||
| 	wsConn := iowrappers.NewWebSocketConn(conn) | ||||
| 	defer wsConn.Close() | ||||
| 
 | ||||
| 	// echo server
 | ||||
| 	iowrappers.SynchronizeStreams(wsConn, wsConn) | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -219,7 +219,7 @@ func main() { | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	http.HandleFunc("/register/", registrationService.handle) | ||||
| 	http.HandleFunc("/agent/", registrationService.handle) | ||||
| 	http.HandleFunc("/client/", clientService.handle) | ||||
| 
 | ||||
| 	// Start HTTP server
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user