Skip to content

Commit

Permalink
bug fix:export json file
Browse files Browse the repository at this point in the history
  • Loading branch information
dfdragon committed Sep 8, 2016
1 parent b8cc78a commit 1cbdebf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
15 changes: 12 additions & 3 deletions Class_ClientNode.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1008,15 +1008,20 @@ function TClientNode.CreateJSONConfig(): string;
JSONObject:= TJSONObject.Create;
try
if (FLocalPort.Trim <> '') then
JSONObject.AddPair(TJSONPair.Create('localaddr', FLocalPort.Trim));
JSONObject.AddPair(TJSONPair.Create('localaddr', ':' + FLocalPort.Trim));
if (FKCPServerIP.Trim <> '') and (FKCPServerPort.Trim <> '') then
JSONObject.AddPair(TJSONPair.Create('remoteaddr', (FKCPServerIP.Trim + ':' + FKCPServerPort.Trim)));

if (FisKey <> 0) and (FKey.Trim <> '') then
JSONObject.AddPair(TJSONPair.Create('key', FKey.Trim));
if (FisCrypt <> 0) and (FCrypt.Trim <> '') then
JSONObject.AddPair(TJSONPair.Create('crypt', FCrypt.Trim));
JSONObject.AddPair(TJSONPair.Create('nocomp', LowerCase(BoolToStr(Boolean(FisNoComp), True))));

if (FisNoComp <> 0) then
JSONObject.AddPair(TJSONPair.Create('nocomp', TJSONTrue.Create))
else
JSONObject.AddPair(TJSONPair.Create('nocomp', TJSONFalse.Create));

if (FisDataShard <> 0) and (FDataShard.Trim <> '') then
JSONObject.AddPair(TJSONPair.Create('datashard', TJSONNumber.Create(FDataShard.Trim)));
if (FisParityShard <> 0) and (FParityShard.Trim <> '') then
Expand All @@ -1043,7 +1048,11 @@ function TClientNode.CreateJSONConfig(): string;
JSONObject.AddPair(TJSONPair.Create('resend', TJSONNumber.Create(FResend.Trim)));
JSONObject.AddPair(TJSONPair.Create('nc', TJSONNumber.Create(FisNC)));

JSONObject.AddPair(TJSONPair.Create('acknodelay', LowerCase(BoolToStr(Boolean(FisACKNoDelay), True))));
if (FisACKNoDelay <> 0) then
JSONObject.AddPair(TJSONPair.Create('acknodelay', TJSONTrue.Create))
else
JSONObject.AddPair(TJSONPair.Create('acknodelay', TJSONFalse.Create));

if (FisKeepAlive <> 0) and (FKeepAlive.Trim <> '') then
JSONObject.AddPair(TJSONPair.Create('keepalive', TJSONNumber.Create(FKeepAlive.Trim)));
if (FisSockBuf <> 0) and (FSockBuf.Trim <> '') then
Expand Down
4 changes: 3 additions & 1 deletion Main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ object FMain: TFMain
Left = 209
Top = 510
Bitmap = {
494C010104001800C00010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010104001800C80010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000002000000001002000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down Expand Up @@ -1458,6 +1458,8 @@ object FMain: TFMain
Top = 456
end
object SaveDialog_JSON: TSaveDialog
DefaultExt = 'json'
Filter = 'JSON'#37197#32622#25991#20214'|*.json'
Options = [ofOverwritePrompt, ofHideReadOnly, ofEnableSizing]
Left = 168
Top = 384
Expand Down
7 changes: 6 additions & 1 deletion Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1270,14 +1270,19 @@ procedure TFMain.Menu_ExitClick(Sender: TObject);
procedure TFMain.Menu_JSONClick(Sender: TObject);
var
ClientNode: TClientNode;
DefaultJSONFileName: string;
JSONStr: string;
JSONFile: TextFile;
isExcept: Boolean;
ErrorInfoStr, HintStr: string;
begin
ClientNode:= ListView_Node.Selected.Data;
DefaultJSONFileName:= ClientNode.KCPServerIP + '.' + ClientNode.KCPServerPort + '--' + ClientNode.LocalPort;
if (ClientNode.Remark.Trim <> '') then
DefaultJSONFileName:= ClientNode.Remark.Trim + '(' + DefaultJSONFileName + ')';
SaveDialog_JSON.FileName:= DefaultJSONFileName;
if not SaveDialog_JSON.Execute then
Exit;
ClientNode:= ListView_Node.Selected.Data;
JSONStr:= ClientNode.CreateJSONConfig();

isExcept:= False;
Expand Down
3 changes: 2 additions & 1 deletion kcptun_gclient.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ program kcptun_gclient;

uses
Vcl.Forms,
System.SysUtils,
Main in 'Main.pas' {FMain},
Class_ClientNode in 'Class_ClientNode.pas',
PublicVar in 'PublicVar.pas',
Expand All @@ -28,7 +29,7 @@ begin
Application.Title := 'KCPTun 客户端配置管理工具';
VerInfoRes:= TVerInfoRes.Create(Application.ExeName);
try
PublicVar.FileVer:= Copy(VerInfoRes.FileVersion, 1, 5);
PublicVar.FileVer:= Copy(VerInfoRes.FileVersion, 1, (LastDelimiter('.', (VerInfoRes.FileVersion)) - 1));
finally
VerInfoRes.Free;
end; //取EXE文件的版本信息
Expand Down
6 changes: 2 additions & 4 deletions kcptun_gclient.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
<DCC_DebugInformation>0</DCC_DebugInformation>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<VerInfo_Release>9</VerInfo_Release>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.9.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Release>10</VerInfo_Release>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.10.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Icon_MainIcon>k.ico</Icon_MainIcon>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
Expand All @@ -104,7 +104,6 @@
</DelphiCompile>
<DCCReference Include="Main.pas">
<Form>FMain</Form>
<FormType>dfm</FormType>
</DCCReference>
<DCCReference Include="Class_ClientNode.pas"/>
<DCCReference Include="PublicVar.pas"/>
Expand All @@ -120,7 +119,6 @@
<DCCReference Include="PublicFun.pas"/>
<DCCReference Include="Photo.pas">
<Form>FPhoto</Form>
<FormType>dfm</FormType>
</DCCReference>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
Expand Down
Binary file modified kcptun_gclient.res
Binary file not shown.

0 comments on commit 1cbdebf

Please sign in to comment.