2
0

RemoteEndPointRequest.cs 959 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using DNS.Protocol;
  2. using FastGithub.Configuration;
  3. using System.Net;
  4. namespace FastGithub.Dns
  5. {
  6. /// <summary>
  7. /// 带远程终节点的请求
  8. /// </summary>
  9. sealed class RemoteEndPointRequest : Request
  10. {
  11. /// <summary>
  12. /// 获取程终节点
  13. /// </summary>
  14. public EndPoint RemoteEndPoint { get; }
  15. /// <summary>
  16. /// 远程请求
  17. /// </summary>
  18. /// <param name="request"></param>
  19. /// <param name="remoteEndPoint"></param>
  20. public RemoteEndPointRequest(Request request, EndPoint remoteEndPoint)
  21. : base(request)
  22. {
  23. this.RemoteEndPoint = remoteEndPoint;
  24. }
  25. /// <summary>
  26. /// 获取对应的本机地址
  27. /// </summary>
  28. /// <returns></returns>
  29. public IPAddress? GetLocalIPAddress()
  30. {
  31. return LocalMachine.GetLocalIPAddress(this.RemoteEndPoint);
  32. }
  33. }
  34. }