示例#1
0
文件: tor.cs 项目: Betawolf/whore
 public virtual void onConnect(object sender, CreateConnectionAsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         System.Console.WriteLine("Task({0}): Connection to {1} failed via TorInstance({2}).", this.GetHashCode(), this.endPoint, tor.GetHashCode());
     System.Console.WriteLine(e.Error);
     System.Console.Write(e.Error.StackTrace);
     }
     else
     {
         System.Console.WriteLine("Task({0}): Connection to {1} established via TorInstance({2}).", this.GetHashCode(), this.endPoint, tor.GetHashCode());
     }
 }
示例#2
0
 private void CreateConnectionAsyncCompleted(object sender, CreateConnectionAsyncCompletedEventArgs e)
 {
     ProxyConnectionResult result;
     while (!pendingOperations.TryDequeue(out result)) { }
     if (e.Error == null)
     {
         socket = e.ProxyConnection.Client;
         result.Callback(result);
     }
     else
     {
         if (e.Error.InnerException.Message.StartsWith("The the network was unreachable concerning destination host"))
             throw e.Error;
         // Inform user, ask if they want to forgo the proxy
         while (WaitingForUserInput) { }
         if (!InformedUserOfFailure)
         {
             InformedUserOfFailure = true;
             WaitingForUserInput = true;
             ConnectAnyway = MessageBox.Show(string.Format("Unable to connect to proxy ({0}). Connect without proxy?",
                 e.Error.InnerException.Message), "Error", MessageBoxButton.YesNo) == MessageBoxResult.Yes;
             WaitingForUserInput = false;
         }
         if (ConnectAnyway)
         {
             socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
             try
             {
                 socket.Connect(EndPoint);
                 result.Callback(result);
             }
             catch (Exception ex)
             {
                 result.Callback(result);
             }
         }
         else
             result.Callback(result);
     }
 }
示例#3
0
文件: whois.cs 项目: Betawolf/whore
 public override void onConnect(object sender, CreateConnectionAsyncCompletedEventArgs e)
 {
     base.onConnect(sender, e);
     if (e.Error == null)
     {
         TcpClient tcp = e.ProxyConnection;
         tcp.Client.Send(ASCIIEncoding.ASCII.GetBytes(Host + "\r\n"));
         tcp.Client.BeginReceive(chunk, 0, chunk.Length, SocketFlags.None, new AsyncCallback(this.onRecieve), this);
     }
     else
     {
         Console.WriteLine("Socket error has occured. " + e.Error);
     }
 }