113 lines
3.8 KiB
VB.net
113 lines
3.8 KiB
VB.net
Imports Microsoft.VisualBasic.CompilerServices
|
|||
|
|
Imports System.Threading
|
||
|
|
Public Class Proxy
|
||
|
|
|
||
|
|
Private list_1 As List(Of Listener)
|
||
|
|
|
||
|
|
Public Shared bool_1 As Boolean
|
||
|
|
|
||
|
|
Public Shared bool_2 As Boolean
|
||
|
|
|
||
|
|
Private random_0 As Random
|
||
|
|
|
||
|
|
Public C As Client
|
||
|
|
Public Cip As String
|
||
|
|
|
||
|
|
Private Enum Enum0
|
||
|
|
ProcessDPIUnaware
|
||
|
|
ProcessSystemDPIAware
|
||
|
|
ProcessPerMonitorDPIAware
|
||
|
|
End Enum
|
||
|
|
Private Sub Proxy_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||
|
|
Try
|
||
|
|
If Not My.Computer.Registry.GetValue(SettingsHelper.RegSave, "ProxyPort", Nothing) = Nothing Then
|
||
|
|
Guna2TextBox4.Text = My.Computer.Registry.GetValue(SettingsHelper.RegSave, "ProxyPort", Nothing)
|
||
|
|
End If
|
||
|
|
Catch ex As Exception
|
||
|
|
Debug.WriteLine(ex.Message)
|
||
|
|
End Try
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Proxy_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||
|
|
Try
|
||
|
|
|
||
|
|
Dim B As Byte() = SB("CloseProxy")
|
||
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
|
||
|
|
Listener.Close()
|
||
|
|
BridgeEndPoint.Close()
|
||
|
|
Relay.Close()
|
||
|
|
|
||
|
|
Catch ex As Exception
|
||
|
|
End Try
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
||
|
|
Try
|
||
|
|
If Not C.IsConnected Then
|
||
|
|
Close()
|
||
|
|
End If
|
||
|
|
Catch ex As Exception
|
||
|
|
Debug.WriteLine(ex.Message)
|
||
|
|
End Try
|
||
|
|
End Sub
|
||
|
|
Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click
|
||
|
|
Try
|
||
|
|
|
||
|
|
If Not String.IsNullOrEmpty(Guna2TextBox4.Text) Then
|
||
|
|
If IsNumeric(Guna2TextBox4.Text) Then
|
||
|
|
Try
|
||
|
|
My.Computer.Registry.SetValue(SettingsHelper.RegSave, "ProxyPort", Guna2TextBox4.Text)
|
||
|
|
Catch ex As Exception
|
||
|
|
Debug.WriteLine(ex.Message)
|
||
|
|
End Try
|
||
|
|
|
||
|
|
list_1 = New List(Of Listener)()
|
||
|
|
random_0 = New Random()
|
||
|
|
|
||
|
|
Main.list_4 = New List(Of BridgeEndPoint)()
|
||
|
|
|
||
|
|
|
||
|
|
Dim gclass As Listener = New Listener()
|
||
|
|
gclass.method_0(Guna2TextBox4.Text, list_1.Count - 1, Convert.ToInt32(Guna2TextBox4.Text))
|
||
|
|
list_1.Add(gclass)
|
||
|
|
|
||
|
|
Dim num As Integer = 50950 'random_0.[Next](50000, 60000)
|
||
|
|
|
||
|
|
|
||
|
|
Dim text As String = Cip & ":" & Guna2TextBox4.Text
|
||
|
|
|
||
|
|
Guna2TextBox1.Text = Cip
|
||
|
|
Guna2TextBox2.Text = Guna2TextBox4.Text
|
||
|
|
Guna2TextBox3.Text = "127.0.0.1" & ":" & Conversions.ToString(num)
|
||
|
|
|
||
|
|
|
||
|
|
Dim item As BridgeEndPoint = New BridgeEndPoint(num, text.Substring(0, text.IndexOf(":")), text)
|
||
|
|
Main.list_4.Add(item)
|
||
|
|
|
||
|
|
|
||
|
|
Panel1.Visible = False
|
||
|
|
Panel2.Visible = True
|
||
|
|
|
||
|
|
Dim B As Byte() = SB("RunProxy" & SettingsHelper.SPL & Guna2TextBox4.Text & SettingsHelper.SPL & Cip)
|
||
|
|
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend),B)
|
||
|
|
|
||
|
|
End If
|
||
|
|
End If
|
||
|
|
|
||
|
|
Catch ex As Exception
|
||
|
|
MessageBox.Show(ex.Message)
|
||
|
|
Close()
|
||
|
|
End Try
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Guna2GradientButton2_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton2.Click
|
||
|
|
Close()
|
||
|
|
End Sub
|
||
|
|
|
||
|
|
Private Sub Guna2TextBox4_KeyDown(sender As Object, e As KeyEventArgs) Handles Guna2TextBox4.KeyDown
|
||
|
|
If e.KeyCode = Keys.Enter Then
|
||
|
|
e.SuppressKeyPress = True
|
||
|
|
Guna2GradientButton1.PerformClick()
|
||
|
|
End If
|
||
|
|
End Sub
|
||
|
|
End Class
|