package protocol import ( "strings" "github.com/sun8911879/shadowsocksR/ssr" ) type creator func() IProtocol var ( creatorMap = make(map[string]creator) ) type IProtocol interface { SetServerInfo(s *ssr.ServerInfoForObfs) GetServerInfo() *ssr.ServerInfoForObfs PreEncrypt(data []byte) ([]byte, error) PostDecrypt(data []byte) ([]byte, int, error) SetData(data interface{}) GetData() interface{} } type authData struct { clientID []byte connectionID uint32 } func register(name string, c creator) { creatorMap[name] = c } func NewProtocol(name string) IProtocol { c, ok := creatorMap[strings.ToLower(name)] if ok { return c() } return nil }