mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
works server<->server
This commit is contained in:
parent
5b5e97277e
commit
3847e5d1ad
9 changed files with 831 additions and 9 deletions
33
main.go
33
main.go
|
@ -3,16 +3,47 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/schollz/croc/v7/src/croc"
|
||||
"github.com/schollz/croc/v7/src/relay"
|
||||
log "github.com/schollz/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var startRelay bool
|
||||
var startRelay, startSend, startReceive bool
|
||||
flag.BoolVar(&startRelay, "relay", false, "start relay")
|
||||
flag.BoolVar(&startSend, "send", false, "send")
|
||||
flag.BoolVar(&startReceive, "receive", false, "receive")
|
||||
flag.Parse()
|
||||
log.SetLevel("debug")
|
||||
if startRelay {
|
||||
relay.Run()
|
||||
} else if startSend {
|
||||
c, err := croc.New(croc.Options{
|
||||
IsSender: true,
|
||||
SharedSecret: "pass",
|
||||
RelayAddress: "ws://localhost:8005/ws",
|
||||
Debug: true,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = c.Send(croc.TransferOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else if startReceive {
|
||||
c, err := croc.New(croc.Options{
|
||||
IsSender: false,
|
||||
SharedSecret: "pass",
|
||||
RelayAddress: "ws://localhost:8005/ws",
|
||||
Debug: true,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = c.Receive()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue