| 326 | }; |
| 327 | |
| 328 | void Socket::SetOutputSecurity(int encryptType, const int8_t* key, int keylen, int compressC2s) |
| 329 | { |
| 330 | std::shared_ptr<limax::Codec> codec = OutputBuffer; |
| 331 | switch (encryptType) |
| 332 | { |
| 333 | case Constant::eEncryptTypeDisable: |
| 334 | break; |
| 335 | case Constant::eEncryptTypeAes: |
| 336 | case Constant::eEncryptTypeAesNoSecureIp: |
| 337 | codec = std::shared_ptr<limax::Codec>(new limax::Encrypt(codec, (int8_t*)key, keylen)); |
| 338 | break; |
| 339 | //TODO: 新增加密算法支持这里加case |
| 340 | default: |
| 341 | throw new std::exception("SetOutputSecurityCodec: unknown encryptType="); |
| 342 | } |
| 343 | |
| 344 | switch (compressC2s) |
| 345 | { |
| 346 | case Constant::eCompressTypeDisable: |
| 347 | break; |
| 348 | case Constant::eCompressTypeMppc: |
| 349 | codec = std::shared_ptr<limax::Codec>(new limax::RFC2118Encode(codec)); |
| 350 | break; |
| 351 | //TODO: 新增压缩算法支持这里加case |
| 352 | default: |
| 353 | throw new std::exception("SetOutputSecurityCodec: unknown compress="); |
| 354 | } |
| 355 | std::lock_guard<std::recursive_mutex> scoped(mutex); |
| 356 | OutputCodec = codec; |
| 357 | } |
| 358 | |
| 359 | void Socket::SetInputSecurity(int encryptType, const int8_t* key, int keylen, int compressS2c) |
| 360 | { |