projettn
Messages postés4Date d'inscriptionmercredi 11 octobre 2006StatutMembreDernière intervention22 janvier 2007
-
20 déc. 2006 à 00:19
jrivet
Messages postés7392Date d'inscriptionmercredi 23 avril 2003StatutMembreDernière intervention 6 avril 2012
-
20 déc. 2006 à 09:01
slt a tout, nous somme des etudiant qui font notre projet.
nous a eux un code et nous somme besoin de le comprendre, ce code ce base sur uhn notion client serveur
le code de client
-------------------------------------------------------------------------------------
Public parOk As Boolean
Public port As String
Public Buf As String
Private Sub Internet_Close()
If Internet.Tag = "c" Then Exit Sub
Internet.Tag = "c"
Timer1.Enabled = True
End Sub
Private Sub Internet_Connect()
If Internet.Tag = "a" Then Exit Sub
Timer1.Enabled = False
Internet.Tag = "a"
Internet.SendData Buf & vbCrLf & vbCrLf
End Sub
Private Sub Internet_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Internet.GetData data, vbString, bytesTotal
If Locale.State <> 7 Then Exit Sub
Locale.SendData data
End Sub
Private Sub Internet_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Erreur de Connection"
End Sub
Private Sub Locale_Close()
If Locale.Tag = "c" Then Exit Sub
Locale.Tag = "c"
base.dire "Déconnnexion de " & Locale.RemoteHostIP
Timer1.Enabled = True
End Sub
Private Sub Locale_Connect()
If Locale.Tag = "c" Then Exit Sub
timeOUT.Enabled = False
Timer1.Enabled = False
Locale.Tag = "c"
End Sub
Private Sub Locale_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim data As String, col, col2, col3, post As String
Locale.GetData data, vbString, bytesTotal
Set par = New HTTPParams
col = Split(data, Chr(13) + Chr(10) & Chr(13) + Chr(10), 2)If UBound(col) 1 Then post col(1)
col = Split(col(0), Chr(13) + Chr(10))
If UBound(col) = 0 Then Exit Sub
col3 = Split(col(0), " ", 3)
If UBound(col3) > 1 Then
base.dire "Téléchargement de " & col3(1)
End If
For i = 1 To UBound(col)
col2 = Split(col(i), ": ", 2)If col2(0) "Host" Then Host col3(1): Exit For ': GoTo boucle
Next
If Host = "" Then Exit Sub
Buf = data
If base.secprox.Value = 0 Then
Host = FindHost(Host)
port = FindPort(Host)
Internet.Connect Host, port
Else
Internet.Connect base.secproxaddr.Text, base.secproxport.Text
End If
End Sub
Private Function FindPort(str) As String
Dim col, col2
str = LCase$(str)
str = Replace(str, "http://", "", , 1)
col = Split(str, "/")
col2 = Split(col(0), ":", 1)If UBound(col2) 0 Then FindPort 80 Else: FindPort = col2(1)
End Function
Private Function FindHost(str) As String
str = LCase$(str)
str = Replace(str, "http://", "", , 1)
Dim col
col = Split(str, "/")
str = col(0)
FindHost = str
End Function
Private Sub timeOUT_Timer()
Internet.Close
Locale.Close
End Sub
Private Sub Timer1_Timer()
Unload Me
End Sub
>>>>>>avec internet et locale se sont deux winsock et timeout et timer1 se sont deux timer
------------------------------------------------------
le code de serveur
-----------------------------------------------
Public Event QuelqueChose(Code As Integer)
Dim journal, jj1 As String
Sub dire(quoi)
jj1 = jj1 & Now & ": " & quoi
log.Text = log.Text & Now & ":" & vbCrLf & quoi & vbCrLf & vbCrLf
log.SelStart = Len(log.Text)
End Sub
Private Sub Command1_Click()
tb3.Index = "jou"
tb3.Seek "=", Format(Date, "dd/MM/YYYY")
If tb3.NoMatch Then
tb3.AddNew
tb3.Fields("dat") = Format(Date, "dd/MM/YYYY")
tb3.Fields("jj") = jj1
tb3.Update
Else
tb3.Edit
tb3.Fields("dat") = Format(Date, "dd/MM/YYYY")
Dim ss As String
ss = tb3.Fields("jj")
tb3.Fields("jj") = ss + jj1
tb3.Update
End If
Dim fff As Long
fff = FreeFile
Open "c:\proxy\log" + Format(Date, "ddmmyyyy") + ".log" For Append As fff
Write #fff, log.Text
Close #fff
log.Text = ""
End Sub
Private Sub Form_Load()
secprox.Value = 0
secprox_Click
okprox_Click
On Error Resume Next
tb2.MoveFirst
Do While tb2.EOF = False
proxaddr.AddItem tb2.Fields("ip")
tb2.MoveNext
Loop
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub
Private Sub log_Change()
journal = journal + log.Text
End Sub
Private Sub okprox_Click()
If okprox.Value = 1 Then
proxec.LocalPort = proxport.Text
proxec.Listen
dire "Démarrage du proxy : port " & proxport.Text
jj1 = jj1 + proxport.Text
Else
dire "Arrêt du proxy"
jj1 = jj1 + "Arrêt du proxy"
proxec.Close
RaiseEvent QuelqueChose(0)
End If
End Sub
Private Sub Proxadd_Click()
Dim col, mess As String, str As String, total As String
mess = InputBox("Quel est le style ou une adresse du réseau sécuritaire?" & vbCrLf & "Exemple : 192.168.0.xxx/127.0.0.1/192.168.xxx.xxx", , "192.168.0.xxx")
col = Split(mess, ".")
If UBound(col) <> 3 Then Exit Sub
For i = 0 To UBound(col)
str = col(i)
If Len(str) > 3 Then Exit Sub
If LCase$(str) = "xxx" Then
mess = MsgBox("entrée une adresse variable") & vbCritical
total = total & LCase$(str) & "."
GoTo suitecheck
End If
If str > 255 Or str < 0 Or IsNumeric(str) = False Then Exit Sub
total = total & str & "."
suitecheck:
Next
total = Left(total, Len(total) - 1)
For i = 0 To proxaddr.ListCount - 1
If total = proxaddr.List(i) Then Exit Sub
Next
proxaddr.AddItem total
End Sub
Private Sub ProxEc_ConnectionRequest(ByVal requestID As Long)
Dim col, Ok As Boolean, str As String, col2, ip As String
dire "Demande de connexion de " & proxec.RemoteHostIP
ip = proxec.RemoteHostIP
col = Split(ip, ".")
For i = 0 To proxaddr.ListCount - 1
Ok = True
col2 = Split(proxaddr.List(i), ".")
For j = 0 To UBound(col)
If col2(j) <> "xxx" And col(j) <> col2(j) Then Ok = False
Next
If Ok = True Then GoTo suiteacc
Next
suiteacc:
If Ok = False Then: dire "Refus de la connexion avec " & proxec.RemoteHostIP: Exit Sub
dire "Connexion avec " & proxec.RemoteHostIP & " acceptée"
Dim cli As New client
Set cli = New client
cli.Locale.Accept (requestID)
End Sub
Private Sub secprox_Click()
If secprox.Value = 1 Then
secproxaddr.Enabled = True
secproxport.Enabled = True
Else
secproxaddr.Enabled = False
secproxport.Enabled = False
End If
End Sub
>>>>> avec proxec est un winsock et timer1 est un timer en ce pose sur ce code sur la notion de connexion seulement
------------------
et merci en avance pour vos aide
coordination