Check protocol version and auth token (hard coded for now)
This commit is contained in:
parent
f98609d48d
commit
e36d5573ff
12
client.go
12
client.go
@ -48,8 +48,8 @@ func (c *Client) Connect() error {
|
|||||||
msg := secure.PacketStart{
|
msg := secure.PacketStart{
|
||||||
OperationType: secure.OperationTypeList,
|
OperationType: secure.OperationTypeList,
|
||||||
ClientName: "Justin Hawkins",
|
ClientName: "Justin Hawkins",
|
||||||
ProtocolVersion: "v1.0",
|
ProtocolVersion: "1.0",
|
||||||
AuthToken: "abc123",
|
AuthToken: "dummy",
|
||||||
}
|
}
|
||||||
err := enc.Encode(msg)
|
err := enc.Encode(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -76,8 +76,8 @@ func (c *Client) Connect() error {
|
|||||||
msg := secure.PacketStart{
|
msg := secure.PacketStart{
|
||||||
OperationType: secure.OperationTypeReceive,
|
OperationType: secure.OperationTypeReceive,
|
||||||
ClientName: "Justin Hawkins",
|
ClientName: "Justin Hawkins",
|
||||||
ProtocolVersion: "v1.0",
|
ProtocolVersion: "1.0",
|
||||||
AuthToken: "abc123",
|
AuthToken: "dummy",
|
||||||
}
|
}
|
||||||
err := enc.Encode(msg)
|
err := enc.Encode(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -124,8 +124,8 @@ func (c *Client) Connect() error {
|
|||||||
msg := secure.PacketStart{
|
msg := secure.PacketStart{
|
||||||
OperationType: secure.OperationTypeSend,
|
OperationType: secure.OperationTypeSend,
|
||||||
ClientName: "Justin Hawkins",
|
ClientName: "Justin Hawkins",
|
||||||
ProtocolVersion: "v1.0",
|
ProtocolVersion: "1.0",
|
||||||
AuthToken: "abc123",
|
AuthToken: "dummy",
|
||||||
}
|
}
|
||||||
|
|
||||||
// gob.Register(secure.PacketSendStart{})
|
// gob.Register(secure.PacketSendStart{})
|
||||||
|
@ -112,6 +112,7 @@ func BenchmarkPPS(b *testing.B) {
|
|||||||
|
|
||||||
out := make([]byte, 16384)
|
out := make([]byte, 16384)
|
||||||
n, err := dstSecConn.Read(out)
|
n, err := dstSecConn.Read(out)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Errorf("got error %v", err)
|
b.Errorf("got error %v", err)
|
||||||
}
|
}
|
||||||
|
12
server.go
12
server.go
@ -97,11 +97,23 @@ func handleConnection(conn *net.TCPConn) {
|
|||||||
log.Printf("connection has been closed prematurely")
|
log.Printf("connection has been closed prematurely")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// xxx we need to add a response part here so they can be notified
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error while expecting PacketStart: %v", err)
|
log.Printf("error while expecting PacketStart: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if start.ProtocolVersion != "1.0" {
|
||||||
|
log.Printf("bad protocol version")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if start.AuthToken != "dummy" {
|
||||||
|
log.Print("bad authtoken")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
conn.SetDeadline(time.Now().Add(time.Second * 5))
|
conn.SetDeadline(time.Now().Add(time.Second * 5))
|
||||||
|
|
||||||
if start.OperationType == secure.OperationTypeSend {
|
if start.OperationType == secure.OperationTypeSend {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user