Example #1
0
 internal async Task onConnectionException(InConnection inc, Exception e)
 {
     Logger.exception(e, Logging.Level.Error, $"Handling {inc}");
     if (inc.IsHandled == false)
     {
         await inc.SetResult(new ConnectResultBase(this, ConnectResultEnum.Failed) {
             FailedReason = $"exception: {e.GetType()}: {e.Message}"
         });
     }
 }
Example #2
0
 public override Task HandleConnection(InConnection connection)
 {
     if (connection is InConnectionDns dns)
     {
         if (redirect_dns != null)
         {
             dns.RedirectTo(redirect_dns);
             return(NaiveUtils.CompletedTask);
         }
         return(ResolveNameCore(dns));
     }
     if (connection is InConnectionUdp udp)
     {
         var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
         return(connection.SetResult(new ConnectResultUdp(this, ConnectResultEnum.OK)
         {
             UdpSocket = GetMyStreamFromSocket(socket) as IUdpSocket
         }));
     }
     return(base.HandleConnection(connection));
 }