zoukankan      html  css  js  c++  java
  • indy 封包转发

    type
      TMySuperMappedPortContext
    = Class(TIdMappedPortContext)
        public
         
    procedure DoEncode;
         
    procedure DoDecode;
      End;


    implementation

    {自定义加密函数}
    function EncodeData(Src: String): String;
    begin
      Result :
    = Src;
    end;

    {自定义解密函数}
    function DecodeData(Src: String): String;
    begin
      Result :
    = Src;
    end;


    {自定义加密接口}
    procedure TMySuperMappedPortContext.DoEncode;
    begin
      FNetData :
    = EncodeData(FNetData);
    end;

    {自定义解密接口}
    procedure TMySuperMappedPortContext.DoDecode;
    begin
      FNetData :
    = DecodeData(FNetData);
    end;

    {OnBeforeListenerRun事件}
    {替换相应的映射消息处理类型}
    procedure TForm1.IdMappedPortTCP1BeforeListenerRun(AThread: TIdThread);
    begin
      IdMappedPortTCP1.ContextClass :
    = TMySuperMappedPortContext;
    end;

    {OnExecute事件}
    {接收到须转发的数据,调用DoEncode进行"加密"}
    procedure TForm1.IdMappedPortTCP1Execute(AContext: TIdContext);
    begin
     
    if AContext is TMySuperMappedPortContext then begin
        TMySuperMappedPortContext(AContext).DoEncode;
     
    end;
    end;

    {OnOutboundData事件}
    {接收到须转发的数据,调用DoDecode进行"解密"}
    procedure TForm1.IdMappedPortTCP1OutboundData(AContext: TIdContext);
    begin
     
    if AContext is TMySuperMappedPortContext then begin
        TMySuperMappedPortContext(AContext).DoDecode;
     
    end;
    end;
  • 相关阅读:
    Centos7 ifconfig命令找不到
    request的各种方法
    linux开放端口
    easyui datagrid 部分参数
    设置tomcat内存
    tomcat做成系统服务
    Meta-analysis with complex research designs: dealing with dependence from multiple measures and multiple group comparisons
    多重校正
    DTI
    learning source archive
  • 原文地址:https://www.cnblogs.com/jxgxy/p/1401506.html
Copyright © 2011-2022 走看看