diff --git a/sshuttle-gui/all/etc/systemd/system/sshuttle.service b/sshuttle-gui/all/etc/systemd/system/sshuttle.service new file mode 100644 index 0000000..3d76ea1 --- /dev/null +++ b/sshuttle-gui/all/etc/systemd/system/sshuttle.service @@ -0,0 +1,10 @@ +[Unit] +Description=sshuttle +After=network.target + +[Service] +Type=simple +ExecStart=/etc/sshuttle-gui/connect.sh + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/sshuttle-gui/all/usr/bin/sshuttle-gui b/sshuttle-gui/all/usr/bin/sshuttle-gui new file mode 100755 index 0000000..84ea4af --- /dev/null +++ b/sshuttle-gui/all/usr/bin/sshuttle-gui @@ -0,0 +1,32 @@ +#!/bin/bash + +if [ -f "/etc/sshuttle-gui/clear" ]; then +#zenity --question --no-wrap --title="Browser Сleaner" \ +# --text="Clear the Cache and Cookies of installed Browsers?" + +#if [ "$?" -eq "0" ]; then +# Caches (Mozilla, Chrome, Opera, Chromium, Palemoon) +rm -rf ~/.cache/mozilla/* \ + ~/.cache/google-chrome/* \ + ~/.cache/opera/* \ + ~/.cache/chromium/* \ + ~/.cache/moonchild\ productions/* + +# Cookies +rm -f $(find ~/.mozilla/* -type f -name "cookies.sqlite") \ + ~/.config/google-chrome/Default/Cookies* \ + ~/.config/opera/Cookies* \ + ~/.config/chromium/Default/Cookies* \ + "$(find ~/.moonchild\ productions/pale\ moon/* -type f -name "cookies.sqlite")" +#fi; +fi; +# --- + +# Detect KDE +if [[ $(type -p kdesu) && $XDG_CURRENT_DESKTOP == KDE ]]; then + kdesu /usr/share/sshuttle-gui/sshuttle_gui "$@" + else + pkexec /usr/share/sshuttle-gui/sshuttle_gui "$@" +fi; + +exit 0; diff --git a/sshuttle-gui/all/usr/share/applications/sshuttle-gui.desktop b/sshuttle-gui/all/usr/share/applications/sshuttle-gui.desktop new file mode 100644 index 0000000..3260d68 --- /dev/null +++ b/sshuttle-gui/all/usr/share/applications/sshuttle-gui.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=SShuttle-GUI +Comment=SSH VPN connector +Comment[ru]=SSH VPN коннектор +Icon=sshuttle-gui +Exec=sshuttle-gui +Type=Application +Categories=System; +Terminal=false diff --git a/sshuttle-gui/all/usr/share/icons/sshuttle-gui.png b/sshuttle-gui/all/usr/share/icons/sshuttle-gui.png new file mode 100644 index 0000000..24157d2 Binary files /dev/null and b/sshuttle-gui/all/usr/share/icons/sshuttle-gui.png differ diff --git a/sshuttle-gui/all/usr/share/polkit-1/actions/sshuttle-gui.policy b/sshuttle-gui/all/usr/share/polkit-1/actions/sshuttle-gui.policy new file mode 100644 index 0000000..1776f99 --- /dev/null +++ b/sshuttle-gui/all/usr/share/polkit-1/actions/sshuttle-gui.policy @@ -0,0 +1,17 @@ + + + + + + Authentication to run SShuttle-GUI + Аутентификация для запуска SShuttle-GUI + + auth_admin + auth_admin + auth_admin + + /usr/share/sshuttle-gui/sshuttle_gui + true + diff --git a/sshuttle-gui/backup/pingtrd.pas b/sshuttle-gui/backup/pingtrd.pas new file mode 100644 index 0000000..28693dc --- /dev/null +++ b/sshuttle-gui/backup/pingtrd.pas @@ -0,0 +1,85 @@ +unit PingTRD; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, Forms, Controls, SysUtils, Process, Graphics; + +type + CheckPing = class(TThread) + private + + { Private declarations } + protected + var + PingStr: TStringList; + + procedure Execute; override; + procedure ShowStatus; + + end; + +implementation + +uses unit1; + +{ TRD } + +procedure CheckPing.Execute; +var + PingProcess: TProcess; +begin + try + FreeOnTerminate := True; //Уничтожать по завершении + PingStr := TStringList.Create; + + PingProcess := TProcess.Create(nil); + PingProcess.Executable := 'bash'; + + while not Terminated do + begin + PingProcess.Parameters.Clear; + PingProcess.Parameters.Add('-c'); + PingProcess.Parameters.Add( + '[[ $(fping google.com) && $(systemctl is-active sshuttle) == "active" ]] && echo "yes" || echo "no"'); + + PingProcess.Options := [poUsePipes, poWaitOnExit]; + + PingProcess.Execute; + PingStr.LoadFromStream(PingProcess.Output); + Synchronize(@ShowStatus); + + Sleep(500); + end; + + finally + PingStr.Free; + PingProcess.Free; + Terminate; + end; +end; + +//Индикация - светодиод +procedure CheckPing.ShowStatus; +begin + with MainForm do + begin + if Trim(PingStr[0]) = 'yes' then + begin + StartBtn.Caption := SStop; + Shape1.Brush.Color := clLime; + end + else + begin + StartBtn.Caption := SStart; + Shape1.Brush.Color := clYellow; + end; + + Shape1.Repaint; + StartBtn.Repaint; + end; +end; + +end. diff --git a/sshuttle-gui/backup/sshuttle_gui.lpi b/sshuttle-gui/backup/sshuttle_gui.lpi new file mode 100644 index 0000000..73233ca --- /dev/null +++ b/sshuttle-gui/backup/sshuttle_gui.lpi @@ -0,0 +1,124 @@ + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N Value="True"/> + <OutDir Value="languages"/> + </i18n> + <BuildModes> + <Item Name="Default" Default="True"/> + <Item Name="Debug"> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="sshuttle_gui"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <IncludeAssertionCode Value="True"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Checks> + <IOChecks Value="True"/> + <RangeChecks Value="True"/> + <OverflowChecks Value="True"/> + <StackChecks Value="True"/> + </Checks> + <VerifyObjMethodCallValidity Value="True"/> + </CodeGeneration> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + <UseHeaptrc Value="True"/> + <TrashVariables Value="True"/> + <UseExternalDbgSyms Value="True"/> + </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + </Item> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="LCL"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="sshuttle_gui.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit> + <Unit> + <Filename Value="pingtrd.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="PingTRD"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="sshuttle_gui"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/sshuttle-gui/backup/sshuttle_gui.lpr b/sshuttle-gui/backup/sshuttle_gui.lpr new file mode 100644 index 0000000..ed8f205 --- /dev/null +++ b/sshuttle-gui/backup/sshuttle_gui.lpr @@ -0,0 +1,25 @@ +program sshuttle_gui; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX} + cthreads, + {$ENDIF} {$IFDEF HASAMIGA} + athreads, + {$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, + Unit1, + PingTRD { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Title:='SShuttle-GUI v0.1'; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. diff --git a/sshuttle-gui/backup/sshuttle_gui.lps b/sshuttle-gui/backup/sshuttle_gui.lps new file mode 100644 index 0000000..0d7bd8b --- /dev/null +++ b/sshuttle-gui/backup/sshuttle_gui.lps @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectSession> + <Version Value="12"/> + <BuildModes Active="Release"> + <Item Name="Release"> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="sshuttle_gui"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <CodeGeneration> + <SmartLinkUnit Value="True"/> + <Optimizations> + <OptimizationLevel Value="3"/> + </Optimizations> + </CodeGeneration> + <Linking> + <Debugging> + <GenerateDebugInfo Value="False"/> + <DebugInfoType Value="dsDwarf2"/> + </Debugging> + <LinkSmart Value="True"/> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + </Item> + </BuildModes> + <Units> + <Unit> + <Filename Value="sshuttle_gui.lpr"/> + <IsPartOfProject Value="True"/> + <EditorIndex Value="1"/> + <UsageCount Value="37"/> + <Loaded Value="True"/> + </Unit> + <Unit> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + <IsVisibleTab Value="True"/> + <TopLine Value="144"/> + <CursorPos X="30" Y="148"/> + <UsageCount Value="37"/> + <Loaded Value="True"/> + <LoadedDesigner Value="True"/> + </Unit> + <Unit> + <Filename Value="pingtrd.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="PingTRD"/> + <EditorIndex Value="2"/> + <CursorPos X="33" Y="59"/> + <UsageCount Value="33"/> + <Loaded Value="True"/> + </Unit> + <Unit> + <Filename Value="start_trd.pas"/> + <EditorIndex Value="-1"/> + <TopLine Value="41"/> + <CursorPos X="46" Y="46"/> + <UsageCount Value="35"/> + </Unit> + </Units> + <JumpHistory HistoryIndex="27"> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="189" Column="20" TopLine="167"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="133" Column="3" TopLine="131"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="132" Column="3" TopLine="130"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="49" Column="53" TopLine="35"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="182" Column="53" TopLine="161"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="194" Column="5" TopLine="179"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="56" Column="6" TopLine="34"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="55" Column="6" TopLine="33"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="45" TopLine="45"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="106" Column="2" TopLine="98"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="148" TopLine="143"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="105" Column="80" TopLine="98"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="181" Column="58" TopLine="164"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="182" Column="58" TopLine="165"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="174" Column="19" TopLine="166"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="153" Column="3" TopLine="148"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="50" Column="17" TopLine="37"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="203" TopLine="178"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="166" Column="53" TopLine="154"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="202" TopLine="173"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="201" TopLine="172"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="163" TopLine="153"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="155" Column="11" TopLine="140"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="167" Column="28" TopLine="158"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="162" Column="24" TopLine="152"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="147" Column="23" TopLine="21"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="170" Column="17" TopLine="158"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="149" Column="76" TopLine="144"/> + </Position> + </JumpHistory> + <RunParams> + <FormatVersion Value="2"/> + <Modes ActiveMode=""/> + </RunParams> + </ProjectSession> +</CONFIG> diff --git a/sshuttle-gui/backup/start_trd.pas b/sshuttle-gui/backup/start_trd.pas new file mode 100644 index 0000000..01e30ea --- /dev/null +++ b/sshuttle-gui/backup/start_trd.pas @@ -0,0 +1,115 @@ +unit start_trd; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, Process, SysUtils, ComCtrls; + +type + StartConnect = class(TThread) + private + + { Private declarations } + protected + var + Result: TStringList; + + procedure Execute; override; + + procedure ShowLog; + procedure StartProgress; + procedure StopProgress; + + end; + +implementation + +uses Unit1; + +{ TRD } + +procedure StartConnect.Execute; +var + ExProcess: TProcess; +begin + try //Вывод лога + Synchronize(@StartProgress); + + FreeOnTerminate := True; //Уничтожить по завершении + Result := TStringList.Create; + + //Рабочий процесс + ExProcess := TProcess.Create(nil); + + //Connect via ppp0 + ExProcess.Executable := 'bash'; + ExProcess.Parameters.Add('-c'); + ExProcess.Parameters.Add('chmod +x /etc/sshuttle-gui/connect.sh; bash ' + + '/etc/sshuttle-gui/connect.sh'); + + ExProcess.Options := [poUsePipes, poStderrToOutPut]; + + ExProcess.Execute; + + //Выводим лог динамически + while ExProcess.Running do + begin + Result.LoadFromStream(ExProcess.Output); + + //Выводим лог + if Result.Count <> 0 then + Synchronize(@ShowLog); + end; + + finally + Synchronize(@StopProgress); + Result.Free; + ExProcess.Free; + Terminate; + end; +end; + +{ БЛОК ОТОБРАЖЕНИЯ ЛОГА } + +//Старт скрипта подключения. Процесс активен до завершения sstpc. +procedure StartConnect.StartProgress; +begin + with MainForm do + begin + LogMemo.Clear; + StartBtn.Enabled := False; + StartBtn.Refresh; + end; +end; + +//Стоп (возникает при обрыве или нажатии Stop) +procedure StartConnect.StopProgress; +begin + with MainForm do + begin + if Trim(Result[0]) <> '---' then + StartBtn.Enabled := True; + StartBtn.Refresh; + + //Сохраняем историю + IniPropStorage1.Save; + end; +end; + +//Вывод лога +procedure StartConnect.ShowLog; +var + i: integer; +begin + //Вывод построчно + for i := 0 to Result.Count - 1 do + MainForm.LogMemo.Lines.Append(Result[i]); + + //Промотать список вниз + MainForm.LogMemo.SelStart := Length(MainForm.LogMemo.Text); + MainForm.LogMemo.SelLength := 0; +end; + +end. diff --git a/sshuttle-gui/backup/unit1.lfm b/sshuttle-gui/backup/unit1.lfm new file mode 100644 index 0000000..e9cf991 --- /dev/null +++ b/sshuttle-gui/backup/unit1.lfm @@ -0,0 +1,221 @@ +object MainForm: TMainForm + Left = 263 + Height = 175 + Top = 126 + Width = 531 + Caption = 'SShuttle-GUI' + ClientHeight = 175 + ClientWidth = 531 + OnCreate = FormCreate + OnShow = FormShow + SessionProperties = 'IPv6Box.Checked;LatencyBox.Checked;Left;PasswordEdit.Text;PortEdit.Text;RouterEdit.Text;ServerEdit.Text;Top;UserEdit.Text' + LCLVersion = '2.2.4.0' + object Label1: TLabel + AnchorSideTop.Side = asrCenter + Left = 8 + Height = 17 + Top = 16 + Width = 37 + Caption = 'Login:' + ParentColor = False + end + object UserEdit: TEdit + AnchorSideLeft.Control = ServerEdit + AnchorSideTop.Control = Label1 + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = Label2 + Left = 51 + Height = 37 + Top = 6 + Width = 95 + BorderSpacing.Right = 10 + TabOrder = 0 + Text = 'root' + end + object Label2: TLabel + AnchorSideLeft.Control = UserEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UserEdit + AnchorSideTop.Side = asrCenter + Left = 156 + Height = 17 + Top = 16 + Width = 61 + BorderSpacing.Left = 10 + Caption = 'Password:' + ParentColor = False + end + object PasswordEdit: TEdit + AnchorSideLeft.Control = Label2 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label2 + AnchorSideTop.Side = asrCenter + Left = 220 + Height = 37 + Top = 6 + Width = 187 + BorderSpacing.Left = 3 + TabOrder = 1 + end + object Label3: TLabel + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrCenter + Left = 8 + Height = 17 + Top = 58 + Width = 40 + Caption = 'Server:' + ParentColor = False + end + object ServerEdit: TEdit + AnchorSideLeft.Control = Label3 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UserEdit + AnchorSideTop.Side = asrBottom + Left = 51 + Height = 37 + Top = 48 + Width = 221 + BorderSpacing.Left = 3 + BorderSpacing.Top = 5 + BorderSpacing.Right = 10 + TabOrder = 2 + end + object ClearBox: TCheckBox + AnchorSideTop.Control = LatencyBox + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 283 + Height = 32 + Top = 134 + Width = 242 + Anchors = [akTop, akRight] + BorderSpacing.Right = 6 + Caption = 'Clear browser cookies on start GUI' + OnChange = ClearBoxChange + TabOrder = 7 + end + object AutoStartBox: TCheckBox + AnchorSideLeft.Control = StartBtn + AnchorSideTop.Control = IPv6Box + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 343 + Height = 32 + Top = 100 + Width = 182 + Anchors = [akTop, akRight] + BorderSpacing.Right = 6 + Caption = 'Autostart VPN on reboot' + OnChange = AutoStartBoxChange + TabOrder = 5 + end + object StartBtn: TSpeedButton + AnchorSideLeft.Control = Shape1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PasswordEdit + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = PortEdit + AnchorSideBottom.Side = asrBottom + Left = 433 + Height = 79 + Top = 6 + Width = 92 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Right = 6 + Caption = 'Start' + Font.Height = -15 + Font.Name = 'Sans' + Font.Style = [fsBold] + OnClick = StartBtnClick + ParentFont = False + end + object StaticText1: TStaticText + Left = 0 + Height = 20 + Top = 155 + Width = 531 + Align = alBottom + BorderStyle = sbsSingle + Caption = 'License: GPLv3 Author: alex_q_2000 (C) 2023 URL: https://linuxforum.ru' + Font.Color = clGray + Font.Height = -11 + Font.Name = 'Sans' + ParentFont = False + TabOrder = 8 + end + object Shape1: TShape + AnchorSideLeft.Control = PasswordEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = StartBtn + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = StartBtn + Left = 416 + Height = 12 + Top = 39 + Width = 12 + BorderSpacing.Left = 9 + BorderSpacing.Right = 5 + Brush.Color = clYellow + Shape = stCircle + end + object Label4: TLabel + AnchorSideLeft.Control = ServerEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = PortEdit + Left = 282 + Height = 17 + Top = 58 + Width = 29 + BorderSpacing.Right = 3 + Caption = 'Port:' + ParentColor = False + end + object PortEdit: TEdit + AnchorSideLeft.Control = Label4 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ServerEdit + AnchorSideRight.Control = PasswordEdit + AnchorSideRight.Side = asrBottom + Left = 314 + Height = 37 + Top = 48 + Width = 93 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 3 + TabOrder = 3 + Text = '22' + end + object IPv6Box: TCheckBox + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrBottom + Left = 8 + Height = 32 + Top = 100 + Width = 120 + BorderSpacing.Top = 15 + Caption = '--disable-ipv6' + TabOrder = 4 + end + object LatencyBox: TCheckBox + AnchorSideTop.Control = IPv6Box + AnchorSideTop.Side = asrBottom + Left = 8 + Height = 32 + Top = 134 + Width = 161 + BorderSpacing.Top = 2 + Caption = '--no-latency-control' + Checked = True + State = cbChecked + TabOrder = 6 + end + object IniPropStorage1: TIniPropStorage + StoredValues = <> + Left = 216 + Top = 96 + end +end diff --git a/sshuttle-gui/backup/unit1.pas b/sshuttle-gui/backup/unit1.pas new file mode 100644 index 0000000..e7b633b --- /dev/null +++ b/sshuttle-gui/backup/unit1.pas @@ -0,0 +1,215 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, + ComCtrls, ExtCtrls, IniPropStorage, Process, DefaultTranslator; + +type + + { TMainForm } + + TMainForm = class(TForm) + IPv6Box: TCheckBox; + LatencyBox: TCheckBox; + ClearBox: TCheckBox; + AutoStartBox: TCheckBox; + PortEdit: TEdit; + Label4: TLabel; + UserEdit: TEdit; + PasswordEdit: TEdit; + ServerEdit: TEdit; + IniPropStorage1: TIniPropStorage; + Label1: TLabel; + Label2: TLabel; + Label3: TLabel; + Shape1: TShape; + StartBtn: TSpeedButton; + StaticText1: TStaticText; + procedure AutoStartBoxChange(Sender: TObject); + procedure ClearBoxChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure StartBtnClick(Sender: TObject); + procedure StartProcess(command: string); + + private + + public + + end; + +var + MainForm: TMainForm; + +resourcestring + + SStart = 'Start'; + SStop = 'Stop'; + +implementation + +uses pingtrd; + +{$R *.lfm} + +{ TMainForm } + +//Общая процедура запуска команд (асинхронная) +procedure TMainForm.StartProcess(command: string); +var + ExProcess: TProcess; +begin + Application.ProcessMessages; + ExProcess := TProcess.Create(nil); + try + ExProcess.Executable := '/bin/bash'; + ExProcess.Parameters.Add('-c'); + ExProcess.Parameters.Add(command); + // ExProcess.Options := ExProcess.Options + [poWaitOnExit]; + ExProcess.Execute; + finally + ExProcess.Free; + end; +end; + +//Проверка чекбокса ClearBox (очистка кеш/cookies) +function CheckClear: boolean; +begin + if FileExists('/etc/sshuttle-gui/clear') then + Result := True + else + Result := False; +end; + +//Проверка чекбокса AutoStart +function CheckAutoStart: boolean; +var + S: ansistring; +begin + RunCommand('/bin/bash', ['-c', + '[[ -n $(systemctl is-enabled sshuttle | grep "enabled") ]] && echo "yes"'], + S); + + if Trim(S) = 'yes' then + Result := True + else + Result := False; +end; + +procedure TMainForm.FormCreate(Sender: TObject); +var + FCheckPingThread: TThread; +begin + MainForm.Caption := Application.Title; + + //Каталог ключей и Рабочая директория + if not DirectoryExists('/root/.ssh') then MkDir('/root/.ssh'); + if not DirectoryExists('/etc/sshuttle-gui') then MkDir('/etc/sshuttle-gui'); + + IniPropStorage1.IniFileName := '/etc/sshuttle-gui/settings.conf'; + + //Поток проверки пинга + FCheckPingThread := CheckPing.Create(False); + FCheckPingThread.Priority := tpNormal; +end; + +procedure TMainForm.ClearBoxChange(Sender: TObject); +var + S: ansistring; +begin + if not ClearBox.Checked then + RunCommand('/bin/bash', ['-c', 'rm -f /etc/sshuttle-gui/clear'], S) + else + RunCommand('/bin/bash', ['-c', 'touch /etc/sshuttle-gui/clear'], S); +end; + +procedure TMainForm.AutoStartBoxChange(Sender: TObject); +var + S: ansistring; +begin + Screen.Cursor := crHourGlass; + Application.ProcessMessages; + + if not AutoStartBox.Checked then + RunCommand('/bin/bash', ['-c', 'systemctl disable sshuttle.service'], S) + else + RunCommand('/bin/bash', ['-c', 'systemctl enable sshuttle.service'], S); + Screen.Cursor := crDefault; +end; + +procedure TMainForm.FormShow(Sender: TObject); +begin + IniPropStorage1.Restore; + + //Высота/Ширина формы (Auto) + MainForm.Height := ClearBox.Top + ClearBox.Height + StaticText1.Height + 5; + MainForm.Width := StartBtn.Left + StartBtn.Height + 25; + + AutostartBox.Checked := CheckAutoStart; + ClearBox.Checked := CheckClear; +end; + +//Start VPN +procedure TMainForm.StartBtnClick(Sender: TObject); +var + Pars: string; + S: TStringList; +begin + //Проверка на пустоту + if (Trim(UserEdit.Text) = '') or (Trim(PasswordEdit.Text) = '') or + (Trim(ServerEdit.Text) = '') or (Trim(PortEdit.Text) = '') then Exit; + + IniPropStorage1.Save; + + //Дополнительные параметры + Pars := ''; + if IPv6Box.Checked then Pars := IPv6Box.Caption; + if LatencyBox.Checked then Pars := Concat(Pars, ' ', LatencyBox.Caption); + + //Старт/Стоп VPN (ip(6)tables -L -t nat) - используется таблица ip(6)tables + //Цепочки очищаются после останова: systemctl stop sshuttle + if StartBtn.Caption = SStop then + begin + Shape1.Brush.Color := clYellow; + StartProcess('systemctl stop sshuttle.service'); + end + else + try + S := TStringList.Create; + + S.Add('#!/bin/bash'); + S.Add(''); + + //Содаём пускач для systemd (Type=simple) + S.Add('# Проверка наличия валидных ключей /root/.ssh/{known_hosts,known_hosts.old}'); + S.Add('if [[ ! -f /root/.ssh/known_hosts.old ]] || [[ -z $(ssh-keygen -F ' + + Trim(ServerEDit.Text) + ') ]]; then'); + S.Add('sshpass -p "' + Trim(PasswordEdit.Text) + + '" ssh -o StrictHostKeyChecking=No ' + Trim(UserEdit.Text) + + '@' + Trim(ServerEDit.Text) + ' -p ' + Trim(PortEdit.Text) + ' exit 0; fi'); + S.Add(''); + S.Add('# Запуск vpn'); + S.Add('[[ "$?" -eq "0" ]] && \'); + S.Add('sshpass -p "' + Trim(PasswordEdit.Text) + + '" sshuttle --dns --remote ' + Trim(UserEdit.Text) + '@' + + Trim(ServerEDit.Text) + ':' + Trim(PortEdit.Text) + ' -x ' + + Trim(ServerEDit.Text) + ':' + Trim(PortEdit.Text) + ' 0/0 ' + Trim(Pars)); + + S.Add('exit 0;'); + + S.SaveToFile('/etc/sshuttle-gui/connect.sh'); + + //Запускаем скрипт через systemd + StartProcess('chmod +x /etc/sshuttle-gui/connect.sh; systemctl restart sshuttle.service'); + + finally + S.Free; + end; +end; + + +end. diff --git a/sshuttle-gui/etc/sstp-connector/stop-connect.sh b/sshuttle-gui/etc/sstp-connector/stop-connect.sh new file mode 100755 index 0000000..69b429e --- /dev/null +++ b/sshuttle-gui/etc/sstp-connector/stop-connect.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +pkill sstpc +pkill -f /etc/sstp-connector/connect.sh +/etc/sstp-connector/update-resolv-conf down + +exit 0 diff --git a/sshuttle-gui/etc/sstp-connector/update-resolv-conf b/sshuttle-gui/etc/sstp-connector/update-resolv-conf new file mode 100755 index 0000000..58a5a82 --- /dev/null +++ b/sshuttle-gui/etc/sstp-connector/update-resolv-conf @@ -0,0 +1,18 @@ +#!/usr/bin/bash + +case $1 in +up) + echo "# Generated by SSTP-Connector" > /etc/resolv.conf + echo -e "nameserver 1.0.0.1\nnameserver 9.9.9.9" >> /etc/resolv.conf + ;; +down) + #DNS restore + if [[ $(systemctl is-active systemd-resolved) == "active" ]]; then + systemctl restart systemd-resolved + else + pgrep NetworkManager && systemctl restart NetworkManager.service || resolvconf -u + fi; + ;; +esac + +exit 0 diff --git a/sshuttle-gui/etc/systemd/system/sstp-connector.service b/sshuttle-gui/etc/systemd/system/sstp-connector.service new file mode 100644 index 0000000..e96165b --- /dev/null +++ b/sshuttle-gui/etc/systemd/system/sstp-connector.service @@ -0,0 +1,13 @@ +[Unit] +Description=SSTP VPN Tunneling Application +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +ExecStart=/etc/sstp-connector/connect-systemd.sh +ExecStop=/etc/sstp-connector/stop-connect.sh +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/sshuttle-gui/ico/sshuttle-gui.png b/sshuttle-gui/ico/sshuttle-gui.png new file mode 100644 index 0000000..24157d2 Binary files /dev/null and b/sshuttle-gui/ico/sshuttle-gui.png differ diff --git a/sshuttle-gui/languages/sshuttle_gui.pot b/sshuttle-gui/languages/sshuttle_gui.pot new file mode 100644 index 0000000..e67906e --- /dev/null +++ b/sshuttle-gui/languages/sshuttle_gui.pot @@ -0,0 +1,65 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: tmainform.autostartbox.caption +msgid "Autostart VPN on reboot" +msgstr "" + +#: tmainform.caption +msgid "SShuttle-GUI" +msgstr "" + +#: tmainform.clearbox.caption +msgid "Clear browser cookies on start GUI" +msgstr "" + +#: tmainform.ipv6box.caption +msgid "--disable-ipv6" +msgstr "" + +#: tmainform.label1.caption +msgid "Login:" +msgstr "" + +#: tmainform.label2.caption +msgid "Password:" +msgstr "" + +#: tmainform.label3.caption +msgid "Server:" +msgstr "" + +#: tmainform.label4.caption +msgid "Port:" +msgstr "" + +#: tmainform.latencybox.caption +msgid "--no-latency-control" +msgstr "" + +#: tmainform.portedit.text +msgid "22" +msgstr "" + +#: tmainform.startbtn.caption +msgctxt "tmainform.startbtn.caption" +msgid "Start" +msgstr "" + +#: tmainform.statictext1.caption +msgid "License: GPLv3 Author: alex_q_2000 (C) 2023 URL: https://linuxforum.ru" +msgstr "" + +#: tmainform.useredit.text +msgid "root" +msgstr "" + +#: unit1.sstart +msgctxt "unit1.sstart" +msgid "Start" +msgstr "" + +#: unit1.sstop +msgid "Stop" +msgstr "" + diff --git a/sshuttle-gui/languages/sshuttle_gui.ru.mo b/sshuttle-gui/languages/sshuttle_gui.ru.mo new file mode 100644 index 0000000..3278061 Binary files /dev/null and b/sshuttle-gui/languages/sshuttle_gui.ru.mo differ diff --git a/sshuttle-gui/languages/sshuttle_gui.ru.po b/sshuttle-gui/languages/sshuttle_gui.ru.po new file mode 100644 index 0000000..04ebe36 --- /dev/null +++ b/sshuttle-gui/languages/sshuttle_gui.ru.po @@ -0,0 +1,75 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" +"X-Generator: Poedit 3.2.2\n" + +#: tmainform.autostartbox.caption +msgid "Autostart VPN on reboot" +msgstr "Автостарт VPN после перезагрузки" + +#: tmainform.caption +msgid "SShuttle-GUI" +msgstr "" + +#: tmainform.clearbox.caption +msgid "Clear browser cookies on start GUI" +msgstr "Очистить cookies браузера при старте GUI" + +#: tmainform.ipv6box.caption +msgid "--disable-ipv6" +msgstr "" + +#: tmainform.label1.caption +msgid "Login:" +msgstr "Логин:" + +#: tmainform.label2.caption +msgid "Password:" +msgstr "Пароль:" + +#: tmainform.label3.caption +msgid "Server:" +msgstr "Сервер:" + +#: tmainform.label4.caption +msgid "Port:" +msgstr "Порт:" + +#: tmainform.latencybox.caption +msgid "--no-latency-control" +msgstr "" + +#: tmainform.portedit.text +msgid "22" +msgstr "" + +#: tmainform.startbtn.caption +msgctxt "tmainform.startbtn.caption" +msgid "Start" +msgstr "Старт" + +#: tmainform.statictext1.caption +msgid "License: GPLv3 Author: alex_q_2000 (C) 2023 URL: https://linuxforum.ru" +msgstr "Лицензия: GPLv3 Автор: alex_q_2000 (C) 2023 URL: https://linuxforum.ru" + +#: tmainform.useredit.text +msgid "root" +msgstr "" + +#: unit1.sstart +msgctxt "unit1.sstart" +msgid "Start" +msgstr "Старт" + +#: unit1.sstop +msgid "Stop" +msgstr "Стоп" diff --git a/sshuttle-gui/lib/x86_64-linux/pingtrd.o b/sshuttle-gui/lib/x86_64-linux/pingtrd.o new file mode 100644 index 0000000..1a40869 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/pingtrd.o differ diff --git a/sshuttle-gui/lib/x86_64-linux/pingtrd.ppu b/sshuttle-gui/lib/x86_64-linux/pingtrd.ppu new file mode 100644 index 0000000..09a2bf0 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/pingtrd.ppu differ diff --git a/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.compiled b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.compiled new file mode 100644 index 0000000..2dd9d78 --- /dev/null +++ b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.compiled @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <Compiler Value="/usr/bin/fpc" Date="1677995175"/> + <Params Value=" -MObjFPC -Scghi -CX -Cg -O3 -XX -l -vewnhibq "-Fi/home/marsik/Рабочий стол/sshuttle-gui/lib/x86_64-linux" -Fu/usr/lib64/lazarus/lcl/units/x86_64-linux/gtk2 -Fu/usr/lib64/lazarus/lcl/units/x86_64-linux -Fu/usr/lib64/lazarus/components/freetype/lib/x86_64-linux -Fu/usr/lib64/lazarus/components/lazutils/lib/x86_64-linux -Fu/usr/lib64/lazarus/packager/units/x86_64-linux "-Fu/home/marsik/Рабочий стол/sshuttle-gui/" "-FU/home/marsik/Рабочий стол/sshuttle-gui/lib/x86_64-linux/" "-FE/home/marsik/Рабочий стол/sshuttle-gui/" "-o/home/marsik/Рабочий стол/sshuttle-gui/sshuttle_gui" -dLCL -dLCLgtk2 sshuttle_gui.lpr"/> +</CONFIG> diff --git a/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.o b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.o new file mode 100644 index 0000000..f3e634b Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.o differ diff --git a/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.or b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.or new file mode 100644 index 0000000..729a00f Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.or differ diff --git a/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.res b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.res new file mode 100644 index 0000000..7e64c9f Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/sshuttle_gui.res differ diff --git a/sshuttle-gui/lib/x86_64-linux/sstp_connector.compiled b/sshuttle-gui/lib/x86_64-linux/sstp_connector.compiled new file mode 100644 index 0000000..0424a0c --- /dev/null +++ b/sshuttle-gui/lib/x86_64-linux/sstp_connector.compiled @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <Compiler Value="/usr/bin/fpc" Date="1648204554"/> + <Params Value=" -MObjFPC -Scghi -CX -Cg -O3 -XX -l -vewnhibq "-Fi/home/marsik/Рабочий стол/sstp-connector/lib/x86_64-linux" -Fu/usr/lib64/lazarus/lcl/units/x86_64-linux/gtk2 -Fu/usr/lib64/lazarus/lcl/units/x86_64-linux -Fu/usr/lib64/lazarus/components/freetype/lib/x86_64-linux -Fu/usr/lib64/lazarus/components/lazutils/lib/x86_64-linux -Fu/usr/lib64/lazarus/packager/units/x86_64-linux "-Fu/home/marsik/Рабочий стол/sstp-connector/" "-FU/home/marsik/Рабочий стол/sstp-connector/lib/x86_64-linux/" "-FE/home/marsik/Рабочий стол/sstp-connector/" "-o/home/marsik/Рабочий стол/sstp-connector/sstp_connector" -dLCL -dLCLgtk2 sstp_connector.lpr"/> +</CONFIG> diff --git a/sshuttle-gui/lib/x86_64-linux/sstp_connector.o b/sshuttle-gui/lib/x86_64-linux/sstp_connector.o new file mode 100644 index 0000000..4601c8c Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/sstp_connector.o differ diff --git a/sshuttle-gui/lib/x86_64-linux/sstp_connector.or b/sshuttle-gui/lib/x86_64-linux/sstp_connector.or new file mode 100644 index 0000000..16263e9 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/sstp_connector.or differ diff --git a/sshuttle-gui/lib/x86_64-linux/sstp_connector.res b/sshuttle-gui/lib/x86_64-linux/sstp_connector.res new file mode 100644 index 0000000..18cbca5 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/sstp_connector.res differ diff --git a/sshuttle-gui/lib/x86_64-linux/start_trd.o b/sshuttle-gui/lib/x86_64-linux/start_trd.o new file mode 100644 index 0000000..b7620b6 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/start_trd.o differ diff --git a/sshuttle-gui/lib/x86_64-linux/start_trd.ppu b/sshuttle-gui/lib/x86_64-linux/start_trd.ppu new file mode 100644 index 0000000..060ea02 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/start_trd.ppu differ diff --git a/sshuttle-gui/lib/x86_64-linux/unit1.lfm b/sshuttle-gui/lib/x86_64-linux/unit1.lfm new file mode 100644 index 0000000..e9cf991 --- /dev/null +++ b/sshuttle-gui/lib/x86_64-linux/unit1.lfm @@ -0,0 +1,221 @@ +object MainForm: TMainForm + Left = 263 + Height = 175 + Top = 126 + Width = 531 + Caption = 'SShuttle-GUI' + ClientHeight = 175 + ClientWidth = 531 + OnCreate = FormCreate + OnShow = FormShow + SessionProperties = 'IPv6Box.Checked;LatencyBox.Checked;Left;PasswordEdit.Text;PortEdit.Text;RouterEdit.Text;ServerEdit.Text;Top;UserEdit.Text' + LCLVersion = '2.2.4.0' + object Label1: TLabel + AnchorSideTop.Side = asrCenter + Left = 8 + Height = 17 + Top = 16 + Width = 37 + Caption = 'Login:' + ParentColor = False + end + object UserEdit: TEdit + AnchorSideLeft.Control = ServerEdit + AnchorSideTop.Control = Label1 + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = Label2 + Left = 51 + Height = 37 + Top = 6 + Width = 95 + BorderSpacing.Right = 10 + TabOrder = 0 + Text = 'root' + end + object Label2: TLabel + AnchorSideLeft.Control = UserEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UserEdit + AnchorSideTop.Side = asrCenter + Left = 156 + Height = 17 + Top = 16 + Width = 61 + BorderSpacing.Left = 10 + Caption = 'Password:' + ParentColor = False + end + object PasswordEdit: TEdit + AnchorSideLeft.Control = Label2 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label2 + AnchorSideTop.Side = asrCenter + Left = 220 + Height = 37 + Top = 6 + Width = 187 + BorderSpacing.Left = 3 + TabOrder = 1 + end + object Label3: TLabel + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrCenter + Left = 8 + Height = 17 + Top = 58 + Width = 40 + Caption = 'Server:' + ParentColor = False + end + object ServerEdit: TEdit + AnchorSideLeft.Control = Label3 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UserEdit + AnchorSideTop.Side = asrBottom + Left = 51 + Height = 37 + Top = 48 + Width = 221 + BorderSpacing.Left = 3 + BorderSpacing.Top = 5 + BorderSpacing.Right = 10 + TabOrder = 2 + end + object ClearBox: TCheckBox + AnchorSideTop.Control = LatencyBox + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 283 + Height = 32 + Top = 134 + Width = 242 + Anchors = [akTop, akRight] + BorderSpacing.Right = 6 + Caption = 'Clear browser cookies on start GUI' + OnChange = ClearBoxChange + TabOrder = 7 + end + object AutoStartBox: TCheckBox + AnchorSideLeft.Control = StartBtn + AnchorSideTop.Control = IPv6Box + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 343 + Height = 32 + Top = 100 + Width = 182 + Anchors = [akTop, akRight] + BorderSpacing.Right = 6 + Caption = 'Autostart VPN on reboot' + OnChange = AutoStartBoxChange + TabOrder = 5 + end + object StartBtn: TSpeedButton + AnchorSideLeft.Control = Shape1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PasswordEdit + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = PortEdit + AnchorSideBottom.Side = asrBottom + Left = 433 + Height = 79 + Top = 6 + Width = 92 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Right = 6 + Caption = 'Start' + Font.Height = -15 + Font.Name = 'Sans' + Font.Style = [fsBold] + OnClick = StartBtnClick + ParentFont = False + end + object StaticText1: TStaticText + Left = 0 + Height = 20 + Top = 155 + Width = 531 + Align = alBottom + BorderStyle = sbsSingle + Caption = 'License: GPLv3 Author: alex_q_2000 (C) 2023 URL: https://linuxforum.ru' + Font.Color = clGray + Font.Height = -11 + Font.Name = 'Sans' + ParentFont = False + TabOrder = 8 + end + object Shape1: TShape + AnchorSideLeft.Control = PasswordEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = StartBtn + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = StartBtn + Left = 416 + Height = 12 + Top = 39 + Width = 12 + BorderSpacing.Left = 9 + BorderSpacing.Right = 5 + Brush.Color = clYellow + Shape = stCircle + end + object Label4: TLabel + AnchorSideLeft.Control = ServerEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = PortEdit + Left = 282 + Height = 17 + Top = 58 + Width = 29 + BorderSpacing.Right = 3 + Caption = 'Port:' + ParentColor = False + end + object PortEdit: TEdit + AnchorSideLeft.Control = Label4 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ServerEdit + AnchorSideRight.Control = PasswordEdit + AnchorSideRight.Side = asrBottom + Left = 314 + Height = 37 + Top = 48 + Width = 93 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 3 + TabOrder = 3 + Text = '22' + end + object IPv6Box: TCheckBox + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrBottom + Left = 8 + Height = 32 + Top = 100 + Width = 120 + BorderSpacing.Top = 15 + Caption = '--disable-ipv6' + TabOrder = 4 + end + object LatencyBox: TCheckBox + AnchorSideTop.Control = IPv6Box + AnchorSideTop.Side = asrBottom + Left = 8 + Height = 32 + Top = 134 + Width = 161 + BorderSpacing.Top = 2 + Caption = '--no-latency-control' + Checked = True + State = cbChecked + TabOrder = 6 + end + object IniPropStorage1: TIniPropStorage + StoredValues = <> + Left = 216 + Top = 96 + end +end diff --git a/sshuttle-gui/lib/x86_64-linux/unit1.o b/sshuttle-gui/lib/x86_64-linux/unit1.o new file mode 100644 index 0000000..a8a7c41 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/unit1.o differ diff --git a/sshuttle-gui/lib/x86_64-linux/unit1.ppu b/sshuttle-gui/lib/x86_64-linux/unit1.ppu new file mode 100644 index 0000000..d6ff0e5 Binary files /dev/null and b/sshuttle-gui/lib/x86_64-linux/unit1.ppu differ diff --git a/sshuttle-gui/lib/x86_64-linux/unit1.rsj b/sshuttle-gui/lib/x86_64-linux/unit1.rsj new file mode 100644 index 0000000..93e683a --- /dev/null +++ b/sshuttle-gui/lib/x86_64-linux/unit1.rsj @@ -0,0 +1,4 @@ +{"version":1,"strings":[ +{"hash":5941396,"name":"unit1.sstart","sourcebytes":[83,116,97,114,116],"value":"Start"}, +{"hash":371552,"name":"unit1.sstop","sourcebytes":[83,116,111,112],"value":"Stop"} +]} diff --git a/sshuttle-gui/package-project/sshuttle-gui.prj b/sshuttle-gui/package-project/sshuttle-gui.prj new file mode 100644 index 0000000..d172e87 --- /dev/null +++ b/sshuttle-gui/package-project/sshuttle-gui.prj @@ -0,0 +1,72 @@ +[NAME] +name=sshuttle-gui + +[VERSION] +version=0.1 + +[RELEASE] +release=0.mrx9 + +[GROUP] +group=Applications/System + +[DESCRIPTION] +0=Simple SShuttle SSH connector GUI +1=--- +2=More information: /usr/share/doc/package_name/repack.txt + +[MAINTAINER] +maintainer=Alex Kotov + +[VENDOR] +vendor=alex_q_2000 (C) 2022 + +[SUMMARY] +summary=Simple SShuttle SSH connector GUI + +[URLCOPY] +urlcopy=https://github.com/AKotov-dev/??? + +[LICENSE] +license=GPLv3 + +[DEPS] +deps=gtk2 polkit fping systemd sshuttle sshpass + +[META] +meta=0 + +[NOARCH] +noarch=0 + +[DEB] +deb=0 + +[FILES] +0=/usr/share/sshuttle-gui/ +1=/usr/bin/sshuttle-gui +2=/usr/share/icons/sshuttle-gui.png +3=/etc/systemd/system/sshuttle.service +4=/usr/share/applications/sshuttle-gui.desktop +5=/usr/share/polkit-1/actions/sshuttle-gui.policy + +[AFTERINSTALL] +0=systemctl daemon-reload + +[AFTERREMOVE] +0=systemctl daemon-reload + +[URL32] +url32=https://github.com/AKotov-dev/??? + +[PROGRAMNAME] +programname=SShuttle-GUI + +[DEVTOOL] +devtool=Lazarus + +[TOOLVERSION] +toolversion=2.2.4 + +[INFO] +0=v0.1 - initial release diff --git a/sshuttle-gui/pingtrd.pas b/sshuttle-gui/pingtrd.pas new file mode 100644 index 0000000..ddfc5a6 --- /dev/null +++ b/sshuttle-gui/pingtrd.pas @@ -0,0 +1,85 @@ +unit PingTRD; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, Forms, Controls, SysUtils, Process, Graphics; + +type + CheckPing = class(TThread) + private + + { Private declarations } + protected + var + PingStr: TStringList; + + procedure Execute; override; + procedure ShowStatus; + + end; + +implementation + +uses unit1; + +{ TRD } + +procedure CheckPing.Execute; +var + PingProcess: TProcess; +begin + try + FreeOnTerminate := True; //Уничтожать по завершении + PingStr := TStringList.Create; + + PingProcess := TProcess.Create(nil); + PingProcess.Executable := 'bash'; + + while not Terminated do + begin + PingProcess.Parameters.Clear; + PingProcess.Parameters.Add('-c'); + PingProcess.Parameters.Add( + '[[ $(fping google.com) && $(systemctl is-active sshuttle) == "active" ]] && echo "yes" || echo "no"'); + + PingProcess.Options := [poUsePipes, poWaitOnExit]; + + PingProcess.Execute; + PingStr.LoadFromStream(PingProcess.Output); + Synchronize(@ShowStatus); + + Sleep(500); + end; + + finally + PingStr.Free; + PingProcess.Free; + Terminate; + end; +end; + +//Индикация: Cветодиод, Режим +procedure CheckPing.ShowStatus; +begin + with MainForm do + begin + if Trim(PingStr[0]) = 'yes' then + begin + StartBtn.Caption := SStop; + Shape1.Brush.Color := clLime; + end + else + begin + StartBtn.Caption := SStart; + Shape1.Brush.Color := clYellow; + end; + + Shape1.Repaint; + StartBtn.Repaint; + end; +end; + +end. diff --git a/sshuttle-gui/sshuttle_gui b/sshuttle-gui/sshuttle_gui new file mode 100755 index 0000000..95c1075 Binary files /dev/null and b/sshuttle-gui/sshuttle_gui differ diff --git a/sshuttle-gui/sshuttle_gui.ico b/sshuttle-gui/sshuttle_gui.ico new file mode 100644 index 0000000..13b56d2 Binary files /dev/null and b/sshuttle-gui/sshuttle_gui.ico differ diff --git a/sshuttle-gui/sshuttle_gui.lpi b/sshuttle-gui/sshuttle_gui.lpi new file mode 100644 index 0000000..73233ca --- /dev/null +++ b/sshuttle-gui/sshuttle_gui.lpi @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="12"/> + <General> + <SessionStorage Value="InProjectDir"/> + <Title Value="SShuttle-GUI v0.1"/> + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N Value="True"/> + <OutDir Value="languages"/> + </i18n> + <BuildModes> + <Item Name="Default" Default="True"/> + <Item Name="Debug"> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="sshuttle_gui"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <IncludeAssertionCode Value="True"/> + </SyntaxOptions> + </Parsing> + <CodeGeneration> + <Checks> + <IOChecks Value="True"/> + <RangeChecks Value="True"/> + <OverflowChecks Value="True"/> + <StackChecks Value="True"/> + </Checks> + <VerifyObjMethodCallValidity Value="True"/> + </CodeGeneration> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + <UseHeaptrc Value="True"/> + <TrashVariables Value="True"/> + <UseExternalDbgSyms Value="True"/> + </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + </Item> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="LCL"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="sshuttle_gui.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit> + <Unit> + <Filename Value="pingtrd.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="PingTRD"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="sshuttle_gui"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/sshuttle-gui/sshuttle_gui.lpr b/sshuttle-gui/sshuttle_gui.lpr new file mode 100644 index 0000000..3580b43 --- /dev/null +++ b/sshuttle-gui/sshuttle_gui.lpr @@ -0,0 +1,25 @@ +program sshuttle_gui; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX} + cthreads, + {$ENDIF} {$IFDEF HASAMIGA} + athreads, + {$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, + Unit1, + PingTRD { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource := True; + Application.Title := 'SShuttle-GUI v0.1'; + Application.Scaled := True; + Application.Initialize; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. diff --git a/sshuttle-gui/sshuttle_gui.lps b/sshuttle-gui/sshuttle_gui.lps new file mode 100644 index 0000000..6dd70ec --- /dev/null +++ b/sshuttle-gui/sshuttle_gui.lps @@ -0,0 +1,195 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectSession> + <Version Value="12"/> + <BuildModes Active="Release"> + <Item Name="Release"> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="sshuttle_gui"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <CodeGeneration> + <SmartLinkUnit Value="True"/> + <Optimizations> + <OptimizationLevel Value="3"/> + </Optimizations> + </CodeGeneration> + <Linking> + <Debugging> + <GenerateDebugInfo Value="False"/> + <DebugInfoType Value="dsDwarf2"/> + </Debugging> + <LinkSmart Value="True"/> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + </Item> + </BuildModes> + <Units> + <Unit> + <Filename Value="sshuttle_gui.lpr"/> + <IsPartOfProject Value="True"/> + <EditorIndex Value="1"/> + <UsageCount Value="37"/> + <Loaded Value="True"/> + </Unit> + <Unit> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + <IsVisibleTab Value="True"/> + <TopLine Value="144"/> + <CursorPos X="29" Y="146"/> + <UsageCount Value="37"/> + <Loaded Value="True"/> + <LoadedDesigner Value="True"/> + </Unit> + <Unit> + <Filename Value="pingtrd.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="PingTRD"/> + <EditorIndex Value="2"/> + <CursorPos X="33" Y="59"/> + <UsageCount Value="33"/> + <Loaded Value="True"/> + </Unit> + <Unit> + <Filename Value="start_trd.pas"/> + <EditorIndex Value="-1"/> + <TopLine Value="41"/> + <CursorPos X="46" Y="46"/> + <UsageCount Value="35"/> + </Unit> + </Units> + <JumpHistory HistoryIndex="27"> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="189" Column="20" TopLine="167"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="133" Column="3" TopLine="131"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="132" Column="3" TopLine="130"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="49" Column="53" TopLine="35"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="182" Column="53" TopLine="161"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="194" Column="5" TopLine="179"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="56" Column="6" TopLine="34"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="55" Column="6" TopLine="33"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="45" TopLine="45"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="106" Column="2" TopLine="98"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="148" TopLine="143"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="105" Column="80" TopLine="98"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="181" Column="58" TopLine="164"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="182" Column="58" TopLine="165"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="174" Column="19" TopLine="166"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="153" Column="3" TopLine="148"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="50" Column="17" TopLine="37"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="203" TopLine="178"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="166" Column="53" TopLine="154"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="202" TopLine="173"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="201" TopLine="172"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="163" TopLine="153"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="155" Column="11" TopLine="140"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="167" Column="28" TopLine="158"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="162" Column="24" TopLine="152"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="147" Column="23" TopLine="21"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="170" Column="17" TopLine="158"/> + </Position> + <Position> + <Filename Value="unit1.pas"/> + <Caret Line="149" Column="76" TopLine="144"/> + </Position> + </JumpHistory> + <RunParams> + <FormatVersion Value="2"/> + <Modes ActiveMode=""/> + </RunParams> + </ProjectSession> +</CONFIG> diff --git a/sshuttle-gui/sshuttle_gui.res b/sshuttle-gui/sshuttle_gui.res new file mode 100644 index 0000000..7e64c9f Binary files /dev/null and b/sshuttle-gui/sshuttle_gui.res differ diff --git a/sshuttle-gui/unit1.lfm b/sshuttle-gui/unit1.lfm new file mode 100644 index 0000000..e9cf991 --- /dev/null +++ b/sshuttle-gui/unit1.lfm @@ -0,0 +1,221 @@ +object MainForm: TMainForm + Left = 263 + Height = 175 + Top = 126 + Width = 531 + Caption = 'SShuttle-GUI' + ClientHeight = 175 + ClientWidth = 531 + OnCreate = FormCreate + OnShow = FormShow + SessionProperties = 'IPv6Box.Checked;LatencyBox.Checked;Left;PasswordEdit.Text;PortEdit.Text;RouterEdit.Text;ServerEdit.Text;Top;UserEdit.Text' + LCLVersion = '2.2.4.0' + object Label1: TLabel + AnchorSideTop.Side = asrCenter + Left = 8 + Height = 17 + Top = 16 + Width = 37 + Caption = 'Login:' + ParentColor = False + end + object UserEdit: TEdit + AnchorSideLeft.Control = ServerEdit + AnchorSideTop.Control = Label1 + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = Label2 + Left = 51 + Height = 37 + Top = 6 + Width = 95 + BorderSpacing.Right = 10 + TabOrder = 0 + Text = 'root' + end + object Label2: TLabel + AnchorSideLeft.Control = UserEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UserEdit + AnchorSideTop.Side = asrCenter + Left = 156 + Height = 17 + Top = 16 + Width = 61 + BorderSpacing.Left = 10 + Caption = 'Password:' + ParentColor = False + end + object PasswordEdit: TEdit + AnchorSideLeft.Control = Label2 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label2 + AnchorSideTop.Side = asrCenter + Left = 220 + Height = 37 + Top = 6 + Width = 187 + BorderSpacing.Left = 3 + TabOrder = 1 + end + object Label3: TLabel + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrCenter + Left = 8 + Height = 17 + Top = 58 + Width = 40 + Caption = 'Server:' + ParentColor = False + end + object ServerEdit: TEdit + AnchorSideLeft.Control = Label3 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = UserEdit + AnchorSideTop.Side = asrBottom + Left = 51 + Height = 37 + Top = 48 + Width = 221 + BorderSpacing.Left = 3 + BorderSpacing.Top = 5 + BorderSpacing.Right = 10 + TabOrder = 2 + end + object ClearBox: TCheckBox + AnchorSideTop.Control = LatencyBox + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 283 + Height = 32 + Top = 134 + Width = 242 + Anchors = [akTop, akRight] + BorderSpacing.Right = 6 + Caption = 'Clear browser cookies on start GUI' + OnChange = ClearBoxChange + TabOrder = 7 + end + object AutoStartBox: TCheckBox + AnchorSideLeft.Control = StartBtn + AnchorSideTop.Control = IPv6Box + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 343 + Height = 32 + Top = 100 + Width = 182 + Anchors = [akTop, akRight] + BorderSpacing.Right = 6 + Caption = 'Autostart VPN on reboot' + OnChange = AutoStartBoxChange + TabOrder = 5 + end + object StartBtn: TSpeedButton + AnchorSideLeft.Control = Shape1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PasswordEdit + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = PortEdit + AnchorSideBottom.Side = asrBottom + Left = 433 + Height = 79 + Top = 6 + Width = 92 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Right = 6 + Caption = 'Start' + Font.Height = -15 + Font.Name = 'Sans' + Font.Style = [fsBold] + OnClick = StartBtnClick + ParentFont = False + end + object StaticText1: TStaticText + Left = 0 + Height = 20 + Top = 155 + Width = 531 + Align = alBottom + BorderStyle = sbsSingle + Caption = 'License: GPLv3 Author: alex_q_2000 (C) 2023 URL: https://linuxforum.ru' + Font.Color = clGray + Font.Height = -11 + Font.Name = 'Sans' + ParentFont = False + TabOrder = 8 + end + object Shape1: TShape + AnchorSideLeft.Control = PasswordEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = StartBtn + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = StartBtn + Left = 416 + Height = 12 + Top = 39 + Width = 12 + BorderSpacing.Left = 9 + BorderSpacing.Right = 5 + Brush.Color = clYellow + Shape = stCircle + end + object Label4: TLabel + AnchorSideLeft.Control = ServerEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = PortEdit + Left = 282 + Height = 17 + Top = 58 + Width = 29 + BorderSpacing.Right = 3 + Caption = 'Port:' + ParentColor = False + end + object PortEdit: TEdit + AnchorSideLeft.Control = Label4 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ServerEdit + AnchorSideRight.Control = PasswordEdit + AnchorSideRight.Side = asrBottom + Left = 314 + Height = 37 + Top = 48 + Width = 93 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 3 + TabOrder = 3 + Text = '22' + end + object IPv6Box: TCheckBox + AnchorSideTop.Control = ServerEdit + AnchorSideTop.Side = asrBottom + Left = 8 + Height = 32 + Top = 100 + Width = 120 + BorderSpacing.Top = 15 + Caption = '--disable-ipv6' + TabOrder = 4 + end + object LatencyBox: TCheckBox + AnchorSideTop.Control = IPv6Box + AnchorSideTop.Side = asrBottom + Left = 8 + Height = 32 + Top = 134 + Width = 161 + BorderSpacing.Top = 2 + Caption = '--no-latency-control' + Checked = True + State = cbChecked + TabOrder = 6 + end + object IniPropStorage1: TIniPropStorage + StoredValues = <> + Left = 216 + Top = 96 + end +end diff --git a/sshuttle-gui/unit1.lrj b/sshuttle-gui/unit1.lrj new file mode 100644 index 0000000..b8afd82 --- /dev/null +++ b/sshuttle-gui/unit1.lrj @@ -0,0 +1,15 @@ +{"version":1,"strings":[ +{"hash":11526233,"name":"tmainform.caption","sourcebytes":[83,83,104,117,116,116,108,101,45,71,85,73],"value":"SShuttle-GUI"}, +{"hash":87416858,"name":"tmainform.label1.caption","sourcebytes":[76,111,103,105,110,58],"value":"Login:"}, +{"hash":497252,"name":"tmainform.useredit.text","sourcebytes":[114,111,111,116],"value":"root"}, +{"hash":179191546,"name":"tmainform.label2.caption","sourcebytes":[80,97,115,115,119,111,114,100,58],"value":"Password:"}, +{"hash":164219914,"name":"tmainform.label3.caption","sourcebytes":[83,101,114,118,101,114,58],"value":"Server:"}, +{"hash":189380409,"name":"tmainform.clearbox.caption","sourcebytes":[67,108,101,97,114,32,98,114,111,119,115,101,114,32,99,111,111,107,105,101,115,32,111,110,32,115,116,97,114,116,32,71,85,73],"value":"Clear browser cookies on start GUI"}, +{"hash":104586580,"name":"tmainform.autostartbox.caption","sourcebytes":[65,117,116,111,115,116,97,114,116,32,86,80,78,32,111,110,32,114,101,98,111,111,116],"value":"Autostart VPN on reboot"}, +{"hash":5941396,"name":"tmainform.startbtn.caption","sourcebytes":[83,116,97,114,116],"value":"Start"}, +{"hash":245811237,"name":"tmainform.statictext1.caption","sourcebytes":[76,105,99,101,110,115,101,58,32,71,80,76,118,51,32,32,32,65,117,116,104,111,114,58,32,97,108,101,120,95,113,95,50,48,48,48,32,40,67,41,32,50,48,50,51,32,32,32,85,82,76,58,32,104,116,116,112,115,58,47,47,108,105,110,117,120,102,111,114,117,109,46,114,117],"value":"License: GPLv3 Author: alex_q_2000 (C) 2023 URL: https://linuxforum.ru"}, +{"hash":5728634,"name":"tmainform.label4.caption","sourcebytes":[80,111,114,116,58],"value":"Port:"}, +{"hash":850,"name":"tmainform.portedit.text","sourcebytes":[50,50],"value":"22"}, +{"hash":30708486,"name":"tmainform.ipv6box.caption","sourcebytes":[45,45,100,105,115,97,98,108,101,45,105,112,118,54],"value":"--disable-ipv6"}, +{"hash":145970412,"name":"tmainform.latencybox.caption","sourcebytes":[45,45,110,111,45,108,97,116,101,110,99,121,45,99,111,110,116,114,111,108],"value":"--no-latency-control"} +]} diff --git a/sshuttle-gui/unit1.pas b/sshuttle-gui/unit1.pas new file mode 100644 index 0000000..cf1d130 --- /dev/null +++ b/sshuttle-gui/unit1.pas @@ -0,0 +1,215 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, + ComCtrls, ExtCtrls, IniPropStorage, Process, DefaultTranslator; + +type + + { TMainForm } + + TMainForm = class(TForm) + IPv6Box: TCheckBox; + LatencyBox: TCheckBox; + ClearBox: TCheckBox; + AutoStartBox: TCheckBox; + PortEdit: TEdit; + Label4: TLabel; + UserEdit: TEdit; + PasswordEdit: TEdit; + ServerEdit: TEdit; + IniPropStorage1: TIniPropStorage; + Label1: TLabel; + Label2: TLabel; + Label3: TLabel; + Shape1: TShape; + StartBtn: TSpeedButton; + StaticText1: TStaticText; + procedure AutoStartBoxChange(Sender: TObject); + procedure ClearBoxChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure StartBtnClick(Sender: TObject); + procedure StartProcess(command: string); + + private + + public + + end; + +var + MainForm: TMainForm; + +resourcestring + + SStart = 'Start'; + SStop = 'Stop'; + +implementation + +uses pingtrd; + +{$R *.lfm} + +{ TMainForm } + +//Общая процедура запуска команд (асинхронная) +procedure TMainForm.StartProcess(command: string); +var + ExProcess: TProcess; +begin + Application.ProcessMessages; + ExProcess := TProcess.Create(nil); + try + ExProcess.Executable := '/bin/bash'; + ExProcess.Parameters.Add('-c'); + ExProcess.Parameters.Add(command); + // ExProcess.Options := ExProcess.Options + [poWaitOnExit]; + ExProcess.Execute; + finally + ExProcess.Free; + end; +end; + +//Проверка чекбокса ClearBox (очистка кеш/cookies) +function CheckClear: boolean; +begin + if FileExists('/etc/sshuttle-gui/clear') then + Result := True + else + Result := False; +end; + +//Проверка чекбокса AutoStart +function CheckAutoStart: boolean; +var + S: ansistring; +begin + RunCommand('/bin/bash', ['-c', + '[[ -n $(systemctl is-enabled sshuttle | grep "enabled") ]] && echo "yes"'], + S); + + if Trim(S) = 'yes' then + Result := True + else + Result := False; +end; + +procedure TMainForm.FormCreate(Sender: TObject); +var + FCheckPingThread: TThread; +begin + MainForm.Caption := Application.Title; + + //Каталог ключей и Рабочая директория + if not DirectoryExists('/root/.ssh') then MkDir('/root/.ssh'); + if not DirectoryExists('/etc/sshuttle-gui') then MkDir('/etc/sshuttle-gui'); + + IniPropStorage1.IniFileName := '/etc/sshuttle-gui/settings.conf'; + + //Поток проверки пинга + FCheckPingThread := CheckPing.Create(False); + FCheckPingThread.Priority := tpNormal; +end; + +procedure TMainForm.ClearBoxChange(Sender: TObject); +var + S: ansistring; +begin + if not ClearBox.Checked then + RunCommand('/bin/bash', ['-c', 'rm -f /etc/sshuttle-gui/clear'], S) + else + RunCommand('/bin/bash', ['-c', 'touch /etc/sshuttle-gui/clear'], S); +end; + +procedure TMainForm.AutoStartBoxChange(Sender: TObject); +var + S: ansistring; +begin + Screen.Cursor := crHourGlass; + Application.ProcessMessages; + + if not AutoStartBox.Checked then + RunCommand('/bin/bash', ['-c', 'systemctl disable sshuttle.service'], S) + else + RunCommand('/bin/bash', ['-c', 'systemctl enable sshuttle.service'], S); + Screen.Cursor := crDefault; +end; + +procedure TMainForm.FormShow(Sender: TObject); +begin + //IniPropStorage1.Restore; + + //Высота/Ширина формы (Auto) + MainForm.Height := ClearBox.Top + ClearBox.Height + StaticText1.Height + 5; + MainForm.Width := StartBtn.Left + StartBtn.Height + 25; + + AutostartBox.Checked := CheckAutoStart; + ClearBox.Checked := CheckClear; +end; + +//Start VPN +procedure TMainForm.StartBtnClick(Sender: TObject); +var + Pars: string; + S: TStringList; +begin + //Проверка на пустоту + if (Trim(UserEdit.Text) = '') or (Trim(PasswordEdit.Text) = '') or + (Trim(ServerEdit.Text) = '') or (Trim(PortEdit.Text) = '') then Exit; + + IniPropStorage1.Save; + + //Дополнительные параметры + Pars := ''; + if IPv6Box.Checked then Pars := IPv6Box.Caption; + if LatencyBox.Checked then Pars := Concat(Pars, ' ', LatencyBox.Caption); + + //Старт/Стоп VPN (ip(6)tables -L -t nat) - используется таблица ip(6)tables + //Цепочки очищаются после останова: systemctl stop sshuttle + if StartBtn.Caption = SStop then + begin + Shape1.Brush.Color := clYellow; + StartProcess('systemctl stop sshuttle.service'); + end + else + try + S := TStringList.Create; + + S.Add('#!/bin/bash'); + S.Add(''); + + //Содаём пускач для systemd (Type=simple) + S.Add('# Проверка наличия валидных ключей /root/.ssh/{known_hosts,known_hosts.old}'); + S.Add('if [[ ! -f /root/.ssh/known_hosts.old ]] || [[ -z $(ssh-keygen -F ' + + Trim(ServerEDit.Text) + ') ]]; then'); + S.Add('sshpass -p "' + Trim(PasswordEdit.Text) + + '" ssh -o StrictHostKeyChecking=No ' + Trim(UserEdit.Text) + + '@' + Trim(ServerEDit.Text) + ' -p ' + Trim(PortEdit.Text) + ' exit 0; fi'); + S.Add(''); + S.Add('# Запуск vpn'); + S.Add('[[ "$?" -eq "0" ]] && \'); + S.Add('sshpass -p "' + Trim(PasswordEdit.Text) + + '" sshuttle --dns --remote ' + Trim(UserEdit.Text) + '@' + + Trim(ServerEDit.Text) + ':' + Trim(PortEdit.Text) + ' -x ' + + Trim(ServerEDit.Text) + ':' + Trim(PortEdit.Text) + ' 0/0 ' + Trim(Pars)); + + S.Add('exit 0;'); + + S.SaveToFile('/etc/sshuttle-gui/connect.sh'); + + //Запускаем скрипт через systemd + StartProcess('chmod +x /etc/sshuttle-gui/connect.sh; systemctl restart sshuttle.service'); + + finally + S.Free; + end; +end; + + +end.