2018-09-22 05:17:57 +02:00
|
|
|
package croc
|
|
|
|
|
2018-09-22 05:51:43 +02:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/schollz/croc/src/logger"
|
|
|
|
"github.com/schollz/croc/src/recipient"
|
|
|
|
"github.com/schollz/croc/src/relay"
|
|
|
|
"github.com/schollz/croc/src/sender"
|
2018-09-22 06:50:20 +02:00
|
|
|
"github.com/schollz/croc/src/zipper"
|
2018-09-22 05:51:43 +02:00
|
|
|
)
|
2018-09-22 05:17:57 +02:00
|
|
|
|
|
|
|
// Croc options
|
|
|
|
type Croc struct {
|
|
|
|
// Options for all
|
|
|
|
Debug bool
|
2018-09-22 07:31:13 +02:00
|
|
|
// ShowText will display text on the stderr
|
|
|
|
ShowText bool
|
2018-09-22 05:17:57 +02:00
|
|
|
|
|
|
|
// Options for relay
|
2018-09-23 21:34:29 +02:00
|
|
|
RelayWebsocketPort string
|
|
|
|
RelayTCPPort string
|
|
|
|
CurveType string
|
2018-09-22 05:17:57 +02:00
|
|
|
|
|
|
|
// Options for connecting to server
|
2018-09-23 21:34:29 +02:00
|
|
|
Address string
|
|
|
|
AddressTCPPort string
|
|
|
|
AddressWebsocketPort string
|
|
|
|
Timeout time.Duration
|
|
|
|
LocalOnly bool
|
|
|
|
NoLocal bool
|
2018-09-22 05:17:57 +02:00
|
|
|
|
|
|
|
// Options for file transfering
|
|
|
|
UseEncryption bool
|
|
|
|
UseCompression bool
|
|
|
|
AllowLocalDiscovery bool
|
2018-09-22 15:32:44 +02:00
|
|
|
NoRecipientPrompt bool
|
2018-09-22 05:17:57 +02:00
|
|
|
Stdout bool
|
2018-09-24 16:17:35 +02:00
|
|
|
ForceSend int // 0: ignore, 1: websockets, 2: TCP
|
2018-09-22 05:17:57 +02:00
|
|
|
|
2018-09-22 05:51:43 +02:00
|
|
|
// Parameters for file transfer
|
|
|
|
Filename string
|
|
|
|
Codephrase string
|
|
|
|
|
2018-09-22 05:17:57 +02:00
|
|
|
// localIP address
|
|
|
|
localIP string
|
|
|
|
// is using local relay
|
|
|
|
isLocal bool
|
|
|
|
normalFinish bool
|
|
|
|
}
|
2018-09-22 05:51:43 +02:00
|
|
|
|
|
|
|
// Init will initiate with the default parameters
|
|
|
|
func Init(debug bool) (c *Croc) {
|
|
|
|
c = new(Croc)
|
|
|
|
c.UseCompression = true
|
|
|
|
c.UseEncryption = true
|
|
|
|
c.AllowLocalDiscovery = true
|
2018-09-24 16:00:48 +02:00
|
|
|
c.RelayWebsocketPort = "8153"
|
|
|
|
c.RelayTCPPort = "8154"
|
|
|
|
c.CurveType = "siec"
|
|
|
|
c.Address = "198.199.67.130"
|
2018-09-24 17:35:24 +02:00
|
|
|
c.AddressWebsocketPort = "8153"
|
|
|
|
c.AddressTCPPort = "8154"
|
2018-09-24 16:00:48 +02:00
|
|
|
c.NoRecipientPrompt = true
|
2018-09-22 05:51:43 +02:00
|
|
|
debugLevel := "info"
|
|
|
|
if debug {
|
|
|
|
debugLevel = "debug"
|
|
|
|
c.Debug = true
|
|
|
|
}
|
|
|
|
logger.SetLogLevel(debugLevel)
|
|
|
|
sender.DebugLevel = debugLevel
|
|
|
|
recipient.DebugLevel = debugLevel
|
|
|
|
relay.DebugLevel = debugLevel
|
2018-09-22 06:50:20 +02:00
|
|
|
zipper.DebugLevel = debugLevel
|
2018-09-22 05:51:43 +02:00
|
|
|
return
|
|
|
|
}
|