first commit

This commit is contained in:
harshabose
2025-04-30 16:26:36 +05:30
parent 2a53196f7d
commit 8f381b77f4
2 changed files with 16 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/harshabose/socket-comm/pkg/interceptor"
"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/keyprovider"
"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 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
}

View File

@@ -45,12 +45,7 @@ func (m *Init) WriteProcess(_ interceptor.Interceptor, _ interceptor.Connection)
}
func (m *Init) ReadProcess(_interceptor interceptor.Interceptor, connection interceptor.Connection) error {
i, ok := _interceptor.(*encrypt.Interceptor)
if !ok {
return encryptionerr.ErrInvalidInterceptor
}
s, err := i.stateManager.GetState(connection)
s, err := encrypt.GetState(_interceptor, connection)
if err != nil {
return err
}