core plugin

This commit is contained in:
刘河
2019-10-14 23:04:14 +08:00
parent 98ab48aaca
commit 8f45d86cee
6 changed files with 39 additions and 92 deletions

View File

@@ -6,30 +6,14 @@ import (
"fmt"
"github.com/cnlh/nps/core"
"io"
"net"
)
type Handshake struct {
}
func (handshake *Handshake) GetConfigName()*core.NpsConfigs{
return nil
}
func (handshake *Handshake) GetStage() core.Stage {
return core.STAGE_RUN
}
func (handshake *Handshake) Start(ctx context.Context, config map[string]string) error {
return nil
core.NpsPlugin
}
func (handshake *Handshake) Run(ctx context.Context, config map[string]string) error {
clientCtxConn := ctx.Value(core.CLIENT_CONNECTION)
if clientCtxConn == nil {
return core.CLIENT_CONNECTION_NOT_EXIST
}
clientConn := clientCtxConn.(net.Conn)
clientConn := handshake.GetClientConn(ctx)
buf := make([]byte, 2)
if _, err := io.ReadFull(clientConn, buf); err != nil {
return errors.New("negotiation err while read 2 bytes from client connection: " + err.Error())
@@ -50,7 +34,3 @@ func (handshake *Handshake) Run(ctx context.Context, config map[string]string) e
return nil
}
func (handshake *Handshake) End(ctx context.Context, config map[string]string) error {
return nil
}