fixed proxy cmdline parameters and logs

This commit is contained in:
amit b 2018-12-01 14:59:32 +02:00
parent 33be77dedc
commit 82e1549c4f
3 changed files with 31 additions and 20 deletions

View File

@ -2,7 +2,7 @@
sum="sha1sum"
# VERSION=`date -u +%Y%m%d`
VERSION="v1.02"
VERSION="v1.11"
LDFLAGS="-X main.VERSION=$VERSION -s -w"
GCFLAGS=""

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"os"
"path/filepath"
"github.com/amitbet/vncproxy/logger"
vncproxy "github.com/amitbet/vncproxy/proxy"
@ -39,14 +40,17 @@ func main() {
logger.Warn("proxy will have no password")
}
tcpUrl := ""
tcpURL := ""
if *tcpPort != "" {
tcpUrl = ":" + string(*tcpPort)
tcpURL = ":" + string(*tcpPort)
}
wsURL := ""
if *wsPort != "" {
wsURL = "http://0.0.0.0:" + string(*wsPort) + "/"
}
proxy := &vncproxy.VncProxy{
WsListeningUrl: "http://0.0.0.0:" + string(*wsPort) + "/", // empty = not listening on ws
TcpListeningUrl: tcpUrl,
WsListeningURL: wsURL, // empty = not listening on ws
TCPListeningURL: tcpURL,
ProxyVncPassword: *vncPass, //empty = no auth
SingleSession: &vncproxy.VncSession{
Target: *targetVnc,
@ -61,9 +65,15 @@ func main() {
}
if *recordDir != "" {
logger.Warn("FBS recording is turned on")
proxy.RecordingDir = *recordDir
fullPath, err := filepath.Abs(*recordDir)
if err != nil {
logger.Error("bad recording path: ", err)
}
logger.Info("FBS recording is turned on, writing to dir: ", fullPath)
proxy.RecordingDir = fullPath
proxy.SingleSession.Type = vncproxy.SessionTypeRecordingProxy
} else {
logger.Info("FBS recording is turned off")
}
proxy.StartListening()

View File

@ -5,6 +5,7 @@ import (
"path"
"strconv"
"time"
"github.com/amitbet/vncproxy/client"
"github.com/amitbet/vncproxy/common"
"github.com/amitbet/vncproxy/encodings"
@ -15,8 +16,8 @@ import (
)
type VncProxy struct {
TcpListeningUrl string // empty = not listening on tcp
WsListeningUrl string // empty = not listening on ws
TCPListeningURL string // empty = not listening on tcp
WsListeningURL string // empty = not listening on ws
RecordingDir string // empty = no recording
ProxyVncPassword string //empty = no auth
SingleSession *VncSession // to be used when not using sessions
@ -185,19 +186,19 @@ func (vp *VncProxy) StartListening() {
UseDummySession: !vp.UsingSessions,
}
if vp.TcpListeningUrl != "" && vp.WsListeningUrl != "" {
logger.Infof("running two listeners: tcp port: %s, ws url: %s", vp.TcpListeningUrl, vp.WsListeningUrl)
if vp.TCPListeningURL != "" && vp.WsListeningURL != "" {
logger.Infof("running two listeners: tcp port: %s, ws url: %s", vp.TCPListeningURL, vp.WsListeningURL)
go server.WsServe(vp.WsListeningUrl, cfg)
server.TcpServe(vp.TcpListeningUrl, cfg)
go server.WsServe(vp.WsListeningURL, cfg)
server.TcpServe(vp.TCPListeningURL, cfg)
}
if vp.WsListeningUrl != "" {
logger.Infof("running ws listener url: %s", vp.WsListeningUrl)
server.WsServe(vp.WsListeningUrl, cfg)
if vp.WsListeningURL != "" {
logger.Infof("running ws listener url: %s", vp.WsListeningURL)
server.WsServe(vp.WsListeningURL, cfg)
}
if vp.TcpListeningUrl != "" {
logger.Infof("running tcp listener on port: %s", vp.TcpListeningUrl)
server.TcpServe(":"+vp.TcpListeningUrl, cfg)
if vp.TCPListeningURL != "" {
logger.Infof("running tcp listener on port: %s", vp.TCPListeningURL)
server.TcpServe(vp.TCPListeningURL, cfg)
}
}