Skip to content

Commit

Permalink
Add sid option to cmdline
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Aug 20, 2016
1 parent c7d8f05 commit e33e8ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 9 additions & 3 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ import (
"math/rand"
"net"
"os"
"syscall"
"syscall"
"time"

"golang.org/x/crypto/pbkdf2"

"github.com/golang/snappy"
"github.com/hashicorp/yamux"
"github.com/urfave/cli"
kcp "github.com/madeye/kcp-go"
"github.com/urfave/cli"
)

var (
Expand Down Expand Up @@ -222,6 +222,10 @@ func main() {
Name: "nocomp",
Usage: "disable compression",
},
cli.BoolFlag{
Name: "sid",
Usage: "enable session id",
},
cli.IntFlag{
Name: "nodelay",
Value: 0,
Expand Down Expand Up @@ -303,13 +307,15 @@ func main() {
mtu, sndwnd, rcvwnd := c.Int("mtu"), c.Int("sndwnd"), c.Int("rcvwnd")
nocomp, acknodelay := c.Bool("nocomp"), c.Bool("acknodelay")
dscp, sockbuf, keepalive, conn := c.Int("dscp"), c.Int("sockbuf"), c.Int("keepalive"), c.Int("conn")
hasSid := c.Bool("sid")

log.Println("listening on:", listener.Addr())
log.Println("encryption:", crypt)
log.Println("nodelay parameters:", nodelay, interval, resend, nc)
log.Println("remote address:", remoteaddr)
log.Println("sndwnd:", sndwnd, "rcvwnd:", rcvwnd)
log.Println("compression:", !nocomp)
log.Println("session id:", hasSid)
log.Println("mtu:", mtu)
log.Println("datashard:", datashard, "parityshard:", parityshard)
log.Println("acknodelay:", acknodelay)
Expand Down Expand Up @@ -356,7 +362,7 @@ func main() {
LogOutput: os.Stderr,
}
createConn := func() *yamux.Session {
kcpconn, err := kcp.DialWithOptions(remoteaddr, true, block, datashard, parityshard)
kcpconn, err := kcp.DialWithOptions(remoteaddr, hasSid, block, datashard, parityshard)
checkError(err)
kcpconn.SetStreamMode(true)
kcpconn.SetNoDelay(nodelay, interval, resend, nc)
Expand Down
11 changes: 9 additions & 2 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/golang/snappy"
"github.com/hashicorp/yamux"
"github.com/urfave/cli"
kcp "github.com/madeye/kcp-go"
"github.com/urfave/cli"
)

var (
Expand Down Expand Up @@ -179,6 +179,10 @@ func main() {
Name: "nocomp",
Usage: "disable compression",
},
cli.BoolFlag{
Name: "sid",
Usage: "enable session id",
},
cli.IntFlag{
Name: "nodelay",
Value: 0,
Expand Down Expand Up @@ -248,8 +252,10 @@ func main() {
block, _ = kcp.NewAESBlockCrypt(pass)
}

hasSid := c.Bool("sid")

datashard, parityshard := c.Int("datashard"), c.Int("parityshard")
lis, err := kcp.ListenWithOptions(c.String("listen"), true, block, datashard, parityshard)
lis, err := kcp.ListenWithOptions(c.String("listen"), hasSid, block, datashard, parityshard)
if err != nil {
log.Fatal(err)
}
Expand All @@ -264,6 +270,7 @@ func main() {
log.Println("nodelay parameters:", nodelay, interval, resend, nc)
log.Println("sndwnd:", sndwnd, "rcvwnd:", rcvwnd)
log.Println("compression:", !nocomp)
log.Println("session id:", hasSid)
log.Println("mtu:", mtu)
log.Println("datashard:", datashard, "parityshard:", parityshard)
log.Println("acknodelay:", acknodelay)
Expand Down

0 comments on commit e33e8ba

Please sign in to comment.