mirror of https://github.com/schollz/croc.git
specify relay ports
This commit is contained in:
parent
ae7ceca3b7
commit
1223b3e51d
5
main.go
5
main.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
croc "github.com/schollz/croc/src"
|
croc "github.com/schollz/croc/src"
|
||||||
|
@ -57,6 +58,7 @@ func main() {
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{Name: "tcp", Value: "27130,27131,27132,27133", Usage: "ports for the tcp connections"},
|
cli.StringFlag{Name: "tcp", Value: "27130,27131,27132,27133", Usage: "ports for the tcp connections"},
|
||||||
cli.StringFlag{Name: "port", Value: "8130", Usage: "port that the websocket listens on"},
|
cli.StringFlag{Name: "port", Value: "8130", Usage: "port that the websocket listens on"},
|
||||||
|
cli.StringFlag{Name: "curve", Value: "siec", Usage: "specify elliptic curve to use (p224, p256, p384, p521, siec)"},
|
||||||
},
|
},
|
||||||
HelpName: "croc relay",
|
HelpName: "croc relay",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
@ -112,6 +114,9 @@ func receive(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func relay(c *cli.Context) error {
|
func relay(c *cli.Context) error {
|
||||||
|
cr.TcpPorts = strings.Split(c.GlobalString("tcp"), ",")
|
||||||
|
cr.ServerPort = c.GlobalString("port")
|
||||||
|
cr.CurveType = c.GlobalString("curve")
|
||||||
fmt.Println("relay")
|
fmt.Println("relay")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,8 @@ type channelData struct {
|
||||||
// passPhrase is used to generate a session key
|
// passPhrase is used to generate a session key
|
||||||
passPhrase string
|
passPhrase string
|
||||||
// sessionKey
|
// sessionKey
|
||||||
sessionKey []byte
|
sessionKey []byte
|
||||||
|
// isReady specifies whether the current client
|
||||||
isReady bool
|
isReady bool
|
||||||
fileReady bool
|
fileReady bool
|
||||||
fileMetaData FileMetaData
|
fileMetaData FileMetaData
|
||||||
|
|
|
@ -1,12 +1,61 @@
|
||||||
package pake
|
package pake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/elliptic"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/tscholl2/siec"
|
"github.com/tscholl2/siec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func BenchmarkPakeSIEC255(b *testing.B) {
|
||||||
|
curve := siec.SIEC255()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
// initialize A
|
||||||
|
A, _ := Init([]byte{1, 2, 3}, 0, curve)
|
||||||
|
// initialize B
|
||||||
|
B, _ := Init([]byte{1, 2, 3}, 1, curve)
|
||||||
|
// send A's stuff to B
|
||||||
|
B.Update(A.Bytes())
|
||||||
|
// send B's stuff to A
|
||||||
|
A.Update(B.Bytes())
|
||||||
|
// send A's stuff back to B
|
||||||
|
B.Update(A.Bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkPakeP521(b *testing.B) {
|
||||||
|
curve := elliptic.P521()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
// initialize A
|
||||||
|
A, _ := Init([]byte{1, 2, 3}, 0, curve)
|
||||||
|
// initialize B
|
||||||
|
B, _ := Init([]byte{1, 2, 3}, 1, curve)
|
||||||
|
// send A's stuff to B
|
||||||
|
B.Update(A.Bytes())
|
||||||
|
// send B's stuff to A
|
||||||
|
A.Update(B.Bytes())
|
||||||
|
// send A's stuff back to B
|
||||||
|
B.Update(A.Bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkPakeP224(b *testing.B) {
|
||||||
|
curve := elliptic.P224()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
// initialize A
|
||||||
|
A, _ := Init([]byte{1, 2, 3}, 0, curve)
|
||||||
|
// initialize B
|
||||||
|
B, _ := Init([]byte{1, 2, 3}, 1, curve)
|
||||||
|
// send A's stuff to B
|
||||||
|
B.Update(A.Bytes())
|
||||||
|
// send B's stuff to A
|
||||||
|
A.Update(B.Bytes())
|
||||||
|
// send A's stuff back to B
|
||||||
|
B.Update(A.Bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPake(t *testing.T) {
|
func TestPake(t *testing.T) {
|
||||||
curve := siec.SIEC255()
|
curve := siec.SIEC255()
|
||||||
// successful (both have same k)
|
// successful (both have same k)
|
||||||
|
|
Loading…
Reference in New Issue