[go: up one dir, main page]

Academia.eduAcademia.edu

Script delphi

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdTCPServer, IdMappedPortTCP, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; IdMappedPortTCP1: TIdMappedPortTCP; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure IdMappedPortTCP1Execute(AThread: TIdMappedPortThread); procedure TForm1.IdMappedPortTCP1OutboundConnect( AThread: TIdMappedPortThread; AException: Exception); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin IdMappedPortTCP1.Bindings.Add.Ip:='127.0.0.1'; IdMappedPortTCP1.Bindings.Add.Port:=StrToInt(Edit1.Text); IdMappedPortTCP1.MappedHost:=Edit2.Text; IdMappedPortTCP1.MappedPort:=StrToInt(Edit3.Text); IdMappedPortTCP1.Active:=True; Button1.Enabled:=False; Button2.Enabled:=True; end; procedure TForm1.Button2Click(Sender: TObject); begin IdMappedPortTCP1.Active:=False; IdMappedPortTCP1.Bindings.Clear; Button1.Enabled:=True; Button2.Enabled:=False; end; procedure TForm1.IdMappedPortTCP1Execute(AThread: TIdMappedPortThread); begin if (pos('CONNECT',athread.NetData)<>0) or (pos('GET',athread.NetData)<>0) or (pos('POST',athread.NetData)<>0) then Athread.NetData :=aThread.NetData+ 'GETS http://tselvideostore.vuclip.com/ HTTP/1.1'+#13#10+'Host: tselvideostore.vuclip.com'#13#10#13#10#13#10; end; procedure TForm1.IdMappedPortTCP1OutboundConnect( AThread: TIdMappedPortThread; AException: Exception); begin AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.1 402 Forbidden','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.0 402 Bad Request','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.1 402 Bad Request','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.0 402 Bad request','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.0 502 Gateway Timeout','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.1 502 Internal Server Error','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData,'HTTP/1.1 402 not authenticated','HTTP/1.1 200 OK', [rfReplaceAll]); AThread.NetData:=StringReplace(AThread.NetData, 'HTTP/1.1 100 Connection established', 'HTTP/1.0 200 Connection established',[rfReplaceAll]) end; end.