mirror of https://github.com/schollz/croc.git
add config default
This commit is contained in:
parent
0d17219c87
commit
1ae117166a
1
go.mod
1
go.mod
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
Loading…
Reference in New Issue