From 837a66e9756c7ff92af7feca3726de3b464591a6 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sat, 30 Jun 2018 06:43:38 -0700 Subject: [PATCH] fix options --- src/cleanup.go | 6 ++++++ src/client.go | 3 ++- src/files.go | 1 + src/models.go | 12 ++++++++---- 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 src/cleanup.go diff --git a/src/cleanup.go b/src/cleanup.go new file mode 100644 index 00000000..6dae1342 --- /dev/null +++ b/src/cleanup.go @@ -0,0 +1,6 @@ +package croc + +func (c *Croc) cleanup() { + // TODO + // erase all the croc files and their possible numbers +} diff --git a/src/client.go b/src/client.go index 69724ca6..f82b98c9 100644 --- a/src/client.go +++ b/src/client.go @@ -58,7 +58,8 @@ func (c *Croc) client(role int, codePhrase string, fname ...string) (err error) // connect to the websocket // TODO: // use predefined host and HTTPS, if exists - u := url.URL{Scheme: "ws", Host: "localhost:8003", Path: "/"} + + u := url.URL{Scheme: strings.Split(c.WebsocketAddress, "://")[0], Host: strings.Split(c.WebsocketAddress, "://")[1], Path: "/"} log.Debugf("connecting to %s", u.String()) ws, _, err := websocket.DefaultDialer.Dial(u.String(), nil) if err != nil { diff --git a/src/files.go b/src/files.go index 0be0b074..80a3c827 100644 --- a/src/files.go +++ b/src/files.go @@ -216,6 +216,7 @@ func (c *Croc) processReceivedFile() (err error) { log.Error(err) return } + os.Remove(c.crocFile) c.cs.channel.finishedHappy = true return } diff --git a/src/models.go b/src/models.go index 279a9fcd..1141cd6f 100644 --- a/src/models.go +++ b/src/models.go @@ -16,9 +16,13 @@ const ( ) type Croc struct { - TcpPorts []string - ServerPort string - Timeout time.Duration + // Options for connecting to server + TcpPorts []string + WebsocketAddress string + ServerPort string + Timeout time.Duration + + // Options for file transfering UseEncryption bool UseCompression bool CurveType string @@ -41,12 +45,12 @@ type Croc struct { func Init() (c *Croc) { c = new(Croc) c.TcpPorts = []string{"27001", "27002", "27003", "27004"} - c.ServerPort = "8003" c.Timeout = 10 * time.Minute c.UseEncryption = true c.UseCompression = true c.AllowLocalDiscovery = true c.CurveType = "p521" + c.WebsocketAddress = "ws://localhost:8003" c.rs.Lock() c.rs.channel = make(map[string]*channelData) c.cs.channel = new(channelData)