From 187dfa33356d777b035a02caff353c6c9456521b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=89=E8=84=9A=E7=8B=90=E7=8B=B8?= Date: Sun, 22 Oct 2017 12:42:36 +0800 Subject: [PATCH] add Quiet parameter --- Class_ClientNode.pas | 35 ++++ Interface_op.pas | 6 + Main.dfm | 20 ++- Main.pas | 14 ++ PublicFun.pas | 12 +- kcptun_gclient.dproj | 399 +++++++++++++++++++++---------------------- kcptun_gclient.res | Bin 139012 -> 139012 bytes 7 files changed, 282 insertions(+), 204 deletions(-) diff --git a/Class_ClientNode.pas b/Class_ClientNode.pas index b18a793..fc8d1ac 100644 --- a/Class_ClientNode.pas +++ b/Class_ClientNode.pas @@ -46,6 +46,7 @@ TClientNode = class FisDSCP: Integer; FDSCP: string; FisAutoExpire: Integer; FAutoExpire: string; FisScavengeTTL: Integer; FScavengeTTL: string; + FisQuiet: Integer; FisMode: Integer; FMode: string; FisNoDelay: Integer; @@ -110,6 +111,8 @@ TClientNode = class procedure SetisScavengeTTL(const Value: Integer); procedure SetScavengeTTL(const Value: string); + procedure SetisQuiet(const Value: Integer); + procedure SetisMode(const Value: Integer); procedure SetMode(const Value: string); @@ -192,6 +195,8 @@ TClientNode = class property isScavengeTTL: Integer read FisScavengeTTL write SetisScavengeTTL; property ScavengeTTL: string read FScavengeTTL write SetScavengeTTL; + property isQuiet: Integer read FisQuiet write SetisQuiet; + //传输模式 property isMode: Integer read FisMode write SetisMode; property Mode: string read FMode write SetMode; @@ -266,6 +271,7 @@ procedure TClientNode.initPara; FisDSCP:= 0; FDSCP:= ''; FisAutoExpire:= 0; FAutoExpire:= ''; FisScavengeTTL:= 0; FScavengeTTL:= ''; + FisQuiet:= 0; FisMode:= 0; FMode:= ''; FisNoDelay:= 0; @@ -636,6 +642,16 @@ procedure TClientNode.SetScavengeTTL(const Value: string); FScavengeTTL:= Value; end; +procedure TClientNode.SetisQuiet(const Value: Integer); +begin + if FCanModifyXML then + begin + FXMLNode.ChildNodes.FindNode('quiet').Attributes['enable']:= Value; + FXMLDocument_Para.SaveToFile; + end; + FisQuiet:= Value; +end; + procedure TClientNode.SetisMode(const Value: Integer); begin if FCanModifyXML then @@ -832,6 +848,9 @@ function TClientNode.ReadFromXMLNode(XMLClientNode: IXMLNode): Integer; FisScavengeTTL:= StrToInt(VarToStr(DealNode.Attributes['enable']).Trim); FScavengeTTL:= VarToStr(DealNode.NodeValue).Trim; + DealNode:= XMLClientNode.ChildNodes.FindNode('quiet'); + FisQuiet:= StrToInt(VarToStr(DealNode.Attributes['enable']).Trim); + DealNode:= XMLClientNode.ChildNodes.FindNode('mode'); FisMode:= StrToInt(VarToStr(DealNode.Attributes['enable']).Trim); FMode:= VarToStr(DealNode.NodeValue).Trim; @@ -934,6 +953,9 @@ function TClientNode.WriteToXMLNode(XMLClientNode: IXMLNode): Integer; DealNode.Attributes['enable']:= FisScavengeTTL; DealNode.NodeValue:= FScavengeTTL; + DealNode:= XMLClientNode.AddChild('quiet'); + DealNode.Attributes['enable']:= FisQuiet; + DealNode:= XMLClientNode.AddChild('mode'); DealNode.Attributes['enable']:= FisMode; DealNode.NodeValue:= FMode; @@ -1043,6 +1065,8 @@ function TClientNode.CreateCMDLine(ClientEXEPathName: string): string; CMDLine:= CMDLine + ' -autoexpire ' + FAutoExpire; if (FisScavengeTTL <> 0) and (FScavengeTTL.Trim <> '') then CMDLine:= CMDLine + ' -scavengettl ' + FScavengeTTL; + if (FisQuiet <> 0) then + CMDLine:= CMDLine + ' -quiet'; //隐藏参数 if (FisACKNoDelay <> 0) then @@ -1121,6 +1145,11 @@ function TClientNode.CreateJSONConfig(): string; if (FisScavengeTTL <> 0) and (FScavengeTTL.Trim <> '') then JSONObject.AddPair(TJSONPair.Create('scavengettl', TJSONNumber.Create(FScavengeTTL.Trim))); + if (FisQuiet <> 0) then + JSONObject.AddPair(TJSONPair.Create('quiet', TJSONTrue.Create)) + else + JSONObject.AddPair(TJSONPair.Create('quiet', TJSONFalse.Create)); + if (FisMode <> 0) and (FMode.Trim <> '') then JSONObject.AddPair(TJSONPair.Create('mode', FMode.Trim)); JSONObject.AddPair(TJSONPair.Create('nodelay', TJSONNumber.Create(FisNoDelay))); @@ -1239,6 +1268,10 @@ function TClientNode.ReadFromJSONConfig(JSONStr: string): Integer; isScavengeTTL:= 1; ScavengeTTL:= IntegerValue.ToString; end; + if JSONObject.TryGetValue('quiet', BooleanValue) then + begin + isQuiet:= Integer(BooleanValue); + end; if JSONObject.TryGetValue('mode', StringValue) then begin @@ -1339,6 +1372,8 @@ function TClientNode.CreateQRCodeData(): string; if FisScavengeTTL <> 0 then ValueStr:= FScavengeTTL.Trim; QRData:= QRData + 'scavengettl=' + ValueStr + ';'; + QRData:= QRData + 'quiet=' + LowerCase(BoolToStr(Boolean(FisQuiet), True)) + ';'; + ValueStr:= ''; if FisMode <> 0 then ValueStr:= FMode.Trim; QRData:= QRData + 'mode=' + ValueStr + ';'; diff --git a/Interface_op.pas b/Interface_op.pas index eae4275..1245942 100644 --- a/Interface_op.pas +++ b/Interface_op.pas @@ -75,6 +75,7 @@ procedure Enable_DisableAllCheckbox(State: Boolean); CheckBox_DSCP.Enabled:= State; CheckBox_AutoExpire.Enabled:= State; CheckBox_ScavengeTTL.Enabled:= State; + CheckBox_Quiet.Enabled:= State; CheckBox_Mode.Enabled:= State; CheckBox_NoDelay.Enabled:= State; @@ -128,6 +129,7 @@ procedure Enable_DisableSelectPara(State: Boolean); CheckBox_DSCP.Enabled:= State; CheckBox_DSCPClick(FMain); CheckBox_AutoExpire.Enabled:= State; CheckBox_AutoExpireClick(FMain); CheckBox_ScavengeTTL.Enabled:= State; CheckBox_ScavengeTTLClick(FMain); + CheckBox_Quiet.Enabled:= State; CheckBox_QuietClick(FMain); end; end; @@ -170,6 +172,7 @@ procedure DisableAllInterfaceExceptJSON; Label_DSCP.Enabled:= False; Edit_DSCP.Enabled:= False; Edit_DSCP.Color:= clBtnFace; Label_AutoExpire.Enabled:= False; Edit_AutoExpire.Enabled:= False; Edit_AutoExpire.Color:= clBtnFace; Label_ScavengeTTL.Enabled:= False; Edit_ScavengeTTL.Enabled:= False; Edit_ScavengeTTL.Color:= clBtnFace; + Label_Quiet.Enabled:= False; Label_Mode.Enabled:= False; ComboBox_Mode.Enabled:= False; Label_NoDelay.Enabled:= False; @@ -268,6 +271,9 @@ procedure ShowClientInfoToInterface(ClientNode: TClientNode); Edit_ScavengeTTL.Text:= ClientNode.ScavengeTTL; CheckBox_ScavengeTTL.OnClick(FMain); + CheckBox_Quiet.Checked:= Boolean(ClientNode.isQuiet); + CheckBox_Quiet.OnClick(FMain); + //------------------------------------------------------------------------------------- ComboBox_Mode.ItemIndex:= ComboBox_Mode.Items.IndexOf(ClientNode.Mode); diff --git a/Main.dfm b/Main.dfm index e6c948c..a2268cd 100644 --- a/Main.dfm +++ b/Main.dfm @@ -111,7 +111,7 @@ object FMain: TFMain end item Alignment = taCenter - Text = 'KCPTun '#23458#25143#31471#31243#24207#35831#20351#29992' 20170218 '#25110#26356#39640#29256#26412 + Text = 'KCPTun '#23458#25143#31471#31243#24207#35831#20351#29992' 20171021 '#25110#26356#39640#29256#26412 Width = 50 end> OnMouseDown = StatusBar_StatusMouseDown @@ -477,6 +477,13 @@ object FMain: TFMain ParentShowHint = False ShowHint = True end + object Label_Quiet: TLabel + Left = 340 + Top = 181 + Width = 72 + Height = 12 + Caption = #21551#29992#38745#40664#27169#24335 + end object CheckBox_Key: TCheckBox Left = 10 Top = 24 @@ -534,6 +541,7 @@ object FMain: TFMain 'tea' 'xtea' 'xor' + 'sm4' 'none') end object CheckBox_Conn: TCheckBox @@ -761,6 +769,14 @@ object FMain: TFMain OnChange = Edit_ScavengeTTLChange OnKeyPress = Edit_ScavengeTTLKeyPress end + object CheckBox_Quiet: TCheckBox + Left = 315 + Top = 180 + Width = 17 + Height = 17 + TabOrder = 23 + OnClick = CheckBox_QuietClick + end end object GroupBox_Mode: TGroupBox Left = 480 @@ -1244,7 +1260,7 @@ object FMain: TFMain Left = 209 Top = 174 Bitmap = { - 494C010104001800500110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 494C010104001800540110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000002000000001002000000000000020 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 diff --git a/Main.pas b/Main.pas index ab7e97e..1f47a1b 100644 --- a/Main.pas +++ b/Main.pas @@ -127,6 +127,8 @@ TFMain = class(TForm) CheckBox_ScavengeTTL: TCheckBox; Label_ScavengeTTL: TLabel; Edit_ScavengeTTL: TEdit; + CheckBox_Quiet: TCheckBox; + Label_Quiet: TLabel; procedure Btn_AddNodeClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Btn_FindClientEXEClick(Sender: TObject); @@ -213,6 +215,7 @@ TFMain = class(TForm) procedure StatusBar_StatusMouseLeave(Sender: TObject); procedure StatusBar_StatusMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); + procedure CheckBox_QuietClick(Sender: TObject); private { Private declarations } function CreateQRCodeBitmap(QRData: string): TMemoryStream; @@ -898,6 +901,17 @@ procedure TFMain.CheckBox_ParityShardClick(Sender: TObject); LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data)); end; +procedure TFMain.CheckBox_QuietClick(Sender: TObject); +begin + Label_Quiet.Enabled:= CheckBox_Quiet.Checked; + if ListView_Node.Selected = nil then + Exit; + TClientNode(ListView_Node.Selected.Data).isQuiet:= Integer(CheckBox_Quiet.Checked); + + if PublicVar.CanModifyXML then + LoadQRCodeImage(TClientNode(ListView_Node.Selected.Data)); +end; + procedure TFMain.CheckBox_RcvWndClick(Sender: TObject); begin Label_RcvWnd.Enabled:= CheckBox_RcvWnd.Checked; diff --git a/PublicFun.pas b/PublicFun.pas index 955c9a2..131f1ee 100644 --- a/PublicFun.pas +++ b/PublicFun.pas @@ -44,12 +44,12 @@ procedure CreateBlankParaXML(ParaXMLPathName: string); end; end; -//实现-c参数,Node中加入json节点;加入自动重连节点;加入ScavengeTTL节点 +//实现-c参数,Node中加入json节点;加入自动重连节点;加入ScavengeTTL节点;加入Quiet节点 procedure RepairParaXML(ParaXMLPathName: string); var isModify: Boolean; XMLDocument_BlankPara: TXMLDocument; - ParasNode, ProgramParaNode, ClientNode, Node, LocalPortNode, JsonNode, AutoConnNode, ScavengeTTLNode: IXMLNode; + ParasNode, ProgramParaNode, ClientNode, Node, LocalPortNode, JsonNode, AutoConnNode, ScavengeTTLNode, QuietNode: IXMLNode; i: Integer; begin isModify:= False; @@ -102,6 +102,14 @@ procedure RepairParaXML(ParaXMLPathName: string); ScavengeTTLNode:= Node.AddChild('scavengettl'); ScavengeTTLNode.Attributes['enable']:= 0; end; + + QuietNode:= Node.ChildNodes.FindNode('quiet'); + if QuietNode = nil then + begin + isModify:= True; + QuietNode:= Node.AddChild('quiet'); + QuietNode.Attributes['enable']:= 0; + end; end; if isModify then XMLDocument_BlankPara.SaveToFile(ParaXMLPathName); diff --git a/kcptun_gclient.dproj b/kcptun_gclient.dproj index 9af3b30..acd7765 100644 --- a/kcptun_gclient.dproj +++ b/kcptun_gclient.dproj @@ -101,12 +101,12 @@ 0 - 2 + 3 1 res\k.ico true Debug - CompanyName=;FileVersion=1.1.2.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + CompanyName=;FileVersion=1.1.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) true 1033 @@ -150,10 +150,9 @@ kcptun_gclient.dpr - Microsoft Office XP Sample Automation Server Wrapper Components - Embarcadero C++Builder Office 2000 Servers Package - Embarcadero C++Builder Office XP Servers Package - Microsoft Office 2000 Sample Automation Server Wrapper Components + Embarcadero C++Builder Office 2000 Servers Package + Embarcadero C++Builder Office XP Servers Package + Microsoft Office 2000 Sample Automation Server Wrapper Components @@ -219,62 +218,64 @@ true - - - 0 - .dll;.bpl - - + + 1 - .dylib Contents\MacOS 1 - .dylib - - 1 - .dylib + + Contents\MacOS + 0 - + + + + classes 1 - .dylib - - - Contents\Resources + + + library\lib\armeabi-v7a 1 - + - classes + library\lib\armeabi 1 - - - Contents\MacOS - 0 - - + + + library\lib\mips 1 - - Contents\MacOS + + + + library\lib\armeabi-v7a 1 - - + + + res\drawable 1 - + + + + res\values 1 - + + + + res\drawable 1 @@ -284,345 +285,343 @@ 1 - + - library\lib\mips + res\drawable-ldpi 1 - - + + + res\drawable-mdpi 1 - + + + + res\drawable-hdpi 1 - - 0 + + + + res\drawable-xhdpi + 1 - + + + + res\drawable-small 1 - - Contents\MacOS + + + + res\drawable-normal 1 + + - library\lib\armeabi-v7a + res\drawable-large 1 - + + + + res\drawable-xlarge 1 - + + + 1 + + + Contents\MacOS + 1 + 0 + + Contents\MacOS 1 .framework - - - 1 - - - 1 + 0 - - + + 1 + .dylib 1 + .dylib - - 1 - - - 1 + .dylib - + + Contents\MacOS 1 + .dylib - - 1 + + 0 + .dll;.bpl - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + + 1 + .dylib - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + .dylib - - 1 + .dylib - + + Contents\MacOS 1 + .dylib - - 1 + + 0 + .bpl - - - 1 + + + 0 + + + 0 - 1 + 0 - - 1 + + 0 - - - - library\lib\armeabi - 1 + + Contents\Resources\StartUp\ + 0 - - 0 - + + + 1 - - Contents\MacOS + + 1 + + 1 - + 1 1 - + 1 - - - res\drawable-normal + + 1 - - - - res\drawable-xhdpi + 1 - - - - res\drawable-large + 1 - - + + 1 1 - + 1 - - - Assets + + 1 - - Assets + + 1 + + 1 - + + + 1 + - ..\ 1 - - ..\ + 1 - - - res\drawable-hdpi + + 1 - - - - library\lib\armeabi-v7a + 1 - - - - Contents + 1 - - - ..\ + + 1 - - - Assets + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - Assets + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - + + 1 1 + + + ..\ 1 - - - - res\values + + ..\ 1 - - - res\drawable-small + + 1 - - - - res\drawable + + 1 + + 1 - + 1 1 - + 1 - - + + + ..\ 1 - - - res\drawable + + + Contents 1 - - - 0 - - - 0 - + - Contents\Resources\StartUp\ - 0 - - - 0 - - - 0 - - - 0 + Contents\Resources + 1 - + library\lib\armeabi-v7a 1 - - - - 0 - .bpl + + 1 1 - .dylib - - Contents\MacOS + 1 - .dylib - + 1 - .dylib - + + Contents\MacOS 1 - .dylib + + + 0 - - - res\drawable-mdpi + + 1 - - - - res\drawable-xlarge + 1 - - - res\drawable-ldpi + + + Assets + 1 + + + Assets 1 - - + + + Assets 1 - + + Assets 1 diff --git a/kcptun_gclient.res b/kcptun_gclient.res index 0735a3da744f97a357779305ec129668d8748c8c..ad67ccfdf9b59b863268425a6204fafce0ff657c 100644 GIT binary patch delta 28 jcmZqK$I-HnV?r4t^ThH_M&o8i#&$+V#_f!ZOw4ishe!uc delta 28 jcmZqK$I-HnV?r4t)5P*lMx$m%#&$+V#_f!ZOw4ishbIS3