ProxyFactory.cs 473 B

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