agent now giving the exact commands to run to use it from the client

side.
This commit is contained in:
Erik Brakkee 2024-07-21 23:02:54 +02:00
parent 7e6b4d9272
commit cd1eb7338d

View File

@ -10,8 +10,10 @@ import (
"io"
"log"
"net"
"net/url"
"os"
"os/exec"
"strings"
"syscall"
"time"
"unsafe"
@ -194,5 +196,25 @@ func main() {
})
//service = ConnectionServer(netCatServer)
//service = ConnectionServer(echoServer)
log.Println()
log.Printf("Clients should use the following commands to connect to this agent:")
log.Println()
clientUrl := strings.ReplaceAll(wsURL, "/agent/", "/client/")
sshCommand := fmt.Sprintf("ssh -oServerAliveInterval=10 -oProxyCommand=\"wsproxy %s\" abc@localhost",
clientUrl)
sftpCommand := fmt.Sprintf("sftp -oServerAliveInterval=10 -oProxyCommand=\"wsproxy %s\" abc@localhost",
clientUrl)
log.Println(" # For SSH")
log.Println(" " + sshCommand)
log.Println()
log.Println(" # for SFTP")
log.Println(" " + sftpCommand)
log.Println()
urlObject, _ := url.Parse(wsURL)
log.Printf("wsproxy can be downloaded from %s",
strings.ReplaceAll(urlObject.Scheme, "ws", "http")+
"://"+urlObject.Host+"/docs/wsproxy")
log.Println()
service.Run(listener)
}