You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

IStrategy.cs 1.3 kB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Shadowsocks.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Net;
  5. using System.Text;
  6. namespace Shadowsocks.Controller.Strategy
  7. {
  8. public enum IStrategyCallerType
  9. {
  10. TCP,
  11. UDP
  12. }
  13. /*
  14. * IStrategy
  15. *
  16. * Subclasses must be thread-safe
  17. */
  18. public interface IStrategy
  19. {
  20. string Name { get; }
  21. string ID { get; }
  22. /*
  23. * Called when servers need to be reloaded, i.e. new configuration saved
  24. */
  25. void ReloadServers();
  26. /*
  27. * Get a new server to use in TCPRelay or UDPRelay
  28. */
  29. Server GetAServer(IStrategyCallerType type, IPEndPoint localIPEndPoint);
  30. /*
  31. * TCPRelay will call this when latency of a server detected
  32. */
  33. void UpdateLatency(Server server, TimeSpan latency);
  34. /*
  35. * TCPRelay will call this when reading from a server
  36. */
  37. void UpdateLastRead(Server server);
  38. /*
  39. * TCPRelay will call this when writing to a server
  40. */
  41. void UpdateLastWrite(Server server);
  42. /*
  43. * TCPRelay will call this when fatal failure detected
  44. */
  45. void SetFailure(Server server);
  46. }
  47. }