diff --git a/nginxtool.lpi b/nginxtool.lpi index 20b72d5..0f9a7c8 100644 --- a/nginxtool.lpi +++ b/nginxtool.lpi @@ -15,7 +15,7 @@ - + diff --git a/nginxtool.res b/nginxtool.res index 9ba71ea..128fc2d 100644 Binary files a/nginxtool.res and b/nginxtool.res differ diff --git a/nginxtool_main.lfm b/nginxtool_main.lfm index 393a524..252074e 100644 --- a/nginxtool_main.lfm +++ b/nginxtool_main.lfm @@ -1,70 +1,105 @@ object FormNginxtool: TFormNginxtool - Left = 276 - Height = 330 + Left = 281 + Height = 340 Top = 140 - Width = 562 + Width = 557 BorderIcons = [biSystemMenu, biMinimize] Caption = 'nginx rtmp tool' - ClientHeight = 330 - ClientWidth = 562 + ClientHeight = 340 + ClientWidth = 557 OnCreate = FormCreate OnDestroy = FormDestroy OnShow = FormShow LCLVersion = '1.7' object Panel1: TPanel Left = 16 - Height = 261 - Top = 56 - Width = 532 + Height = 199 + Top = 128 + Width = 527 Anchors = [akTop, akLeft, akRight, akBottom] BevelOuter = bvLowered - TabOrder = 2 + TabOrder = 3 OnClick = Panel1Click end object Button1: TButton Left = 16 Height = 25 - Top = 24 + Top = 96 Width = 112 Caption = '&Start' OnClick = Button1Click - TabOrder = 0 + TabOrder = 1 end object Button2: TButton - Left = 184 + Left = 160 Height = 25 - Top = 24 + Top = 96 Width = 123 Caption = 'Sto&p' OnClick = Button2Click - TabOrder = 1 - end - object CheckBox1: TCheckBox - Left = 16 - Height = 19 - Top = 0 - Width = 140 - Caption = 'Above Normal Priority' - TabOrder = 3 + TabOrder = 2 end - object CheckBoxModConf: TCheckBox - Left = 184 - Height = 19 + object GroupBox1: TGroupBox + Left = 8 + Height = 81 Top = 0 - Width = 120 - Caption = 'Modify Config File' - TabOrder = 4 + Width = 536 + Anchors = [akTop, akLeft, akRight] + Caption = ' Option ' + ClientHeight = 64 + ClientWidth = 532 + TabOrder = 0 + object CheckBoxModConf: TCheckBox + Left = 178 + Height = 19 + Top = 4 + Width = 120 + Caption = 'Modify Config File' + TabOrder = 0 + end + object CheckBox1: TCheckBox + Left = 10 + Height = 19 + Top = 4 + Width = 140 + Caption = 'Above Normal Priority' + TabOrder = 1 + end + object Label1: TLabel + Left = 10 + Height = 12 + Top = 35 + Width = 73 + Caption = 'Chunk Size :' + ParentColor = False + end + object ComboBoxChunk: TComboBox + Left = 92 + Height = 23 + Top = 30 + Width = 68 + ItemHeight = 15 + ItemIndex = 1 + Items.Strings = ( + '4096' + '8192' + ) + OnCloseUp = ComboBoxChunkCloseUp + OnKeyPress = ComboBoxChunkKeyPress + TabOrder = 2 + Text = '8192' + end end object UniqueInstance1: TUniqueInstance Enabled = True - Left = 372 - Top = 20 + Left = 328 + Top = 88 end object Timer1: TTimer Enabled = False Interval = 500 OnTimer = Timer1Timer - Left = 432 - Top = 22 + Left = 376 + Top = 88 end end diff --git a/nginxtool_main.pas b/nginxtool_main.pas index c89e50f..4580287 100644 --- a/nginxtool_main.pas +++ b/nginxtool_main.pas @@ -17,12 +17,17 @@ TFormNginxtool = class(TForm) Button2: TButton; CheckBox1: TCheckBox; CheckBoxModConf: TCheckBox; + ComboBoxChunk: TComboBox; + GroupBox1: TGroupBox; + Label1: TLabel; Panel1: TPanel; Timer1: TTimer; UniqueInstance1: TUniqueInstance; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure CheckBoxModConfClick(Sender: TObject); + procedure ComboBoxChunkCloseUp(Sender: TObject); + procedure ComboBoxChunkKeyPress(Sender: TObject; var Key: char); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); @@ -201,7 +206,7 @@ procedure TFormNginxtool.Timer1Timer(Sender: TObject); procedure TFormNginxtool.VerboseNginxConfig; var - buf, bufrtmp : string; + buf, bufrtmp, schunksize : string; fs : TFileStream; bufsize, bufloc, bufpos, bufopen : Integer; rx, rxrtmp : TRegExpr; @@ -210,6 +215,11 @@ procedure TFormNginxtool.VerboseNginxConfig; has_autopush, chunk_modified : Boolean; begin chunk_modified:=False; + schunksize:=Trim(ComboBoxChunk.Text); + if StrToIntDef(schunksize,0)=0 then begin + schunksize:='4096'; + ComboBoxChunk.Text:=schunksize; + end; try // read config file fs := TFileStream.Create('conf/nginx.conf',fmOpenRead or fmShareDenyNone); @@ -276,8 +286,8 @@ procedure TFormNginxtool.VerboseNginxConfig; try rx.ModifierI:=True; if rx.Exec(buf) then begin - if StrToIntDef(rx.Match[1],0)<8192 then begin - buf:=Copy(buf,1,rx.MatchPos[1]-1)+'8192'+Copy(buf,rx.MatchPos[1]+rx.MatchLen[1]); + if StrToIntDef(rx.Match[1],0)<>0 then begin + buf:=Copy(buf,1,rx.MatchPos[1]-1)+schunksize+Copy(buf,rx.MatchPos[1]+rx.MatchLen[1]); chunk_modified:=True; end; end else begin @@ -285,7 +295,7 @@ procedure TFormNginxtool.VerboseNginxConfig; try rxrtmp.ModifierI:=True; if rxrtmp.Exec(buf) then begin - buf:=Copy(buf,1,rxrtmp.MatchPos[0]+rxrtmp.MatchLen[0]-1)+#10#9#9'chunk_size 8192;'#10+ + buf:=Copy(buf,1,rxrtmp.MatchPos[0]+rxrtmp.MatchLen[0]-1)+#10#9#9'chunk_size '+schunksize+';'#10+ Copy(buf,rxrtmp.MatchPos[0]+rxrtmp.MatchLen[0]); chunk_modified:=True; end; @@ -368,7 +378,7 @@ procedure TFormNginxtool.FormCreate(Sender: TObject); procedure TFormNginxtool.FormDestroy(Sender: TObject); var fs : TFileStream; - s : string; + s,schunk : string; i : Integer; begin s:='00'; @@ -376,6 +386,7 @@ procedure TFormNginxtool.FormDestroy(Sender: TObject); s[1]:='1'; if CheckBoxModConf.Checked then s[2]:='1'; + s:=s+ComboBoxChunk.Text; if checkflag<>s then begin try fs:=TFileStream.Create('nginxtool.ini',fmOpenWrite or fmCreate or fmShareDenyNone); @@ -472,28 +483,49 @@ procedure TFormNginxtool.CheckBoxModConfClick(Sender: TObject); VerboseNginxConfig; end; +procedure TFormNginxtool.ComboBoxChunkCloseUp(Sender: TObject); +begin + CheckBoxModConfClick(nil); +end; + +procedure TFormNginxtool.ComboBoxChunkKeyPress(Sender: TObject; var Key: char); +begin + if Key=#13 then begin + Key:=#0; + CheckBoxModConfClick(nil); + end; +end; + function ReadINIFile(idx:Integer):Boolean; var fs : TFileStream; s : string; + bsize : Integer; begin - s:='01'; + s:='018192'; if idx>Length(s) then idx:=Length(s); if checkflag='' then begin try fs:=TFileStream.Create('nginxtool.ini',fmOpenRead or fmShareDenyNone); try + bsize:=fs.Size; + if bsize>8 then + bsize:=8; + SetLength(s,bsize); fs.Read(s[1],Length(s)); finally fs.Free; end; except - s:='01'; + s:='018192'; end; checkflag:=s; end; - Result:=checkflag[idx]='1'; + if idx<3 then + Result:=checkflag[idx]='1' + else + Result:=False; end; @@ -505,6 +537,7 @@ procedure TFormNginxtool.FormShow(Sender: TObject); loglist.AddLog(Format('> IP Address: %s',[IPBuf])); CheckBox1.Checked:=ReadINIFile(1); CheckBoxModConf.Checked:=ReadINIFile(2); + ComboBoxChunk.Text:=Copy(checkflag,3); CheckBoxModConf.OnClick:=@CheckBoxModConfClick; VerboseNginxConfig; end;