Skip to content

Commit 44df065

Browse files
committed
Allow to connect to non-standard ssh port
1 parent 5b05687 commit 44df065

File tree

4 files changed

+79
-46
lines changed

4 files changed

+79
-46
lines changed

pu_main.lfm

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ object f_main: Tf_main
55
Width = 390
66
ActiveControl = StringGrid1
77
Caption = 'INDI server'
8-
ClientHeight = 369
8+
ClientHeight = 339
99
ClientWidth = 390
1010
Menu = MainMenu1
1111
OnClose = FormClose
1212
OnCreate = FormCreate
1313
OnDestroy = FormDestroy
1414
object StringGrid1: TStringGrid
1515
Left = 0
16-
Height = 252
16+
Height = 222
1717
Top = 0
1818
Width = 390
1919
Align = alClient
@@ -45,7 +45,7 @@ object f_main: Tf_main
4545
object Panel1: TPanel
4646
Left = 0
4747
Height = 117
48-
Top = 252
48+
Top = 222
4949
Width = 390
5050
Align = alBottom
5151
ClientHeight = 117
@@ -101,7 +101,7 @@ object f_main: Tf_main
101101
end
102102
object ConfigLabel: TLabel
103103
Left = 99
104-
Height = 19
104+
Height = 18
105105
Top = 7
106106
Width = 73
107107
Caption = 'ConfigLabel'

pu_main.pas

+15-9
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Tf_main = class(TForm)
9999
TunnelProcess: TProcess;
100100
rc,config: TXMLConfig;
101101
ConfigDir,configfile,devlist,serveroptions,serverlog: string;
102-
RemoteHost,RemoteUser,LocalPort,RemotePort,sshopt: string;
102+
RemoteHost,RemoteSshPort,RemoteUser,LocalPort,RemotePort,sshopt: string;
103103
autostart,stayontop,remote,ServerStarted: boolean;
104104
GUIready: boolean;
105105
ServerFifo: string;
@@ -172,6 +172,7 @@ procedure Tf_main.FormCreate(Sender: TObject);
172172
serverlog:='';
173173
remote:=false;
174174
RemoteHost:='';
175+
RemoteSshPort:='22';
175176
RemoteUser:='';
176177
LocalPort:='7624';
177178
RemotePort:='7624';
@@ -321,6 +322,7 @@ procedure Tf_main.LoadConfig(cname:string);
321322
serverlog:=config.GetValue('/Server/Log','');
322323
remote:=config.GetValue('/Server/Remote',remote);
323324
RemoteHost:=config.GetValue('/RemoteServer/Host',RemoteHost);
325+
RemoteSshPort:=config.GetValue('/RemoteServer/SshPort','22');
324326
RemoteUser:=config.GetValue('/RemoteServer/User',RemoteUser);
325327
LocalPort:=config.GetValue('/RemoteServer/LocalPort',LocalPort);
326328
RemotePort:=config.GetValue('/RemoteServer/RemotePort',RemotePort);
@@ -358,6 +360,7 @@ procedure Tf_main.SaveConfig;
358360
config.SetValue('/Server/Log',serverlog);
359361
config.SetValue('/Server/Remote',remote);
360362
config.SetValue('/RemoteServer/Host',RemoteHost);
363+
config.SetValue('/RemoteServer/SshPort',RemoteSshPort);
361364
config.SetValue('/RemoteServer/User',RemoteUser);
362365
config.SetValue('/RemoteServer/LocalPort',LocalPort);
363366
config.SetValue('/RemoteServer/RemotePort',RemotePort);
@@ -454,6 +457,7 @@ procedure Tf_main.MenuSetupClick(Sender: TObject);
454457
f_setup.stayontop.Checked:=stayontop;
455458
f_setup.remote.Checked:=remote;
456459
f_setup.remotehost.Text:=RemoteHost;
460+
f_setup.sshport.Text:=RemoteSshPort;
457461
f_setup.remoteuser.Text:=RemoteUser;
458462
f_setup.localport.Text:=LocalPort;
459463
f_setup.remoteport.Text:=RemotePort;
@@ -471,6 +475,7 @@ procedure Tf_main.MenuSetupClick(Sender: TObject);
471475
GSCdir := f_setup.gscpath.Directory;
472476
remote := f_setup.remote.Checked;
473477
RemoteHost := f_setup.remotehost.Text;
478+
RemoteSshPort := f_setup.sshport.Text;
474479
RemoteUser := f_setup.remoteuser.Text;
475480
LocalPort := f_setup.localport.Text;
476481
RemotePort := f_setup.remoteport.Text;
@@ -497,6 +502,7 @@ procedure Tf_main.SetupConfigChange(Sender: TObject);
497502
f_setup.stayontop.Checked:=stayontop;
498503
f_setup.remote.Checked:=remote;
499504
f_setup.remotehost.Text:=RemoteHost;
505+
f_setup.sshport.Text:=RemoteSshPort;
500506
f_setup.remoteuser.Text:=RemoteUser;
501507
f_setup.localport.Text:=LocalPort;
502508
f_setup.remoteport.Text:=RemotePort;
@@ -816,7 +822,7 @@ function Tf_main.WriteCmd(cmd:string): boolean;
816822
if ServerPid<>'' then begin
817823
if remote then begin
818824
str:=TStringList.Create;
819-
ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' echo '+cmd+'>'+ServerFifo,str);
825+
ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' echo '+cmd+'>'+ServerFifo,str);
820826
result:=true;
821827
str.Free;
822828
end
@@ -846,9 +852,9 @@ procedure Tf_main.StartServer;
846852
if ServerPid='' then begin
847853
str:=TStringList.Create;
848854
if remote then begin
849-
ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' rm '+ServerFifo,str);
850-
if ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' mkfifo '+ServerFifo,str)<>0 then begin ShowErr(RemoteUser+'@'+RemoteHost+' mkfifo '+ServerFifo,str);exit;end;
851-
if ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' "sh -c ''nohup indiserver '+serveroptions+' -f '+ServerFifo+' >/dev/null 2>&1 &''"',str)<>0 then begin ShowErr(RemoteUser+'@'+RemoteHost+' indiserver',str);exit;end;
855+
ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' rm '+ServerFifo,str);
856+
if ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' mkfifo '+ServerFifo,str)<>0 then begin ShowErr(RemoteUser+'@'+RemoteHost+' mkfifo '+ServerFifo,str);exit;end;
857+
if ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' "sh -c ''nohup indiserver '+serveroptions+' -f '+ServerFifo+' >/dev/null 2>&1 &''"',str)<>0 then begin ShowErr(RemoteUser+'@'+RemoteHost+' indiserver',str);exit;end;
852858
Wait(5);
853859
ServerStarted:=true;
854860
if StringGrid1.RowCount>1 then begin
@@ -912,8 +918,8 @@ procedure Tf_main.StopServer;
912918
str:=TStringList.Create;
913919
if remote then begin
914920
StopTunnel;
915-
ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' killall indiserver ',str);
916-
ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' rm '+ServerFifo,str);
921+
ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' killall indiserver ',str);
922+
ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' rm '+ServerFifo,str);
917923
end
918924
else begin
919925
ExecProcess('killall indiserver',str);
@@ -941,7 +947,7 @@ procedure Tf_main.StopServer;
941947
procedure Tf_main.StartTunnel;
942948
begin
943949
if remote then begin
944-
TunnelProcess:=ExecProcessNoWait('ssh '+sshopt+' -N -L'+LocalPort+':'+RemoteHost+':'+RemotePort+' '+RemoteUser+'@'+RemoteHost);
950+
TunnelProcess:=ExecProcessNoWait('ssh '+sshopt+' -p '+RemoteSshPort+' '+' -N -L'+LocalPort+':'+RemoteHost+':'+RemotePort+' '+RemoteUser+'@'+RemoteHost);
945951
Wait(5);
946952
end;
947953
end;
@@ -968,7 +974,7 @@ function Tf_main.ServerPid: string;
968974
repeat
969975
try
970976
if remote then begin
971-
i:=ExecProcess('ssh '+sshopt+RemoteUser+'@'+RemoteHost+' pgrep indiserver',str);
977+
i:=ExecProcess('ssh '+sshopt+' -p '+RemoteSshPort+' '+RemoteUser+'@'+RemoteHost+' pgrep indiserver',str);
972978
end
973979
else begin
974980
i:=ExecProcess('pgrep indiserver',str);

pu_setup.lfm

+58-33
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,36 @@ object f_setup: Tf_setup
5656
Visible = False
5757
object remotehost: TEdit
5858
Left = 8
59-
Height = 30
59+
Height = 32
6060
Top = 24
61-
Width = 201
61+
Width = 152
6262
ParentFont = False
6363
TabOrder = 0
6464
end
6565
object remoteuser: TEdit
6666
Left = 228
67-
Height = 30
67+
Height = 32
6868
Top = 24
6969
Width = 80
7070
ParentFont = False
7171
TabOrder = 1
7272
end
7373
object Label3: TLabel
7474
Left = 8
75-
Height = 19
75+
Height = 18
7676
Top = 4
77-
Width = 117
77+
Width = 116
7878
Caption = 'Remote host name'
79+
ParentColor = False
7980
ParentFont = False
8081
end
8182
object Label4: TLabel
8283
Left = 228
83-
Height = 19
84+
Height = 18
8485
Top = 4
85-
Width = 68
86+
Width = 67
8687
Caption = 'User name'
88+
ParentColor = False
8789
ParentFont = False
8890
end
8991
object Label5: TLabel
@@ -93,41 +95,59 @@ object f_setup: Tf_setup
9395
Width = 300
9496
AutoSize = False
9597
Caption = 'You must configure ssh key-based authentication for username on hostname.'
98+
ParentColor = False
9699
ParentFont = False
97100
WordWrap = True
98101
end
99102
object localport: TEdit
100103
Left = 88
101-
Height = 30
104+
Height = 32
102105
Top = 64
103106
Width = 54
104107
ParentFont = False
105108
TabOrder = 2
106109
end
107110
object remoteport: TEdit
108111
Left = 254
109-
Height = 30
112+
Height = 32
110113
Top = 64
111114
Width = 54
112115
ParentFont = False
113116
TabOrder = 3
114117
end
115118
object Label6: TLabel
116119
Left = 8
117-
Height = 19
120+
Height = 18
118121
Top = 68
119122
Width = 61
120123
Caption = 'Local port'
124+
ParentColor = False
121125
ParentFont = False
122126
end
123127
object Label7: TLabel
124128
Left = 160
125-
Height = 19
129+
Height = 18
126130
Top = 68
127-
Width = 79
131+
Width = 77
128132
Caption = 'Remote port'
133+
ParentColor = False
129134
ParentFont = False
130135
end
136+
object sshport: TEdit
137+
Left = 163
138+
Height = 32
139+
Top = 24
140+
Width = 60
141+
TabOrder = 4
142+
end
143+
object Label11: TLabel
144+
Left = 163
145+
Height = 18
146+
Top = 4
147+
Width = 50
148+
Caption = 'ssh port'
149+
ParentColor = False
150+
end
131151
end
132152
object Panel1: TPanel
133153
Left = 0
@@ -141,26 +161,27 @@ object f_setup: Tf_setup
141161
TabOrder = 2
142162
object remote: TCheckBox
143163
Left = 8
144-
Height = 21
164+
Height = 22
145165
Top = 299
146-
Width = 262
166+
Width = 264
147167
Caption = 'Start indiserver on a remote computer'
148168
OnClick = remoteClick
149169
ParentFont = False
150170
TabOrder = 0
151171
end
152172
object Label2: TLabel
153173
Left = 13
154-
Height = 19
174+
Height = 18
155175
Top = 121
156-
Width = 159
176+
Width = 157
157177
Caption = 'Additional server options:'
178+
ParentColor = False
158179
ParentFont = False
159180
ParentShowHint = False
160181
end
161182
object serveroptions: TEdit
162183
Left = 8
163-
Height = 30
184+
Height = 32
164185
Hint = 'Do not add driver here, and do not use the -f option!'#10'Valid options:'#10' -l d : log driver messages to <d>/YYYY-MM-DD.islog'#10' -m m : kill client if gets more than this many MB behind, default 64'#10' -p p : alternate IP port, default 7624'#10' -v : show key events, no traffic'#10' -vv : -v + key message content'#10' -vvv : -vv + complete xml'
165186
Top = 141
166187
Width = 297
@@ -171,36 +192,37 @@ object f_setup: Tf_setup
171192
end
172193
object stayontop: TCheckBox
173194
Left = 8
174-
Height = 21
195+
Height = 22
175196
Top = 265
176-
Width = 258
197+
Width = 261
177198
Caption = 'Keep the server window always visible'
178199
ParentFont = False
179200
TabOrder = 2
180201
end
181202
object autostart: TCheckBox
182203
Left = 8
183-
Height = 21
204+
Height = 22
184205
Top = 234
185-
Width = 280
206+
Width = 281
186207
Caption = 'Autostart the server with last used profile'
187208
ParentFont = False
188209
TabOrder = 3
189210
end
190211
object Label8: TLabel
191212
Left = 13
192-
Height = 19
213+
Height = 18
193214
Top = 8
194-
Width = 91
215+
Width = 92
195216
Caption = 'Configuration :'
217+
ParentColor = False
196218
ParentFont = False
197219
end
198220
object ConfigList: TComboBox
199221
Left = 12
200-
Height = 35
222+
Height = 32
201223
Top = 24
202224
Width = 169
203-
ItemHeight = 0
225+
ItemHeight = 18
204226
OnChange = ConfigListChange
205227
ParentFont = False
206228
Sorted = True
@@ -219,14 +241,15 @@ object f_setup: Tf_setup
219241
end
220242
object Label9: TLabel
221243
Left = 13
222-
Height = 19
244+
Height = 18
223245
Top = 178
224-
Width = 207
246+
Width = 206
225247
Caption = 'Server log file ( blank for stdout )'
248+
ParentColor = False
226249
end
227250
object LogFileName: TFileNameEdit
228251
Left = 8
229-
Height = 30
252+
Height = 32
230253
Top = 198
231254
Width = 297
232255
FilterIndex = 0
@@ -247,14 +270,15 @@ object f_setup: Tf_setup
247270
TabOrder = 7
248271
object Label1: TLabel
249272
Left = 13
250-
Height = 19
273+
Height = 18
251274
Top = 2
252-
Width = 113
275+
Width = 112
253276
Caption = 'INDI binaries path'
277+
ParentColor = False
254278
end
255279
object indipath: TDirectoryEdit
256280
Left = 8
257-
Height = 30
281+
Height = 32
258282
Top = 22
259283
Width = 297
260284
ShowHidden = False
@@ -275,14 +299,15 @@ object f_setup: Tf_setup
275299
TabOrder = 8
276300
object Label10: TLabel
277301
Left = 13
278-
Height = 19
302+
Height = 18
279303
Top = 2
280304
Width = 166
281305
Caption = 'GSC path for the simulator '
306+
ParentColor = False
282307
end
283308
object gscpath: TDirectoryEdit
284309
Left = 8
285-
Height = 30
310+
Height = 32
286311
Top = 22
287312
Width = 297
288313
ShowHidden = False

pu_setup.pas

+2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ Tf_setup = class(TForm)
3939
Button2: TButton;
4040
BtnNewConfig: TButton;
4141
ConfigList: TComboBox;
42+
sshport: TEdit;
4243
gscpath: TDirectoryEdit;
4344
Label10: TLabel;
45+
Label11: TLabel;
4446
LogFileName: TFileNameEdit;
4547
indipath: TDirectoryEdit;
4648
Label1: TLabel;

0 commit comments

Comments
 (0)