Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - Garbage Collector e classi
Forum - C# / VB.NET - Garbage Collector e classi - Pagina 4

Pagine: [ 1 2 3 4 ] Precedente | Prossimo
Avatar
Il Totem (Admin)
Guru^2


Messaggi: 3635
Iscritto: 24/01/2006

Segnala al moderatore
Postato alle 9:32
Venerdė, 12/06/2009
A patto che non siano chilometriche :rotfl:

PM Quote
Avatar
GoLDBeRG (Ex-Member)
Expert


Messaggi: 331
Iscritto: 19/12/2005

Segnala al moderatore
Postato alle 9:41
Venerdė, 12/06/2009
Codice sorgente - presumibilmente VB.NET

  1. Public Sub manda(ByRef us As user, ByVal data As String)
  2.         Try
  3.             data = data.Replace(Chr(10) & Chr(10), "").Replace("||", "")
  4.             If us.adc Then
  5.                 If data.EndsWith(Chr(10)) = False Then
  6.                     data &= Chr(10)
  7.                 End If
  8.             Else
  9.                 If data.EndsWith("|") = False Then
  10.                     data &= "|"
  11.                 End If
  12.             End If
  13.             IMPOSTAZIONI.banda += data.Length
  14.             protocol.byteinviati += data.Length
  15.             Dim buffer() As Byte
  16.             If us.adc Then
  17.                 buffer = Encoding.UTF8.GetBytes(data)
  18.             Else
  19.                 buffer = Encoding.Default.GetBytes(data)
  20.             End If
  21.             us.client.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, New AsyncCallback(AddressOf nulla), Nothing)
  22.         Catch
  23.         End Try
  24.     End Sub



Codice sorgente - presumibilmente VB.NET

  1. Public Sub send(ByRef us As user, ByVal data As String)
  2.         If us.falso Then Exit Sub
  3.         If IMPOSTAZIONI.arrayset(4) Then
  4.             If data.StartsWith("<" & IMPOSTAZIONI.bot & ">") = False And us.isop = False And data.StartsWith("$To:") = False Then
  5.                 data = data.Replace(vbCrLf, "")
  6.             End If
  7.         End If
  8.         If data(0) = "<" Then
  9.             If us.adc Then
  10.                 Dim copia As String = data
  11.                 copia = copia.Remove(0, 1)
  12.                 copia = copia.Substring(0, copia.IndexOf(" ")).Replace(">", "")
  13.                 Dim cod As String = chič(copia)
  14.                 data = data.Remove(0, 1)
  15.                 While Not (data(0) = ">")
  16.                     data = data.Remove(0, 1)
  17.                 End While
  18.                 data = data.Remove(0, 2)
  19.                 manda(us, "BMSG" & Chr(32) & cod & Chr(32) & data.Replace(" ", "\s"))
  20.             Else
  21.                 If IMPOSTAZIONI.arrayset(5) Then
  22.                     If data.StartsWith("<" & IMPOSTAZIONI.bot & ">") = False And us.isop = False Then
  23.                         Dim prima As String = data.Substring(data.IndexOf("<"), data.IndexOf(">") + 1)
  24.                         Dim frase As String = data.Substring(data.IndexOf(">") + 2, data.Length - data.IndexOf(">") - 2)
  25.                         frase = frase.ToLower
  26.                         manda(us, prima & " " & frase)
  27.                     Else
  28.                         manda(us, data)
  29.                     End If
  30.                 Else
  31.                     manda(us, data)
  32.                 End If
  33.             End If
  34.         Else
  35.             manda(us, data)
  36.         End If
  37.     End Sub



Codice sorgente - presumibilmente VB.NET

  1. Public Sub disconnettiuser(ByRef user As user)
  2.         On Error Resume Next
  3.         IMPOSTAZIONI.oplist.Remove(user)
  4.         IMPOSTAZIONI.vero.Remove(user)
  5.         IMPOSTAZIONI.users.Remove(user)
  6.         If user.cod <> "" Then
  7.             mandaatutti2adc("IQUI" & Chr(32) & user.cod, user)
  8.         End If
  9.         If user.nick <> "" Then
  10.             If user.nickadc = 0 Then
  11.                 If user.isop Then
  12.                     mandaoplistconthread()
  13.                 End If
  14.                 mandaatutti2("$Quit " & user.nick)
  15.                 If user.altronick <> "" Then
  16.                     mandaatutti2("$Quit " & user.altronick)
  17.                 End If
  18.             End If
  19.         End If
  20.  
  21.         user.client.Close()
  22.         user.cod = Nothing
  23.         user.id = Nothing
  24.         user.pd = Nothing
  25.         user.email = Nothing
  26.         user.descr = Nothing
  27.         user.binf = Nothing
  28.         user.altronick = Nothing
  29.         user.fraseparla = Nothing
  30.         user.inizialistato = Nothing
  31.         user.ip = Nothing
  32.         user.myinfo = Nothing
  33.         user.nick = Nothing
  34.         user.stato = Nothing
  35.         user.temp = Nothing
  36.         user.ultimomex = Nothing
  37.         user.ultimopvtachi = Nothing
  38.         user.modalita = Nothing
  39.         user.ReadBuffer = Nothing
  40.         user.client = Nothing
  41.         user.finale()
  42.         user = Nothing
  43.     End Sub



Codice sorgente - presumibilmente VB.NET

  1. Public Sub altricontrolli(ByVal comando As String, ByRef us As user)
  2.         If comando.Length < IMPOSTAZIONI.maxchatmex Then
  3.             If IMPOSTAZIONI.arrayset(22) Then
  4.                 If controllaseripetuto(us, comando) Then
  5.                     If us.avvertimenti = 3 Then
  6.                         mandabot("Sei Stato Droppato per Abuso della Main Chat", us)
  7.                         disconnettiuser(us)
  8.                         Exit Sub
  9.                     End If
  10.                     mandabot("Non ripetere 2 Volte la Stessa Cosa Per Favore - " & us.avvertimenti + 1 & "° Avvertimento", us)
  11.                     us.avvertimenti += 1
  12.                     Exit Sub
  13.                 End If
  14.             End If
  15.             If IMPOSTAZIONI.arrayset(7) Then
  16.                 If comando.StartsWith("$To:") = False Then
  17.                     Dim ora As Int64 = CType(Now.TimeOfDay.TotalSeconds, Long)
  18.                     Dim sottrazione As Integer = CInt(ora - us.ultimomexint)
  19.                     us.ultimomexint = CType(Now.TimeOfDay.TotalSeconds, Long)
  20.                     If sottrazione < protezione.main Then
  21.                         If us.avvertimenti = 3 Then
  22.                             mandabot("Sei Stato Droppato per Abuso della Main Chat", us)
  23.                             disconnettiuser(us)
  24.                             Exit Sub
  25.                         End If
  26.                         mandabot("Minimo Delay: " & protezione.main & " Secondi - " & us.avvertimenti + 1 & "° Avvertimento", us)
  27.                         us.avvertimenti += 1
  28.                         Exit Sub
  29.                     End If
  30.                     Dim controllo As String = comando.Replace("<" & us.nick & "> ", "")
  31.                     For Each lettera As String In controllo
  32.                         For a As Integer = 1 To 47
  33.                             If a <> 32 And a <> 33 And a <> 44 And a <> 34 And a <> 40 And a <> 41 And a <> 42 And a <> 45 And a <> 43 And a <> 46 And a <> 39 Then
  34.                                 If lettera = Chr(a) Then
  35.                                     mandabot("Hai Usato Caratteri non Ammessi [ " & lettera & " ]", us)
  36.                                     Exit Sub
  37.                                 End If
  38.                             End If
  39.                         Next
  40.                         For a As Integer = 58 To 64
  41.                             If a <> 61 And a <> 63 And a <> 58 And a <> 64 And a <> 59 Then
  42.                                 If lettera = Chr(a) Then
  43.                                     mandabot("Hai Usato Caratteri non Ammessi [ " & lettera & " ]", us)
  44.                                     Exit Sub
  45.                                 End If
  46.                             End If
  47.                         Next
  48.                         For a As Integer = 91 To 96
  49.                             If a <> 95 And a <> 94 And a <> 91 And a <> 93 Then
  50.                                 If lettera = Chr(a) Then
  51.                                     mandabot("Hai Usato Caratteri non Ammessi [ " & lettera & " ]", us)
  52.                                     Exit Sub
  53.                                 End If
  54.                             End If
  55.                         Next
  56.                         For a As Integer = 123 To 255
  57.                             If Chr(a) <> "č" And Chr(a) <> "ā" And Chr(a) <> "ō" And Chr(a) <> "ų" And Chr(a) <> "ė" Then
  58.                                 If lettera = Chr(a) Then
  59.                                     mandabot("Hai Usato Caratteri non Ammessi [ " & lettera & " ]", us)
  60.                                     Exit Sub
  61.                                 End If
  62.                             End If
  63.                         Next
  64.                     Next
  65.                     mandaconip(comando, us)
  66.                 Else
  67.                     controllatempopvt(comando, us)
  68.                 End If
  69.             Else
  70.                 If comando.StartsWith("$To:") Then
  71.                     controllatempopvt(comando, us)
  72.                 Else
  73.                     For Each a As user In IMPOSTAZIONI.users
  74.                         send(a, comando)
  75.                     Next
  76.                 End If
  77.             End If
  78.         Else
  79.             mandabot("Messaggio troppo lungo [Max: " & IMPOSTAZIONI.maxchatmex & "] Tu Hai Scritto per [" & comando.Length & "]", us)
  80.         End If
  81.     End Sub



Codice sorgente - presumibilmente VB.NET

  1. Public Sub mandaconip(ByVal comando As String, ByRef us As user)
  2.         If us.isop Then
  3.             If comando.StartsWith("<" & us.nick & "> is kicking ") Then
  4.                 mandaopchat(comando, us)
  5.             End If
  6.         End If
  7.  
  8.         If IMPOSTAZIONI.arrayset(20) Then
  9.             Dim frase As String = comando.Substring(comando.IndexOf(">") + 1, comando.Length - comando.IndexOf(">") - 1).Remove(0, 1)
  10.             Dim modi As String = "[" & us.ip & "]-<" & us.nick & "> " & frase
  11.             For Each a As user In IMPOSTAZIONI.users
  12.                 If a.isop = False Then
  13.                     send(a, comando)
  14.                 Else
  15.                     send(a, modi)
  16.                 End If
  17.             Next
  18.         Else
  19.             mandaatutti(comando, us)
  20.         End If
  21.     End Sub



Codice sorgente - presumibilmente VB.NET

  1. Public Sub mandaatutti(ByVal comando As String, ByRef us As user)
  2.         If us.isop = False And comando(0) = ("<") Then
  3.             If IMPOSTAZIONI.controllogenerale = IMPOSTAZIONI.maxmexsecondo Then
  4.                 IMPOSTAZIONI.maxchatmex = 0
  5.                 If IMPOSTAZIONI.hubinfo <> "Scovato Presunto Flood, La MainChat č stata Bloccata per Sicurezza" Then
  6.                     mandaopchat("Scovato Presunto Flood, La MainChat č stata Bloccata per Sicurezza", us)
  7.                 End If
  8.                 Exit Sub
  9.             Else
  10.                 IMPOSTAZIONI.controllogenerale += 1
  11.             End If
  12.         End If
  13.         If (comando.Length < 3 Or us.nicklist = False) Then Exit Sub
  14.         If (Now.TimeOfDay.TotalMilliseconds - us.timecontrol) < 100 Then
  15.             Exit Sub
  16.         End If
  17.         us.timecontrol = CLng(Now.TimeOfDay.TotalMilliseconds)
  18.         If IMPOSTAZIONI.tempmain.Count >= 30 Then
  19.             IMPOSTAZIONI.tempmain.RemoveAt(0)
  20.             IMPOSTAZIONI.tempmain.Add(comando)
  21.         Else
  22.             IMPOSTAZIONI.tempmain.Add(comando)
  23.         End If
  24.         comando = modifica(comando, us)
  25.         For Each a As user In IMPOSTAZIONI.users
  26.             If a.loggato = 1 Then
  27.                 send(a, comando)
  28.             End If
  29.         Next



Codice sorgente - presumibilmente VB.NET

  1. Public Class Connect
  2.     Public port As Integer
  3.     Public client As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  4.     Public Evento As New ManualResetEvent(False)
  5.     Public Delegate Sub arrivo(ByVal listener As user, ByVal copia As String)
  6.     Dim chiamata As New arrivo(AddressOf Form1.dataarrival)
  7.     Dim chiamata2 As New arrivo(AddressOf Form1.processdata)
  8.  
  9.     Public Function bannaipbassolivello(ByVal ip As String, ByRef client As Socket) As Boolean
  10.         If IMPOSTAZIONI.arraysyn.Contains(ip) Then
  11.             Dim c As New firewall
  12.             c.ip = ip
  13.             client.Close()
  14.             If IMPOSTAZIONI.sottoattacco Then
  15.                 c.manda = False
  16.             End If
  17.             c.banna()
  18.             protocol.connessionirifiutate += 1
  19.             Return True
  20.         Else
  21.             IMPOSTAZIONI.arraysyn.Add(ip)
  22.         End If
  23.         Return False
  24.     End Function
  25.  
  26.     Public Sub bannasub(ByVal ip As String, ByRef chi As Socket)
  27.         Dim c As New firewall
  28.         c.ip = ip
  29.         chi.Close()
  30.         If IMPOSTAZIONI.sottoattacco Then
  31.             c.manda = False
  32.         End If
  33.         c.banna()
  34.         protocol.connessionirifiutate += 1
  35.     End Sub
  36.  
  37.     Public Sub accetta(ByVal ar As IAsyncResult)
  38.         Evento.Set()
  39.         Try
  40.             Dim client As Socket = CType(ar.AsyncState, Socket).EndAccept(ar)
  41.             Dim ip As String
  42.             Try
  43.                 ip = CType(client.RemoteEndPoint, IPEndPoint).Address.ToString
  44.                 If (client.Available - 5) Mod 7 <> 0 And client.Available <> 0 Then
  45.                     IMPOSTAZIONI.accettaint += 1
  46.                     If IMPOSTAZIONI.arrayset(28) = False Then GoTo nulla
  47.                     If IMPOSTAZIONI.accettaint > protezione.spoofing Then
  48.                         If IMPOSTAZIONI.sottoattacco = False Then
  49.                             IMPOSTAZIONI.sottoattacco = True
  50.                             Dim b As New spoofing
  51.                             b.porta = port
  52.                             Dim thr As New Thread(AddressOf b.parti)
  53.                             thr.Start()
  54.                         End If
  55.                     End If
  56.                     bannasub(ip, client)
  57. nulla:
  58.                     Exit Sub
  59.                 Else
  60.                     If IMPOSTAZIONI.arrayset(29) Then
  61.                         If bannaipbassolivello(ip, client) Then
  62.                             Exit Sub
  63.                         End If
  64.                     End If
  65.  
  66.                     Dim us As New user
  67.                     us.ip = ip
  68.                     us.client = client
  69.  
  70.                     If IMPOSTAZIONI.banip Then
  71.                         If Form1.controllasebannato(ip, us) Then
  72.                             Form1.mandabot("Your IP Is Banned", us)
  73.                             protocol.connessionirifiutate += 1
  74.                             Form1.disconnettiuser(us)
  75.                             Exit Sub
  76.                         End If
  77.                     End If
  78.  
  79.                     If IMPOSTAZIONI.arrayset(3) Then
  80.                         If IMPOSTAZIONI.arrayprotected.Contains(us.ip) = False Then
  81.                             Dim arr As New ArrayList
  82.                             arr = IMPOSTAZIONI.users
  83.                             Dim conto As Integer
  84.                             For Each asd As user In arr
  85.                                 If asd.ip = us.ip Then
  86.                                     conto += 1
  87.                                 End If
  88.                             Next
  89.                             If conto > protezione.ip Then
  90.                                 Form1.mandabot("Il tuo IP č gia Presente in HUB", us)
  91.                                 Form1.altrobanip(us.ip)
  92.                                 Form1.mandaopchat("L'ip: " & us.ip & " č stato bannato, Double IP Control", us)
  93.                                 protocol.connessionirifiutate += 1
  94.                                 Form1.disconnettiuser(us)
  95.                                 Exit Sub
  96.                             End If
  97.                         End If
  98.                     End If
  99.  
  100.                     If IMPOSTAZIONI.arrayset(12) Then
  101.                         If IMPOSTAZIONI.arraysocks.Contains(us.ip) Then
  102.                             Form1.mandabot("Non č Permesso l'uso dei Socks", us)
  103.                             Form1.altrobanip(us.ip)
  104.                             Form1.mandaopchat("L'ip: " & us.ip & " č stato bannato, Socks", us)
  105.                             protocol.connessionirifiutate += 1
  106.                             Form1.disconnettiuser(us)
  107.                             Exit Sub
  108.                         End If
  109.                     End If
  110.  
  111.                     protocol.connessioniaccettate += 1
  112.                     us.cod = creacodice()
  113.  
  114.                     Form1.send(us, "$Lock EXTENDEDPROTOCOL::This_hub_was_written_by_TeNeBrA::CTRL[NoKey] Pk=Colossus|")
  115.                     Form1.send(us, "$Supports NoHello NoGetINFO UserIP2 BotINFO Feed MCTo|")
  116.                     us.client.BeginReceive(us.ReadBuffer, 0, us.ReadBuffer.Length, SocketFlags.None, New AsyncCallback(AddressOf ricevi), us)
  117.                 End If
  118.             Catch
  119.                 protocol.connessionirifiutate += 1
  120.                 client.Close()
  121.             End Try
  122.         Catch
  123.             protocol.connessionirifiutate += 1
  124.             client.Close()
  125.         End Try
  126.     End Sub
  127.  
  128.     Public Function creacodice() As String
  129. accapo: Randomize()
  130.         'da 65 a 90
  131.         Dim finale As String
  132.         For a As Integer = 0 To 3
  133. ancora:     Dim num As Integer = Math.Round(Rnd() * 90)
  134.             If num < 65 Then GoTo ancora
  135.             finale &= Chr(num)
  136.         Next
  137.         For Each controllo As user In IMPOSTAZIONI.users
  138.             If controllo.cod = finale Then GoTo accapo
  139.         Next
  140.         Return finale
  141.     End Function
  142.  
  143.     Public Sub ricevi(ByVal ar As IAsyncResult)
  144.         Dim listener As user = CType(ar.AsyncState, user)
  145.         Try
  146.             Dim bytesRead As Integer = listener.client.EndReceive(ar)
  147.             If bytesRead > 0 Then
  148.                 If listener.adc Then
  149.                     listener.temp &= Encoding.UTF8.GetString(listener.ReadBuffer, 0, bytesRead)
  150.                 Else
  151.                     listener.temp &= Encoding.Default.GetString(listener.ReadBuffer, 0, bytesRead)
  152.                 End If
  153.  
  154.                 If listener.temp.Contains("$MyNick") And listener.nick = "" Then
  155.                     protocol.connessionirifiutate += 1
  156.                     protocol.connessioniaccettate -= 1
  157.                     Form1.disconnettiuser(listener)
  158.                     IMPOSTAZIONI.accettaint += 1
  159.                     bannasub(listener.ip, listener.client)
  160.                     Exit Sub
  161.                 End If
  162.  
  163.                 If listener.temp.StartsWith("HSUP ") And listener.temp.EndsWith(Chr(10)) Then
  164.                     listener.adc = True
  165.                 End If
  166.  
  167.                 If listener.adc Then
  168.                     If listener.temp.EndsWith(Chr(10)) Then
  169.                         IMPOSTAZIONI.bandaricevuta += bytesRead
  170.                         protocol.bytericevuti += bytesRead
  171.                         Dim copia As String = listener.temp.Clone
  172.                         listener.temp = ""
  173.                         chiamata2.BeginInvoke(listener, copia, New AsyncCallback(AddressOf nulla), chiamata)
  174.                     End If
  175.                 Else
  176.                     If listener.temp.EndsWith("|") Then
  177.                         IMPOSTAZIONI.bandaricevuta += bytesRead
  178.                         protocol.bytericevuti += bytesRead
  179.                         Dim copia As String = listener.temp.Clone
  180.                         listener.temp = ""
  181.                         chiamata.BeginInvoke(listener, copia, New AsyncCallback(AddressOf nulla), chiamata)
  182.                     End If
  183.                 End If
  184.             Else
  185.                 Form1.disconnettiuser(listener)
  186.                 Exit Sub
  187.             End If
  188. prosegui:   Threading.Thread.Sleep(10)
  189.             listener.client.BeginReceive(listener.ReadBuffer, 0, listener.ReadBuffer.Length, SocketFlags.None, New AsyncCallback(AddressOf ricevi), listener)
  190.         Catch
  191.             Form1.disconnettiuser(listener)
  192.         End Try
  193.     End Sub
  194.  
  195.     Public Sub nulla()
  196.     End Sub
  197.  
  198.     Public Function parti() As Boolean
  199.         Try
  200.             client.Bind(New IPEndPoint(IPAddress.Parse(IMPOSTAZIONI.ipparse), port))
  201.             client.Listen(IMPOSTAZIONI.nmrsockets)
  202.             Dim thr As New Thread(AddressOf circola)
  203.             thr.Start()
  204.             Return True
  205.         Catch
  206.             Return False
  207.         End Try
  208.     End Function
  209.  
  210.     Public Sub circola()
  211.         On Error Resume Next
  212.         While (IMPOSTAZIONI.avviato)
  213.             Evento.Reset()
  214.             If Not IMPOSTAZIONI.avviato Then Exit While
  215.             If Not IMPOSTAZIONI.arrayporte.Contains(port.ToString) Then Exit While
  216.             client.BeginAccept(New AsyncCallback(AddressOf accetta), client)
  217.             Evento.WaitOne()
  218.         End While
  219.         client.Close()
  220.         Evento.Close()
  221.     End Sub
  222. End Class



ok l'errore č qui in mezzo... e sono 3 maledetti mesi che lo cerco... non č un errore di sintassi... č un errore di logica credo che fa schizzare la ram a 250 mb... dopo poche ore... qualcosa che non viene rimosso dal garbage collector nemmeno facendo gc.collect...

PM Quote
Avatar
ruggy94 (Member)
Guru


Messaggi: 890
Iscritto: 21/04/2008

Segnala al moderatore
Postato alle 11:17
Venerdė, 12/06/2009
Ehm...ma Totem aveva scritto qualcosa del genere o me lo sono immaginato io?
Testo quotato

Postato originariamente da Il Totem:
A patto che non siano chilometriche :rotfl:


:D
Ora me le leggo, ma credo che ci metterō un po', quindi non datemi per disperso :rotfl:

Ultima modifica effettuata da ruggy94 il 12/06/2009 alle 11:18
PM Quote
Avatar
GoLDBeRG (Ex-Member)
Expert


Messaggi: 331
Iscritto: 19/12/2005

Segnala al moderatore
Postato alle 14:56
Venerdė, 12/06/2009
dai non sono poi cosi lunghe... pensa solo che ce ne sono altre e 74 come queste... in 23 classi.... gia capire che l'errore č dentro queste procedure cio messo 2 mesi.... figurati a trovare l'errore......   :grr:

PM Quote
Pagine: [ 1 2 3 4 ] Precedente | Prossimo