mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
add peer discovery
This commit is contained in:
parent
b2885a7d95
commit
1d316e6fbe
1 changed files with 10 additions and 8 deletions
18
src/api.go
18
src/api.go
|
@ -24,21 +24,23 @@ func (c *Croc) Relay() error {
|
||||||
// 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
|
||||||
func (c *Croc) Send(fname string, codephrase string) (err error) {
|
func (c *Croc) Send(fname string, codephrase string) (err error) {
|
||||||
// start relay for listening
|
// start relay for listening
|
||||||
|
runClientError := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
d := c
|
d := Init()
|
||||||
d.ServerPort = "8140"
|
d.ServerPort = "8140"
|
||||||
d.TcpPorts = []string{"27140", "27141"}
|
d.TcpPorts = []string{"27140", "27141"}
|
||||||
go d.startRelay()
|
go d.startRelay()
|
||||||
go d.startServer()
|
go d.startServer()
|
||||||
// e := c
|
e := Init()
|
||||||
// time.Sleep(100 * time.Millisecond)
|
e.WebsocketAddress = "ws://127.0.0.1:8140"
|
||||||
// e.WebsocketAddress = "ws://127.0.0.1:8140"
|
runClientError <- e.client(0, codephrase, fname)
|
||||||
// go e.client(0, codephrase, fname)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// start other client
|
// start main client
|
||||||
c.WebsocketAddress = "ws://127.0.0.1:8140"
|
go func() {
|
||||||
return c.client(0, codephrase, fname)
|
runClientError <- c.client(0, codephrase, fname)
|
||||||
|
}()
|
||||||
|
return <-runClientError
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive will receive something through the croc relay
|
// Receive will receive something through the croc relay
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue