Jump to content
yshejia

For help, how can I use TIcsproxy?

Recommended Posts

I am using icsproxy component to proxy forward eth mining data. But I want to modify the data in the "icsproxydatasendtar" and "icsproxydatarecvtar" events and then forward it. How to operate? Can you give me a simple example?

Share this post


Link to post
1 hour ago, FPiette said:

Did you read the explanation that is in TIcsProxy source code ?

I read the comments in ticsprox and "targetbufxmit" and "sourcebufxmit", but I'm not sure how to deal with "dataptr: = @ ftarbuffer [0]". I even modified the source code of icsproxy, "procedure icsproxydatarecvtar (sender: tobject; proxyclient: tproxyclient; VAR dataptr: pointer; VAR datalen: integer);", Although I finally modified the data, I always felt that there was a simpler way.

Share this post


Link to post
Just now, yshejia said:

I read the comments in ticsprox and "targetbufxmit" and "sourcebufxmit", but I'm not sure how to deal with "dataptr: = @ ftarbuffer [0]". I even modified the source code of icsproxy, "procedure icsproxydatarecvtar (sender: tobject; proxyclient: tproxyclient; VAR dataptr: pointer; VAR datalen: integer);", Although I finally modified the data, I always felt that there was a simpler way.

================Here's how I use it====================

 

procedure TFrmMain.IcsProxyDataSendTar(Sender: TObject; ProxyClient: TProxyClient; var DataPtr: Pointer; var DataLen: Integer);
var
  CMDData: TBytes;
  CMDStr: string;
begin

  CMDData := TBytes(DataPtr);
  SetLength(CMDData, DataLen);
  CMDStr := TEncoding.Default.GetString(CMDData);

  //Here, I will modify the content of "cmdstr"

  CMDStr := ReplaceText(CMDStr, "A", "B");

 

  CMDData := TEncoding.Default.GetBytes(CMDStr);
  DataLen := Length(CMDData);
  DataPtr := @CMDData[0];

end;

============================================================

Share this post


Link to post

Please stop sending your comments as private messages as well, I do read this forum, when I'm in the office.

 

Why do you specifically want to use OnDataSendTar and OnDataRevcTar events, they are very low level.

 

If you want to modify headers and/or body, you should be using onHttpReqBody, onHttpRespBody, onHttpReqHdr, onHttpRespHdr, which have a simple String property you can update.  

 

If you change the body length, you map also need to change header fields.

 

Angus

 

Share this post


Link to post
32 minutes ago, Angus Robertson said:

Please stop sending your comments as private messages as well, I do read this forum, when I'm in the office.

 

Why do you specifically want to use OnDataSendTar and OnDataRevcTar events, they are very low level.

 

If you want to modify headers and/or body, you should be using onHttpReqBody, onHttpRespBody, onHttpReqHdr, onHttpRespHdr, which have a simple String property you can update.  

 

If you change the body length, you map also need to change header fields.

 

Angus

 

I use the "ticsproxy" component, not "ticshttpproxy", because the packets I want to process are TCP protocol, not HTTP protocol. I try to use ticshttpproxy, but I can't receive anything in httpreqbody, httprespbody, httpreqhdr and httpresphdr events

Share this post


Link to post
26 minutes ago, yshejia said:

because the packets I want to process are TCP protocol, not HTTP protocol.

For your information, HTTP is based on TCP as many other high level protocols such as FTP, SMTP, POP3 and more.

 

You are right that the HTTP proxy will only work for HTTP. Maybe you can have a look at it to understand how it works?

Or you have to study how TIcsProxy: you have full source code.

 

Share this post


Link to post

So there is no HTML and your questions are not really about our proxy, but just how to convert a binary buffer into a string, for which you can use IcsMoveTBytesToString and IcsMoveStringToTBytes which is what the proxy uses. 

 

Angus

 

Share this post


Link to post
On 1/19/2022 at 10:00 PM, Angus Robertson said:

So there is no HTML and your questions are not really about our proxy, but just how to convert a binary buffer into a string, for which you can use IcsMoveTBytesToString and IcsMoveStringToTBytes which is what the proxy uses. 

 

Angus

 

Thank you very much. I have done some wh on the basis of the source code

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×