1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-08 11:17:44 -05:00
v2fly/transport/internet/conn_authenticator.go

29 lines
533 B
Go
Raw Normal View History

2016-10-31 17:26:46 -04:00
package internet
import (
2017-01-12 16:47:10 -05:00
"errors"
2016-11-02 17:26:21 -04:00
"net"
2017-01-12 16:47:10 -05:00
"context"
2016-10-31 17:26:46 -04:00
"v2ray.com/core/common"
)
type ConnectionAuthenticator interface {
2016-11-02 17:26:21 -04:00
Client(net.Conn) net.Conn
Server(net.Conn) net.Conn
2016-10-31 17:26:46 -04:00
}
2017-01-12 16:47:10 -05:00
func CreateConnectionAuthenticator(config interface{}) (ConnectionAuthenticator, error) {
auth, err := common.CreateObject(context.Background(), config)
if err != nil {
return nil, err
2016-10-31 17:26:46 -04:00
}
2017-01-12 16:47:10 -05:00
switch a := auth.(type) {
case ConnectionAuthenticator:
return a, nil
default:
return nil, errors.New("Internet: Not a ConnectionAuthenticator.")
2016-10-31 17:26:46 -04:00
}
}