mirror of
https://github.com/harshabose/socket-comm.git
synced 2025-11-01 11:22:40 +08:00
first commit
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/harshabose/socket-comm/pkg/interceptor"
|
"github.com/harshabose/socket-comm/pkg/interceptor"
|
||||||
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/config"
|
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/config"
|
||||||
|
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/encryptionerr"
|
||||||
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/keyexchange"
|
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/keyexchange"
|
||||||
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/keyprovider"
|
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/keyprovider"
|
||||||
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/state"
|
"github.com/harshabose/socket-comm/pkg/middleware/encrypt/state"
|
||||||
@@ -60,3 +61,17 @@ func (i *Interceptor) UnBindSocketConnection(connection interceptor.Connection)
|
|||||||
func (i *Interceptor) Close() error {
|
func (i *Interceptor) Close() error {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetState(_i interceptor.Interceptor, connection interceptor.Connection) (*state.State, error) {
|
||||||
|
i, ok := _i.(*Interceptor)
|
||||||
|
if !ok {
|
||||||
|
return nil, encryptionerr.ErrInvalidInterceptor
|
||||||
|
}
|
||||||
|
|
||||||
|
s, err := i.stateManager.GetState(connection)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,12 +45,7 @@ func (m *Init) WriteProcess(_ interceptor.Interceptor, _ interceptor.Connection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Init) ReadProcess(_interceptor interceptor.Interceptor, connection interceptor.Connection) error {
|
func (m *Init) ReadProcess(_interceptor interceptor.Interceptor, connection interceptor.Connection) error {
|
||||||
i, ok := _interceptor.(*encrypt.Interceptor)
|
s, err := encrypt.GetState(_interceptor, connection)
|
||||||
if !ok {
|
|
||||||
return encryptionerr.ErrInvalidInterceptor
|
|
||||||
}
|
|
||||||
|
|
||||||
s, err := i.stateManager.GetState(connection)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user