add config default

This commit is contained in:
Zack Scholl 2018-10-21 07:54:59 -07:00
parent 0d17219c87
commit 1ae117166a
2 changed files with 60 additions and 0 deletions

1
go.mod
View File

@ -1,6 +1,7 @@
module github.com/schollz/croc
require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.7.0 // indirect

59
src/croc/config.go Normal file
View File

@ -0,0 +1,59 @@
package croc
import (
"bytes"
"time"
"github.com/BurntSushi/toml"
)
type Config struct {
// Relay parameters
RelayWebsocketPort string
RelayTCPPorts []string
// Sender parameters
CurveType string
// Options for connecting to server
PublicServerIP string
AddressTCPPorts []string
AddressWebsocketPort string
Timeout time.Duration
LocalOnly bool
NoLocal bool
// Options for file transfering
UseEncryption bool
UseCompression bool
AllowLocalDiscovery bool
NoRecipientPrompt bool
ForceTCP bool
ForceWebsockets bool
Codephrase string
}
// DefaultConfig returns the default config
func DefaultConfig() string {
c := Config{}
cr := Init(false)
c.RelayWebsocketPort = cr.RelayWebsocketPort
c.RelayTCPPorts = cr.RelayTCPPorts
c.CurveType = cr.CurveType
c.PublicServerIP = cr.Address
c.AddressTCPPorts = cr.AddressTCPPorts
c.AddressWebsocketPort = cr.AddressWebsocketPort
c.Timeout = cr.Timeout
c.LocalOnly = cr.LocalOnly
c.NoLocal = cr.NoLocal
c.UseEncryption = cr.UseEncryption
c.UseCompression = cr.UseCompression
c.AllowLocalDiscovery = cr.AllowLocalDiscovery
c.NoRecipientPrompt = cr.NoRecipientPrompt
c.ForceTCP = false
c.ForceWebsockets = false
c.Codephrase = ""
buf := new(bytes.Buffer)
toml.NewEncoder(buf).Encode(c)
return buf.String()
}