ProxyFactory.cs 573 B

1234567891011121314151617181920
  1. using STUN.Enums;
  2. using STUN.Interfaces;
  3. using System;
  4. using System.Net;
  5. namespace STUN.Proxy
  6. {
  7. public static class ProxyFactory
  8. {
  9. public static IUdpProxy CreateProxy(ProxyType type, IPEndPoint local, IPEndPoint proxy, string user, string password)
  10. {
  11. return type switch
  12. {
  13. ProxyType.Plain => new NoneUdpProxy(local),
  14. ProxyType.Socks5 => new Socks5UdpProxy(local, proxy, user, password),
  15. _ => throw new NotSupportedException(type.ToString())
  16. };
  17. }
  18. }
  19. }