1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-24 16:23:47 +03:00

simplified api

This commit is contained in:
Zack Scholl 2018-06-28 08:09:06 -07:00
parent 7656b102c7
commit e557869afd

View File

@ -3,39 +3,35 @@ package croc
import "time" import "time"
type Croc struct { type Croc struct {
tcpPorts []string TcpPorts []string
serverPort string ServerPort string
timeout time.Duration Timeout time.Duration
useEncryption bool UseEncryption bool
useCompression bool UseCompression bool
curveType string CurveType string
AllowLocalDiscovery bool
} }
// Init will initialize the croc relay // Init will initialize the croc relay
func Init() (c *Croc) { func Init() (c *Croc) {
c = new(Croc) c = new(Croc)
c.tcpPorts = []string{"27001", "27002", "27003", "27004"} c.TcpPorts = []string{"27001", "27002", "27003", "27004"}
c.serverPort = "8003" c.ServerPort = "8003"
c.timeout = 10 * time.Minute c.Timeout = 10 * time.Minute
c.useEncryption = true c.UseEncryption = true
c.useCompression = true c.UseCompression = true
c.curveType = "p521" c.AllowLocalDiscovery = true
c.CurveType = "p521"
return return
} }
// TODO:
// OptionTimeout
// OptionCurve
// OptionUseEncryption
// OptionUseCompression
// Relay initiates a relay // Relay initiates a relay
func (c *Croc) Relay() error { func (c *Croc) Relay() error {
// start relay // start relay
go startRelay(c.tcpPorts) go startRelay(c.TcpPorts)
// start server // start server
return startServer(c.tcpPorts, c.serverPort) return startServer(c.TcpPorts, c.ServerPort)
} }
// Send will take an existing file or folder and send it through the croc relay // Send will take an existing file or folder and send it through the croc relay