Option Strict Off
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Imports System
Public Class Form1
Inherits System.Windows.Forms.Form
Dim ind, porta As String
'General stuff
Dim ore As Integer
Dim OpList() As String
Dim isConnectedFlag As Boolean
Dim UserStats As UserStatisticStructure
Dim Timer As TimerStructure
Const BotVersion As String = "Manda mex By GoLDBeRG"
'Socket stuff
Private Client As New TcpClient
Private ClientStream As NetworkStream
Private ReadBuffer(1024) As Byte
Private ReadMessage As String
Public Delegate Sub ProcessInvoker(ByVal Data As String)
'Timerstuff
Private RunTime As New System.Timers.Timer(1000)
Structure TimerStructure
Dim Connect As Integer
Dim LockConnect As Integer
End Structure
Structure UserStatisticStructure
Dim IsOp As Boolean
Dim isOnline As Integer
Dim Username As String
Dim Password As String
Dim Email As String
Dim Description As String
Dim Sharesize As String
Dim Connection As String
Dim HubAdress As String
End Structure
#Region " Codice generato da Progettazione Windows Form "
Public Sub New()
MyBase.New()
'Chiamata richiesta da Progettazione Windows Form.
InitializeComponent()
'Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent()
End Sub
'Form esegue l'override del metodo Dispose per pulire l'elenco dei componenti.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Richiesto da Progettazione Windows Form
Private components As System.ComponentModel.IContainer
'NOTA: la procedura che segue è richiesta da Progettazione Windows Form.
'Può essere modificata in Progettazione Windows Form.
'Non modificarla nell'editor del codice.
Friend WithEvents btnConnect As System.Windows.Forms.Button
Friend WithEvents StatusBar As System.Windows.Forms.StatusBar
Friend WithEvents StatusConnected As System.Windows.Forms.StatusBarPanel
Friend WithEvents StatusHubname As System.Windows.Forms.StatusBarPanel
Friend WithEvents StatusUsers As System.Windows.Forms.StatusBarPanel
Friend WithEvents ProgressBar As System.Windows.Forms.ProgressBar
Friend WithEvents txtshare As System.Windows.Forms.TextBox
Friend WithEvents txtuser As System.Windows.Forms.TextBox
Friend WithEvents txtpass As System.Windows.Forms.TextBox
Friend WithEvents txtdesc As System.Windows.Forms.TextBox
Friend WithEvents txtemail As System.Windows.Forms.TextBox
Friend WithEvents cmbSpeed As System.Windows.Forms.ComboBox
Friend WithEvents nmrAutoreconnect As System.Windows.Forms.NumericUpDown
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnDisconnect As System.Windows.Forms.Button
Friend WithEvents lblShareSize As System.Windows.Forms.Label
Friend WithEvents chkConfirmExit As System.Windows.Forms.CheckBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents ok As System.Windows.Forms.Label
Friend WithEvents cmd2 As System.Windows.Forms.TextBox
Friend WithEvents cmd4 As System.Windows.Forms.TextBox
Friend WithEvents cmd1 As System.Windows.Forms.TextBox
Friend WithEvents cmd3 As System.Windows.Forms.TextBox
Friend WithEvents txtport As System.Windows.Forms.TextBox
Friend WithEvents txtip As System.Windows.Forms.ListBox
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents Timer2 As System.Windows.Forms.Timer
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.btnConnect = New System.Windows.Forms.Button
Me.StatusBar = New System.Windows.Forms.StatusBar
Me.StatusConnected = New System.Windows.Forms.StatusBarPanel
Me.StatusHubname = New System.Windows.Forms.StatusBarPanel
Me.StatusUsers = New System.Windows.Forms.StatusBarPanel
Me.ProgressBar = New System.Windows.Forms.ProgressBar
Me.txtshare = New System.Windows.Forms.TextBox
Me.txtuser = New System.Windows.Forms.TextBox
Me.txtpass = New System.Windows.Forms.TextBox
Me.txtdesc = New System.Windows.Forms.TextBox
Me.txtemail = New System.Windows.Forms.TextBox
Me.cmbSpeed = New System.Windows.Forms.ComboBox
Me.nmrAutoreconnect = New System.Windows.Forms.NumericUpDown
Me.Label1 = New System.Windows.Forms.Label
Me.btnDisconnect = New System.Windows.Forms.Button
Me.lblShareSize = New System.Windows.Forms.Label
Me.chkConfirmExit = New System.Windows.Forms.CheckBox
Me.Button2 = New System.Windows.Forms.Button
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.ok = New System.Windows.Forms.Label
Me.cmd2 = New System.Windows.Forms.TextBox
Me.cmd4 = New System.Windows.Forms.TextBox
Me.cmd1 = New System.Windows.Forms.TextBox
Me.cmd3 = New System.Windows.Forms.TextBox
Me.txtport = New System.Windows.Forms.TextBox
Me.txtip = New System.Windows.Forms.ListBox
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.Timer2 = New System.Windows.Forms.Timer(Me.components)
Me.Button1 = New System.Windows.Forms.Button
CType(Me.StatusConnected, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.StatusHubname, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.StatusUsers, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.nmrAutoreconnect, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'btnConnect
'
Me.btnConnect.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.btnConnect.Location = New System.Drawing.Point(32, 256)
Me.btnConnect.Name = "btnConnect"
Me.btnConnect.TabIndex = 0
Me.btnConnect.TabStop = False
Me.btnConnect.Text = "Connetti"
'
'StatusBar
'
Me.StatusBar.Location = New System.Drawing.Point(0, 422)
Me.StatusBar.Name = "StatusBar"
Me.StatusBar.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.StatusConnected, Me.StatusHubname, Me.StatusUsers})
Me.StatusBar.ShowPanels = True
Me.StatusBar.Size = New System.Drawing.Size(374, 22)
Me.StatusBar.SizingGrip = False
Me.StatusBar.TabIndex = 1
'
'StatusConnected
'
Me.StatusConnected.Alignment = System.Windows.Forms.HorizontalAlignment.Center
Me.StatusConnected.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusConnected.Text = "Not Connected"
Me.StatusConnected.Width = 124
'
'StatusHubname
'
Me.StatusHubname.Alignment = System.Windows.Forms.HorizontalAlignment.Center
Me.StatusHubname.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusHubname.Text = "No Hub"
Me.StatusHubname.Width = 124
'
'StatusUsers
'
Me.StatusUsers.Alignment = System.Windows.Forms.HorizontalAlignment.Center
Me.StatusUsers.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.StatusUsers.Text = "0"
Me.StatusUsers.Width = 124
'
'ProgressBar
'
Me.ProgressBar.Location = New System.Drawing.Point(8, 360)
Me.ProgressBar.Maximum = 3
Me.ProgressBar.Name = "ProgressBar"
Me.ProgressBar.Size = New System.Drawing.Size(360, 16)
Me.ProgressBar.Step = 1
Me.ProgressBar.TabIndex = 3
'
'txtshare
'
Me.txtshare.Location = New System.Drawing.Point(8, 80)
Me.txtshare.MaxLength = 15
Me.txtshare.Name = "txtshare"
Me.txtshare.Size = New System.Drawing.Size(96, 20)
Me.txtshare.TabIndex = 1
Me.txtshare.Text = "5435743573"
Me.txtshare.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtuser
'
Me.txtuser.Location = New System.Drawing.Point(8, 104)
Me.txtuser.Name = "txtuser"
Me.txtuser.Size = New System.Drawing.Size(96, 20)
Me.txtuser.TabIndex = 2
Me.txtuser.Text = "AstaLaVista"
Me.txtuser.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtpass
'
Me.txtpass.AutoSize = False
Me.txtpass.Font = New System.Drawing.Font("Comic Sans MS", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtpass.Location = New System.Drawing.Point(8, 128)
Me.txtpass.Name = "txtpass"
Me.txtpass.PasswordChar = Microsoft.VisualBasic.ChrW(8226)
Me.txtpass.Size = New System.Drawing.Size(96, 20)
Me.txtpass.TabIndex = 3
Me.txtpass.Text = "123456123"
Me.txtpass.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtdesc
'
Me.txtdesc.BackColor = System.Drawing.Color.White
Me.txtdesc.Location = New System.Drawing.Point(8, 152)
Me.txtdesc.Name = "txtdesc"
Me.txtdesc.Size = New System.Drawing.Size(360, 20)
Me.txtdesc.TabIndex = 4
Me.txtdesc.TabStop = False
Me.txtdesc.Text = "Manda Mex By GoLDBeRG"
Me.txtdesc.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtemail
'
Me.txtemail.BackColor = System.Drawing.Color.White
Me.txtemail.Location = New System.Drawing.Point(8, 176)
Me.txtemail.Name = "txtemail"
Me.txtemail.Size = New System.Drawing.Size(360, 20)
Me.txtemail.TabIndex = 5
Me.txtemail.TabStop = False
Me.txtemail.Text = "www.oenrik.it"
Me.txtemail.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'cmbSpeed
'
Me.cmbSpeed.BackColor = System.Drawing.Color.White
Me.cmbSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cmbSpeed.Items.AddRange(New Object() {"BOT", "ISDN", "DSL", "Satellite", "Wireless", "LAN(T1)", "LAN(T3)"})
Me.cmbSpeed.Location = New System.Drawing.Point(112, 120)
Me.cmbSpeed.Name = "cmbSpeed"
Me.cmbSpeed.Size = New System.Drawing.Size(256, 21)
Me.cmbSpeed.TabIndex = 2
Me.cmbSpeed.TabStop = False
'
'nmrAutoreconnect
'
Me.nmrAutoreconnect.BackColor = System.Drawing.Color.White
Me.nmrAutoreconnect.Location = New System.Drawing.Point(8, 200)
Me.nmrAutoreconnect.Maximum = New Decimal(New Integer() {60, 0, 0, 0})
Me.nmrAutoreconnect.Name = "nmrAutoreconnect"
Me.nmrAutoreconnect.ReadOnly = True
Me.nmrAutoreconnect.Size = New System.Drawing.Size(48, 20)
Me.nmrAutoreconnect.TabIndex = 6
Me.nmrAutoreconnect.TabStop = False
Me.nmrAutoreconnect.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Label1
'
Me.Label1.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.Label1.Location = New System.Drawing.Point(56, 200)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(80, 16)
Me.Label1.TabIndex = 7
Me.Label1.Text = "Autoriconnetti"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.BottomLeft
'
'btnDisconnect
'
Me.btnDisconnect.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.btnDisconnect.Location = New System.Drawing.Point(112, 256)
Me.btnDisconnect.Name = "btnDisconnect"
Me.btnDisconnect.TabIndex = 0
Me.btnDisconnect.TabStop = False
Me.btnDisconnect.Text = "Disconnetti"
'
'lblShareSize
'
Me.lblShareSize.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.lblShareSize.Location = New System.Drawing.Point(104, 80)
Me.lblShareSize.Name = "lblShareSize"
Me.lblShareSize.Size = New System.Drawing.Size(100, 16)
Me.lblShareSize.TabIndex = 7
Me.lblShareSize.TextAlign = System.Drawing.ContentAlignment.BottomLeft
'
'chkConfirmExit
'
Me.chkConfirmExit.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.chkConfirmExit.Location = New System.Drawing.Point(8, 232)
Me.chkConfirmExit.Name = "chkConfirmExit"
Me.chkConfirmExit.Size = New System.Drawing.Size(104, 16)
Me.chkConfirmExit.TabIndex = 8
Me.chkConfirmExit.TabStop = False
Me.chkConfirmExit.Text = "Conferma uscita"
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button2.Location = New System.Drawing.Point(192, 256)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 0
Me.Button2.TabStop = False
Me.Button2.Text = "Chiudi"
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.Button1)
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.TextBox2)
Me.GroupBox1.Controls.Add(Me.Button3)
Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.GroupBox1.Location = New System.Drawing.Point(8, 280)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(360, 72)
Me.GroupBox1.TabIndex = 9
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Aggiunta Hub"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(8, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(272, 20)
Me.TextBox1.TabIndex = 10
Me.TextBox1.Text = "pippo.no-ip.info"
Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(280, 16)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(64, 20)
Me.TextBox2.TabIndex = 11
Me.TextBox2.Text = "411"
Me.TextBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'Button3
'
Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button3.Location = New System.Drawing.Point(280, 40)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(64, 23)
Me.Button3.TabIndex = 0
Me.Button3.TabStop = False
Me.Button3.Text = "Aggiungi"
'
'Button4
'
Me.Button4.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button4.Location = New System.Drawing.Point(272, 256)
Me.Button4.Name = "Button4"
Me.Button4.TabIndex = 0
Me.Button4.TabStop = False
Me.Button4.Text = "Salva"
'
'ok
'
Me.ok.Location = New System.Drawing.Point(8, 384)
Me.ok.Name = "ok"
Me.ok.Size = New System.Drawing.Size(360, 32)
Me.ok.TabIndex = 10
Me.ok.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'cmd2
'
Me.cmd2.Location = New System.Drawing.Point(256, 208)
Me.cmd2.MaxLength = 32512
Me.cmd2.Name = "cmd2"
Me.cmd2.Size = New System.Drawing.Size(112, 20)
Me.cmd2.TabIndex = 7
Me.cmd2.Text = "2° comando"
Me.cmd2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'cmd4
'
Me.cmd4.Location = New System.Drawing.Point(256, 232)
Me.cmd4.MaxLength = 32512
Me.cmd4.Name = "cmd4"
Me.cmd4.Size = New System.Drawing.Size(112, 20)
Me.cmd4.TabIndex = 9
Me.cmd4.Text = "4° comando"
Me.cmd4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'cmd1
'
Me.cmd1.Location = New System.Drawing.Point(144, 208)
Me.cmd1.MaxLength = 32512
Me.cmd1.Name = "cmd1"
Me.cmd1.Size = New System.Drawing.Size(112, 20)
Me.cmd1.TabIndex = 6
Me.cmd1.Text = "1° comando"
Me.cmd1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'cmd3
'
Me.cmd3.Location = New System.Drawing.Point(144, 232)
Me.cmd3.MaxLength = 32512
Me.cmd3.Name = "cmd3"
Me.cmd3.Size = New System.Drawing.Size(112, 20)
Me.cmd3.TabIndex = 8
Me.cmd3.Text = "3° comando"
Me.cmd3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtport
'
Me.txtport.BackColor = System.Drawing.Color.White
Me.txtport.Location = New System.Drawing.Point(112, 96)
Me.txtport.MaxLength = 15
Me.txtport.Name = "txtport"
Me.txtport.ReadOnly = True
Me.txtport.Size = New System.Drawing.Size(256, 20)
Me.txtport.TabIndex = 1
Me.txtport.Text = "411"
Me.txtport.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'txtip
'
Me.txtip.BackColor = System.Drawing.Color.White
Me.txtip.ContextMenu = Me.ContextMenu1
Me.txtip.Location = New System.Drawing.Point(8, 8)
Me.txtip.Name = "txtip"
Me.txtip.ScrollAlwaysVisible = True
Me.txtip.Size = New System.Drawing.Size(360, 69)
Me.txtip.Sorted = True
Me.txtip.TabIndex = 11
Me.txtip.TabStop = False
Me.txtip.UseTabStops = False
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.Text = "Elimina"
'
'Timer2
'
Me.Timer2.Interval = 10000
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button1.Location = New System.Drawing.Point(8, 40)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(272, 23)
Me.Button1.TabIndex = 12
Me.Button1.TabStop = False
Me.Button1.Text = "Non riesco ad utilizzare il programma!"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(374, 444)
Me.Controls.Add(Me.txtip)
Me.Controls.Add(Me.ok)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.nmrAutoreconnect)
Me.Controls.Add(Me.txtpass)
Me.Controls.Add(Me.txtshare)
Me.Controls.Add(Me.ProgressBar)
Me.Controls.Add(Me.StatusBar)
Me.Controls.Add(Me.btnConnect)
Me.Controls.Add(Me.txtuser)
Me.Controls.Add(Me.txtdesc)
Me.Controls.Add(Me.txtemail)
Me.Controls.Add(Me.cmbSpeed)
Me.Controls.Add(Me.btnDisconnect)
Me.Controls.Add(Me.lblShareSize)
Me.Controls.Add(Me.chkConfirmExit)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.cmd2)
Me.Controls.Add(Me.cmd4)
Me.Controls.Add(Me.cmd1)
Me.Controls.Add(Me.cmd3)
Me.Controls.Add(Me.txtport)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Manda Mex By GoLDBeRG"
CType(Me.StatusConnected, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.StatusHubname, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.StatusUsers, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.nmrAutoreconnect, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler RunTime.Elapsed, AddressOf TimerFired
If File.
Exists(Application.
StartupPath & "\indirizzi.gold") = True Then
Dim share As StreamReader = New StreamReader(Application.StartupPath & "\share.gold")
If share.ReadLine = "" Then
share.Close()
GoTo casa
Else
share.Close()
End If
Dim connessione As StreamReader = New StreamReader(Application.StartupPath & "\connessione.gold")
cmbSpeed.Text = connessione.ReadLine
connessione.Close()
Dim percorso2 As String = Application.StartupPath & "\indirizzi.gold"
Dim linea As Object
FileOpen(1, percorso2, OpenMode.Input)
Do While Not EOF(1)
linea = LineInput(1)
If linea <> "" Then txtip.Items.Add((linea))
Loop
FileClose(1)
Dim share2 As StreamReader = New StreamReader(Application.StartupPath & "\share.gold")
txtshare.Text = share2.ReadLine
share2.Close()
Dim descr2 As StreamReader = New StreamReader(Application.StartupPath & "\descrizione.gold")
txtdesc.Text = descr2.ReadLine
descr2.Close()
On Error Resume Next
txtip.SelectedIndex = 0
Dim nick As StreamReader = New StreamReader(Application.StartupPath & "\nick.gold")
txtuser.Text = nick.ReadLine
nick.Close()
Dim passwd As StreamReader = New StreamReader(Application.StartupPath & "\passwd.gold")
txtpass.Text = passwd.ReadLine
passwd.Close()
Dim email As StreamReader = New StreamReader(Application.StartupPath & "\email.gold")
txtemail.Text = email.ReadLine
email.Close()
Dim nmrautoriconnetti As StreamReader = New StreamReader(Application.StartupPath & "\autoriconnetti.gold")
nmrAutoreconnect.Text = nmrautoriconnetti.ReadLine
nmrautoriconnetti.Close()
Dim conferma As StreamReader = New StreamReader(Application.StartupPath & "\confermachiusura.gold")
Dim conf As String
conf = conferma.ReadLine
If conf = "si" Then
chkConfirmExit.Checked = True
conferma.Close()
Else
chkConfirmExit.Checked = False
conferma.Close()
End If
Dim comando1 As StreamReader = New StreamReader(Application.StartupPath & "\comando1.gold")
cmd1.Text = comando1.ReadLine
comando1.Close()
Dim comando2 As StreamReader = New StreamReader(Application.StartupPath & "\comando2.gold")
cmd2.Text = comando2.ReadLine
comando2.Close()
Dim comando3 As StreamReader = New StreamReader(Application.StartupPath & "\comando3.gold")
cmd3.Text = comando3.ReadLine
comando3.Close()
Dim comando4 As StreamReader = New StreamReader(Application.StartupPath & "\comando4.gold")
cmd4.Text = comando4.ReadLine
comando4.Close()
Else
File.
Create(Application.
StartupPath & "\indirizzi.gold")
File.
Create(Application.
StartupPath & "\connessione.gold")
File.
Create(Application.
StartupPath & "\share.gold")
File.
Create(Application.
StartupPath & "\nick.gold")
File.
Create(Application.
StartupPath & "\passwd.gold")
File.
Create(Application.
StartupPath & "\email.gold")
File.
Create(Application.
StartupPath & "\autoriconnetti.gold")
File.
Create(Application.
StartupPath & "\confermachiusura.gold")
File.
Create(Application.
StartupPath & "\comando1.gold")
File.
Create(Application.
StartupPath & "\comando2.gold")
File.
Create(Application.
StartupPath & "\comando3.gold")
File.
Create(Application.
StartupPath & "\comando4.gold")
File.
Create(Application.
StartupPath & "\descrizione.gold")
MessageBox.Show("Ok i file di salvataggio sono stati correttamente creati, si prega di riavviare l'appilicazione", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information)
End
End If
casa:
End Sub
Public Sub TimerFired(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
If RunTime.Enabled Then
If Timer.LockConnect > 0 Then
btnConnect.Text = CStr(Timer.LockConnect)
Timer.LockConnect -= 1
ElseIf Timer.LockConnect = 0 Then
Timer.LockConnect = -1
btnConnect.Text = "Connect"
btnConnect.Enabled = True
ElseIf btnConnect.Enabled = False Then
btnConnect.Text = "Connect"
btnConnect.Enabled = True
End If
If UserStats.isOnline > -1 Then UserStats.isOnline -= 1
If Timer.Connect > 0 Then
Me.StatusConnected.Text = "Connecting in " & CStr(Timer.Connect)
Timer.Connect -= 1
ElseIf Timer.Connect = 0 Then
Timer.Connect = -1
Connect(txtip.Text, txtport.Text)
End If
'End timer
If Timer.Connect = -1 And UserStats.isOnline = -1 And Timer.LockConnect = -1 Then RunTime.Stop()
End If
End Sub
Private Sub Disconnect()
On Error Resume Next
Timer.Connect = -1
ClientStream.Close()
Client.Close()
Timer.LockConnect = -1
ProgressBar.Value = 0
UserStats.isOnline = -1
Me.StatusUsers.Text = "0"
Me.StatusConnected.Text = "Not Connected"
Me.StatusHubname.Text = "No Hub"
isConnectedFlag = False
ReadMessage = ""
Timer2.Enabled = True
End Sub
Private Sub StoreUserdata()
ok.Text = ("*** Connecting to " & txtip.Text & "..")
UserStats.Username = txtuser.Text
UserStats.Password = txtpass.Text
UserStats.Description = txtdesc.Text
UserStats.Email = txtemail.Text
If txtshare.Text <> "" Then UserStats.Sharesize = txtshare.Text Else UserStats.Sharesize = "0"
UserStats.Connection = cmbSpeed.Text
UserStats.HubAdress = txtip.Text
End Sub
Private Sub Connect(ByVal HubAdress As String, ByVal HubPort As String)
'Lock the Connect button
Timer.Connect = -1
Disconnect()
'Check if a hubadress was entered
If txtip.Text = "" Then
MsgBox("Please enter an adress or IP to connect to.", MsgBoxStyle.Exclamation, Me.Text)
Exit Sub
End If
'Check if a sharesize was entered
If txtshare.Text = "" Then
UserStats.Sharesize = "0"
ElseIf Not IsNumeric(txtshare.Text) Then
MsgBox("Sharesize requires a numeric value in bytes to work.", MsgBoxStyle.Exclamation, Me.Text)
Exit Sub
End If
'Check if a username is entered
If txtuser.Text = "" Then
MsgBox("Please enter a username in the settings.", MsgBoxStyle.Exclamation, Me.Text)
Exit Sub
End If
'Check if a port is entered
If HubPort.Length = 0 Then
HubPort = "411"
ElseIf Not IsNumeric(HubPort) Then
MsgBox("Server Port is not a valid port. Try again (leave blank for default 411)", MsgBoxStyle.Exclamation, Me.Text)
Exit Sub
End If
ProgressBar.Value = 1
btnConnect.Enabled = False
StoreUserdata()
Try
'Make new connection
Client = New TcpClient(HubAdress, HubPort)
ClientStream = Client.GetStream
isConnectedFlag = True
ClientStream.BeginRead(ReadBuffer, 0, 1024, AddressOf DoRead, Nothing)
Catch Ex As Exception
'Nobody answered
ok.Text = ("*** Server is not active or the adress/port is invalid.")
ProgressBar.Value = 0
btnConnect.Enabled = True
If nmrAutoreconnect.Value > 0 Then
Timer.Connect = CInt(nmrAutoreconnect.Value)
RunTime.Start()
End If
End Try
End Sub
Private Sub ProcessData(ByVal strMessage As String)
Dim dataArray(), strLock, Lock2Key, strCase As String
Dim i, x As Integer
' Message parts are divided by "|" Break the string into an array accordingly.
dataArray = strMessage.Split("|".ToCharArray)
'I recommend http://wza.digitalbrains.com/DC/doc/Introduction.html for info on DC protocol.
Try
For i = dataArray.GetLowerBound(0) To dataArray.GetUpperBound(0)
If dataArray(i).StartsWith("$") And dataArray(i).IndexOf(" ") > 0 Then
strCase = dataArray(i).Substring(0, (dataArray(i).IndexOf(" ")))
Else
strCase = dataArray(i)
End If
Select Case strCase
Case "$Search"
' $Search <ip:port> <1>?<2>?<3>?<4>?<string>|
' $Search Hub:<name> <1>?<2>?<3>?<4>?<string>|
Case "$MyINFO"
' $MyINFO $ALL <name> <description>$ $<connection><char>$<email>$<share>$|
Case "$Hello"
'$Hello <name>|
If dataArray(i) = "$Hello " & UserStats.Username Then
'If we're not an OP, we don't share
Dim ShareSize As String = "0"
'If UserStats.IsOp Then
ShareSize = UserStats.Sharesize
'End If
'$Version <version>|$GetNickList|$MyINFO $ALL <name> <description>$ $<connection><char>$<email>$<share>$|
SendData("$Version 1,0091|$GetNickList|$MyINFO $ALL " & UserStats.Username & " " & UserStats.Description & " <" & BotVersion & ">$ $" & UserStats.Connection & " $" & UserStats.Email & "$" & ShareSize & "$|")
ProgressBar.Value = 3
If cmd1.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd1.Text & "|")
If cmd2.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd2.Text & "|")
If cmd3.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd3.Text & "|")
If cmd4.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd4.Text & "|")
If txtip.SelectedIndex = txtip.Items.Count - 1 Then
End
End If
btnDisconnect.PerformClick()
Else
HubUsers(1)
End If
Case "$Quit"
'$Quit <name>|
Me.StatusUsers.Text = CStr(CInt(Me.StatusUsers.Text) - 1)
Case "$To:"
'$To <name> From: <name> $<<name>> <message>|
CheckMessage(dataArray(i), 2)
Case "$Supports"
'$Supports <feature> <feature_etc>|
Case "$HubINFO"
'$HubINFO <hubname> <etc>|
Case "$UserIP"
'$UserIP <name> <ip>|
Case "$UserCommand"
'$UserCommand <type> <context> <details>|
Case "$ForceMove"
ok.Text = ("*** You are being redirected to " & (dataArray(i).Substring(11)))
If txtip.SelectedIndex = txtip.Items.Count - 1 Then
End
End If
btnDisconnect.PerformClick()
'$ForceMove <address>|
Case "$LogedIn"
'$LogedIn|
'Yes, it really is "LogedIn", not "LoggedIn"
UserStats.IsOp = True
Case "$ValidateDenide"
ok.Text = ("*** Nickname was already taken, try something else.")
If txtip.SelectedIndex = txtip.Items.Count - 1 Then
End
End If
btnDisconnect.PerformClick()
'$ValidateDenide <name>|
Case "$HubIsFull"
ok.Text = ("*** The hub is currently full, try again later.")
If txtip.SelectedIndex = txtip.Items.Count - 1 Then
End
End If
btnDisconnect.PerformClick()
'$HubIsFull|
Case "$BadPass"
ok.Text = ("*** The password was incorrect.")
If txtip.SelectedIndex = txtip.Items.Count - 1 Then
End
End If
btnDisconnect.PerformClick()
'$BadPass|
Case "$NickList"
'$NickList <name>$$<etc>$$|
Dim NickList() As String
Dim nicks As String
nicks = (dataArray(i).Substring(10)).Replace("$$", "$")
NickList = nicks.Split("$".ToCharArray)
'For x = NickList.GetLowerBound(0) To NickList.GetUpperBound(0) - 1
' Use this to make a list of online users
'Next
HubUsers(NickList.GetUpperBound(0) - 1)
Case "$OpList"
'$OpList <name>$$<etc>$$|
Dim nicks As String
nicks = (dataArray(i).Substring(8)).Replace("$$", "$")
OpList = Nothing
OpList = nicks.Split("$".ToCharArray)
Case "$GetPass"
'$GetPass|
ok.Text = ("*** Nickname is registered, sending password.")
SendData("$MyPass " & UserStats.Password & "|")
Case "$HubName"
'$HubName <name>|
Me.StatusConnected.Text = "Connected"
If UserStats.isOnline = -1 Then
UserStats.isOnline = 10
RunTime.Start()
End If
btnConnect.Enabled = True
Case "$Lock"
'$Lock <string>|
Lock2Key = LockToKey(dataArray(i).Substring(6), 5)
If dataArray(i).Substring(0, 22) = "$Lock EXTENDEDPROTOCOL" Then
'If there is an EXTENDEDPROTOCOL, we can send the $Supports command to find out what it can do
SendData("$Supports UserIP BotINFO|$Key " & Lock2Key & "|$ValidateNick " & UserStats.Username & "|")
Else
SendData("$Key " & Lock2Key & "|$ValidateNick " & UserStats.Username & "|")
End If
ProgressBar.Value = 2
Case Else
'Handle mainchat messages
If dataArray(i).StartsWith("<") And dataArray(i).IndexOf(">") < dataArray(i).IndexOf(" ") Then
ElseIf Not dataArray(i).StartsWith("$") And dataArray(i).Length > 0 Then
End If
End Select
Next
Catch e As Exception
'Something went bad, but we can probably stay online and hope for the best.
End Try
End Sub
Private Sub CheckMessage(ByVal text As String, ByVal type As Integer)
If UserStats.isOnline = -1 Then
Dim nick, data As String
If type = 1 Then
nick = text.Substring(text.IndexOf("<") + 1, text.IndexOf(">") - text.IndexOf("<") - 1)
ElseIf type = 2 Then
'$To: <name> From: <name> $<<name>> <message>|
nick = text.Substring(text.IndexOf("From: ") + 6, text.IndexOf("$", 1) - (text.IndexOf("From: ") + 7))
ChatTextPM("[PM] <-- [" & nick & "] " & text.Substring(text.IndexOf("<")))
End If
If text.Length > (text.IndexOf(">") + 2) Then data = text.Substring(text.IndexOf(">") + 2)
End If
End Sub
'Do stuff with incoming private messages
Private Sub ChatTextPM(ByVal text As String)
End Sub
'Do stuff with incoming chatmessages
Private Sub ChatText(ByVal text As String)
End Sub
Private Sub HubUsers(ByVal amount As Integer)
Me.StatusUsers.Text = CStr(CInt(Me.StatusUsers.Text) + amount)
End Sub
Public Function LockToKey(ByRef strLock As String, ByVal n As Long) As String
Dim h As Long
Dim ub As Long
Dim test As Long
'n = 5 for hub and client locks
h = strLock.IndexOf(" Pk=")
If h Then strLock = strLock.Substring(0, h)
'The lock only continues to the first space (Pk= comes after)
'Make sure it is more than 3 characters
If strLock.Length > 3 Then
ub = strLock.Length - 1
'The first character is handled differently from the others
'h = Asc(strLock) Xor Asc(strLock.Chars(ub)) Xor Asc(strLock.Chars(ub - 1)) Xor n
h = Asc(strLock.Chars(0)) Xor Asc(strLock.Chars(ub)) Xor Asc(strLock.Chars(ub - 1)) Xor n
h = ((h * 16) And 240) Or ((h \ 16) And 15)
'Equivalent of bit shifting four to the left (* 2^4) and four to the right (\ 2^4)
'Check for illegal characters
Select Case h
Case 0, 5, 36, 96, 124, 126
LockToKey = "/%DCN" & StrReverse(StrReverse("00" & h).Substring(0, 3)) & "%/"
'LockToKey = "/%DCN" & Right$("00" & h, 3) & "%/"
Case Else
LockToKey = Chr(h)
End Select
'Now the rest of the characaters in the lock are handled the same
For n = 1 To ub
h = Asc(strLock.Chars(n)) Xor Asc(strLock.Chars(n - 1))
h = ((h * 16) And 240) Or ((h \ 16) And 15)
Select Case h
Case 0, 5, 36, 96, 124, 126
LockToKey = LockToKey & "/%DCN" & StrReverse(StrReverse("00" & h).Substring(0, 3)) & "%/"
Case Else
LockToKey = LockToKey & Chr(h)
End Select
Next
Else
LockToKey = "Lock string length must be greater than 3 characters."
End If
Exit Function
End Function
Private Sub SendData(ByVal Data As String)
On Error Resume Next
Data.Replace("||", "|") 'Cleanup, just in case
If Not Data.EndsWith("|") Then Data = Data & "|"
Dim networkStream As NetworkStream = ClientStream
Dim sendBytes As [Byte]() = Encoding.Default.GetBytes(Data)
networkStream.Write(sendBytes, 0, sendBytes.Length)
networkStream.Flush()
End Sub
Private Sub DoRead(ByVal ar As IAsyncResult)
Dim intCount As Integer
Try
intCount = ClientStream.EndRead(ar)
If intCount < 1 Then
Disconnect()
Exit Sub
End If
ReadMessage = ReadMessage & Encoding.Default.GetString(ReadBuffer, 0, intCount)
If ReadMessage.EndsWith("|".ToCharArray) Then
Dim params() As Object = {ReadMessage}
Me.Invoke(New ProcessInvoker(AddressOf Me.ProcessData), params)
ReadMessage = ""
End If
ClientStream.BeginRead(ReadBuffer, 0, 1024, AddressOf DoRead, Nothing)
Catch e As System.ObjectDisposedException
'Don't know why these happen, but they're socket related.
'If you can fix 'em, please do. But no harms seems to come from hiding them
isConnectedFlag = False
Disconnect()
Catch e As System.IO.IOException
isConnectedFlag = False
Disconnect()
Catch e As Exception
isConnectedFlag = False
Disconnect()
End Try
End Sub
Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
txtip.SelectedIndex = txtip.SelectedIndex + 1
btnConnect.Enabled = False
Me.Timer.LockConnect = 2
RunTime.Start()
Disconnect()
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim arr() As String
arr = Split(txtip.SelectedItem, ":")
ind = arr(0)
porta = arr(1)
txtport.Text = porta
ore = 0
Connect(ind, porta)
End Sub
Private Sub txtshare_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtshare.TextChanged
If IsNumeric(txtshare.Text) Then
Dim size As Int64 = Convert.ToInt64(txtshare.Text)
size = Convert.ToInt64(Math.Floor(size / 1024 / 1024 / 1024))
lblShareSize.Text = size.ToString & " GB"
Else
txtshare.Text = "0"
lblShareSize.Text = "0 GB"
MessageBox.Show("Immettere uno share valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If chkConfirmExit.Checked Then
If MessageBox.Show("Are you sure you want to exit?", Me.Text, MessageBoxButtons.YesNo) = DialogResult.Yes Then
If isConnectedFlag Then Disconnect()
Else
e.Cancel = True
End If
Else
If isConnectedFlag Then Disconnect()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim comando1 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando1.gold")
comando1.WriteLine(cmd1.Text)
comando1.Close()
Dim descr As StreamWriter = New StreamWriter(Application.StartupPath & "\descrizione.gold")
descr.WriteLine(txtdesc.Text)
descr.Close()
Dim comando2 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando2.gold")
comando2.WriteLine(cmd2.Text)
comando2.Close()
Dim comando3 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando3.gold")
comando3.WriteLine(cmd3.Text)
comando3.Close()
Dim comando4 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando4.gold")
comando4.WriteLine(cmd4.Text)
comando4.Close()
Dim share3 As StreamWriter = New StreamWriter(Application.StartupPath & "\share.gold")
share3.WriteLine(txtshare.Text)
share3.Close()
Dim nick As StreamWriter = New StreamWriter(Application.StartupPath & "\nick.gold")
nick.WriteLine(txtuser.Text)
nick.Close()
Dim pass As StreamWriter = New StreamWriter(Application.StartupPath & "\passwd.gold")
pass.WriteLine(txtpass.Text)
pass.Close()
Dim email As StreamWriter = New StreamWriter(Application.StartupPath & "\email.gold")
email.WriteLine(txtemail.Text)
email.Close()
Dim uscita As StreamWriter = New StreamWriter(Application.StartupPath & "\confermachiusura.gold")
If chkConfirmExit.Checked = True Then
uscita.WriteLine("si")
uscita.Close()
Else
uscita.WriteLine("no")
uscita.Close()
End If
Dim riconnetti As StreamWriter = New StreamWriter(Application.StartupPath & "\autoriconnetti.gold")
riconnetti.WriteLine(nmrAutoreconnect.Text)
riconnetti.Close()
Dim speed As StreamWriter = New StreamWriter(Application.StartupPath & "\connessione.gold")
speed.WriteLine(cmbSpeed.Text)
speed.Close()
Dim percorso As String
percorso = Application.StartupPath & "\indirizzi.gold"
Dim i As Integer
FileOpen(1, percorso, OpenMode.Output)
For i = 0 To txtip.Items.Count - 1
PrintLine(1, txtip.Items(i) & Chr(13))
Next i
FileClose(1)
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then Button3.PerformClick()
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then Button3.PerformClick()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
txtip.Items.Add(TextBox1.Text & ":" & TextBox2.Text)
TextBox1.Clear()
TextBox2.Clear()
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
If txtip.Items.Count <= 2 Then
MessageBox.Show("Almeno 2 Hub in lista", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
txtip.Items.Remove(txtip.SelectedItem)
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer2.Enabled = False
btnConnect.PerformClick()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("1) Aggiungere alla lista hub almeno 2 hub altrimenti nn funziona 2)una volta inseriti tutti i dati (nick,share,i comandi da mandare in main etc.... Selezione il primo hub in alto della lista e premere su connetti, dopodichè lasciar fare tutto al programma Saluti da Gold ;) PS:Se il programma dovesse continuamente blokkarsi su un hub in particolare è molto probabile che si è stato o bannati o kikkati da quell'hub.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class
Public Class Main
Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1)
End Sub
End Class