//private TcpClient client; //private Dictionary<string, object> targetInfo; //private object userConfigJson; //private Form1 form1; public Tunnel(Socket client, Dictionary <string, object> targetInfo, ConfigJson userConfigJson, Form1 form) { _client = client; _userConfigJson = userConfigJson; _targetInfo = targetInfo; _form = form; enCodeRc4 = new RC4(userConfigJson.passport); deCodeRc4 = new RC4(userConfigJson.passport); _form.SetLogTextBox("Tunnel"); NetworkStream clientStream = new NetworkStream(_client); TunnelStart(clientStream, new byte[1], 0); //_remote = new Socket(AddressFamily.InterNetwork, // SocketType.Stream, // ProtocolType.Tcp); //Thread sendTargetThread = null; //NetworkStream clientStream = new NetworkStream(client); //try //{ // _remote.Connect(_userConfigJson.server, _userConfigJson.port); // NetworkStream remoteStream = new NetworkStream(_remote); // SendTargetInfoToRemote(_targetInfo, remoteStream, enCodeRc4); // _form.SetLogTextBox("send target Info"); // sendTargetThread = new Thread(ThreadForTarget); // sendTargetThread.Start(new ArrayList { clientStream, remoteStream, enCodeRc4 }); // LoopReceiveAndSend(remoteStream, clientStream, deCodeRc4); //} //catch (Exception e) //{ // _form.SetLogTextBox("传输异常结束: " + e.ToString()); //} //Dispose(); }
public static ConfigJson LoadJson() { using (StreamReader r = new StreamReader("config.json")) { string jsonString = r.ReadToEnd(); ConfigJson config = JsonSerializer.Deserialize <ConfigJson>(jsonString); return(config); } }
private void Form1_Load(object sender, EventArgs e) { ConfigJson userConfigJson = Config.LoadJson(); this.radioButton1.Checked = true; SystemProxy.UpdateSystemProxy(1); Thread listener = new Thread(RunListener); listener.Start(this); // MessageBox.Show(userConfigJson.Passport, userConfigJson.Servers[0], MessageBoxButtons.YesNo); }
public Tunnel(TcpClient client, NetworkStream clientStream, Dictionary <string, object> targetInfo, ConfigJson userConfigJson, Form1 form1, byte[] sendData, int sendDataSize) { tcpClient = client; _userConfigJson = userConfigJson; _targetInfo = targetInfo; _form = form1; enCodeRc4 = new RC4(userConfigJson.passport); deCodeRc4 = new RC4(userConfigJson.passport); _form.SetLogTextBox("http Tunnel"); TunnelStart(clientStream, sendData, sendDataSize); }
public void Init(Form1 form) { userConfigJson = Config.LoadJson(); ipAddress = IPAddress.Parse("127.0.0.1"); port = 1088; mainForm = form; mainForm.SetLogTextBox("SocketListener init"); CreateSocket(); BindAndListen(); WaitClientConnection(); }