Compare commits

...

712 Commits

Author SHA1 Message Date
Mazay B
1b75b68373 Fix in AndroidController [NO CI] 2023-06-18 17:49:03 +01:00
pokamest
a116774104 Bugfix/macos fixes (#247)
* Icon for macos and tiny fixes
* Macos deploy build fix
2023-05-28 16:24:00 +01:00
pokamest
adcc74ac8e Merge pull request #245 from amnezia-vpn/fix/ui_fixes
Tiny ui fixes
2023-05-24 08:17:40 -07:00
pokamest
3e0085b4a4 PopupWithQuestion.qml fix 2023-05-24 16:12:07 +01:00
pokamest
17fb2a98d6 Fix question when removing server from list 2023-05-24 12:18:40 +01:00
Mykola Baibuz
780efc2477 OpenVPN over Cloak for Android and iOS (#158)
OpenVPN over Cloak for Android and iOS
2023-05-23 23:50:36 +01:00
pokamest
7f02fe4157 Merge pull request #244 from amnezia-vpn/bugfix/ios_import_configs
Import configs for iOS
2023-05-23 08:10:46 -07:00
pokamest
f722576bf2 Merge pull request #241 from amnezia-vpn/bugfix/cloak_for_desktops_fix
Fixes for Cloak proto
2023-05-23 08:00:15 -07:00
pokamest
7fecc2cf4c Merge pull request #242 from i-ky/badge-link
Make build status badge into a link
2023-05-23 07:54:02 -07:00
pokamest
3519e070b4 Merge pull request #243 from i-ky/linguist
Mark client/3rd/ as vendored code
2023-05-23 07:53:17 -07:00
i-ky
25d7e121c9 Mark client/3rd/ as vendored code 2023-05-22 14:21:02 +03:00
i-ky
882077f0aa Make build status badge into a link 2023-05-22 13:30:03 +03:00
pokamest
b5b69ff369 Fixes for Cloak proto 2023-05-20 18:44:19 +01:00
i-ky
f0ad76fff6 Gitpod integration (#240)
Add Gitpod configuration
2023-05-20 15:55:19 +01:00
amnezia-developer
e651ea7614 Add Qt Multimedia to project (#236)
Add Qt Multimedia to iOS cmake project
2023-05-17 20:38:28 +01:00
pokamest
230f44f4e6 Import configs for iOS [WIP] 2023-05-15 17:57:35 -07:00
Nethius
19c42490e3 feature/versioning-for-desktop (#181)
Project refactoring and cleanup
2023-05-16 01:34:06 +01:00
Mykola Baibuz
8a8d38a30f Prevent ipv6 leak (#224)
Prevent ipv6 leak for OpenVPN
2023-04-25 16:34:17 +01:00
pokamest
6429ff0603 Merge pull request #228 from amnezia-vpn/bugfix/openvpn-crl-verify
bugfix/openvpn-crl-verify
2023-04-21 12:43:35 +01:00
vladimir.kuznetsov
f5057dfac4 removed crl-verify from client config
- specified full path to crl in server config
- added crl generation when setting up a container
2023-04-21 07:44:35 +03:00
pokamest
00d61def0b Merge pull request #226 from amnezia-vpn/bugfix/sftp-files-permissions
bugfix/sftp-files-permissions
2023-04-19 16:19:47 +01:00
vladimir.kuznetsov
f5a26c7116 set the value S_IRWXU for windows, so that when copying via sftp, the necessary permissions for the file are set 2023-04-19 17:58:03 +03:00
pokamest
54fba99bed Merge pull request #225 from amnezia-vpn/bugfix/tcp-port-busy-check
in the port busy check, for tcp now only LISTEN ports are checked
2023-04-19 14:09:49 +01:00
vladimir.kuznetsov
7216a8b923 in the port busy check, for tcp now only LISTEN ports are checked 2023-04-19 06:39:50 +03:00
pokamest
97e322ba22 Merge pull request #223 from amnezia-vpn/bugfix/tcp-port-busy-check
in the port busy check, for tcp only the local port is now checked
2023-04-18 18:26:59 +01:00
vladimir.kuznetsov
fc603f11ce in the port busy check, for tcp only the local port is now checked 2023-04-18 20:00:40 +03:00
pokamest
10bca290c3 Merge pull request #221 from amnezia-vpn/bugfix/check-sudo-for-root
skipping sudo check for root user
2023-04-18 11:54:29 +01:00
vladimir.kuznetsov
3dabaeb2c9 skipping sudo check for root user 2023-04-18 05:48:37 +03:00
pokamest
cf74b879c6 Merge pull request #219 from amnezia-vpn/change/client-management-update-page
change/client-management-update-page
2023-04-16 14:41:28 +01:00
vladimir.kuznetsov
0ae2a1f177 now, when onUpdateAllPages is called, the ClientInfoLogic and ClientManagementLogic pages will not be updated
- moved the Client Management button to the Advanced Settings page
-
2023-04-16 07:32:32 +03:00
pokamest
af29637163 Merge branch 'dev' 2023-04-11 18:00:54 +01:00
Josh Soref
7351fe9633 Spelling (#214)
Spelling fixed
2023-04-11 14:50:44 +01:00
pokamest
1a6b4a1188 Merge pull request #213 from amnezia-vpn/chore/qtssh-gitmodules
removed qtssh from gitmodules
2023-04-11 02:00:34 +01:00
vladimir.kuznetsov
8751dd3797 removed qtssh from gitmodules 2023-04-09 05:47:27 +03:00
pokamest
9a6df25280 Merge pull request #149 from amnezia-vpn/feature/qt6-client-management-panel
feature/qt6-client-management-panel
2023-04-08 19:33:09 +01:00
vladimir.kuznetsov
ada8912a1f Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into feature/qt6-client-management-panel 2023-04-08 19:03:10 +03:00
pokamest
de4245025c Merge pull request #189 from amnezia-vpn/feature/check-user-in-sudo
feature/check-user-in-sudo
2023-04-08 16:38:00 +01:00
vladimir.kuznetsov
f620f4a92e Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/check-user-in-sudo 2023-04-08 17:12:23 +03:00
pokamest
2ca85c7829 Merge pull request #212 from bakhtiyork/feature/qt6-libssh-support
CI/CD iOS build fix
2023-04-07 17:23:31 +01:00
bakhtiyork
8374404b0f iOS - cmake: disabling testing and programs 2023-04-07 11:21:44 +05:00
pokamest
c453c6c294 Merge pull request #139 from amnezia-vpn/feature/qt6-libssh-support
feature/qt6-libssh-support
2023-04-06 20:09:03 +01:00
pokamest
a5e5c3d941 Merge pull request #210 from amnezia-vpn/dev
Pre-release 3.0.4
2023-04-06 20:05:51 +01:00
pokamest
c242a08653 Merge pull request #193 from bakhtiyork/feature/qt6-libssh-support
iOS - libssh with mbedtls build
2023-04-06 18:04:25 +01:00
bakhtiyork
f931603203 Disabling symbol versioning for iOS 2023-04-06 20:33:12 +05:00
bakhtiyork
ef03a3d9d4 FindMbedTLS.cmake - adding mbedtls targets export 2023-04-06 05:59:42 +05:00
vladimir.kuznetsov
ccfc9f2ad2 added error handling for key authentication 2023-04-05 09:45:03 +03:00
vladimir.kuznetsov
b3456ee96c fixed variable name in addAlreadyInstalledContainersGui() function 2023-04-05 06:20:10 +03:00
vladimir.kuznetsov
05cd4ac14b Merge branch 'feature/qt6-libssh-support' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-04-05 06:08:15 +03:00
vladimir.kuznetsov
ba2ecf9789 fixed cleanup of private/public keys after use 2023-04-05 06:07:36 +03:00
pokamest
020e6b1cb3 Merge branch 'dev' into feature/qt6-libssh-support 2023-04-05 03:40:55 +01:00
pokamest
2a7365730b getOpenFileName fix 2023-04-05 03:39:05 +01:00
pokamest
ad77d74f4b Merge branch 'dev' into feature/qt6-libssh-support 2023-04-05 03:26:08 +01:00
pokamest
ef8668dce4 Merge pull request #205 from amnezia-vpn/fix/build_desktop_on_apple_silicon
Fix to build Amnezia desktop app on Apple Silicon
2023-04-05 01:51:31 +01:00
pokamest
3fb34e28a4 Merge pull request #207 from amnezia-vpn/bugfix/add-server-with-same-credentials
bugfix/add-server-with-same-credentials
2023-04-05 01:50:11 +01:00
pokamest
871214f907 Merge pull request #206 from amnezia-vpn/bugfix/server-busy-default-port
bugfix/server-busy-default-port
2023-04-05 01:48:20 +01:00
pokamest
7e717754a3 getOpenFileName fix for Android 2023-04-05 01:43:42 +01:00
vladimir.kuznetsov
6e67946ae2 Removed the ability to add multiple servers with the same connection credentials via the "Add server" button 2023-04-04 19:13:39 +03:00
vladimir.kuznetsov
48d673c853 fixed getting default port and default transport protocol in isServerPortBusy function 2023-04-04 18:20:19 +03:00
Dmitriy Karpushin
a9bb6f8099 Fix to build at least x86_64 version of Amnezia desktop app on Apple Silicon 2023-04-04 17:10:58 +03:00
vladimir.kuznetsov
f8ef69b88a removed setPassphraseCallback() function from ServerController and libssh::Client 2023-04-04 13:32:37 +03:00
vladimir.kuznetsov
a005ed2a84 now an instance of the serverController class is created at the place of use 2023-04-04 10:22:25 +03:00
vladimir.kuznetsov
1aa859b10d moved passphraseCallback and passphraseDialog to startPage
- made some methods of the servercontroller class private
- returned a call to the checkSshConnection() function
2023-04-04 07:09:30 +03:00
vladimir.kuznetsov
4aba34c18b Merge remote-tracking branch 'remotes/origin/dev' into feature/qt6-libssh-support 2023-04-03 17:48:55 +03:00
vladimir.kuznetsov
5e099f522e added private key export without password to client config 2023-04-03 17:27:55 +03:00
pokamest
15c33014e7 Merge pull request #198 from amnezia-vpn/bugfix/qssh-too-many-open-connections
bugfix/qssh-too-many-open-connections
2023-04-02 13:43:30 +01:00
vladimir.kuznetsov
af5b9172ef removed unused disconnectFromHost() from ServerController 2023-04-02 15:19:59 +03:00
bakhtiyork
fe9e813c79 Custom cmake module path 2023-04-02 17:19:21 +05:00
vladimir.kuznetsov
51d7cdfd31 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into bugfix/qssh-too-many-open-connections 2023-04-02 14:48:26 +03:00
vladimir.kuznetsov
f3aef67be6 Added a form for entering a passphrase for a private ssh key and the corresponding logic for processing a private key 2023-04-02 09:09:20 +03:00
pokamest
449af8060a Merge pull request #204 from amnezia-vpn/fix/android_config_import
Android config import
2023-03-29 22:16:16 +01:00
pokamest
fa19f1f5a0 Merge pull request #200 from amnezia-vpn/bugfix/empty-server-list-settings-availability
bugfix/empty-server-list-settings-availability
2023-03-29 15:17:25 +02:00
Dmitriy Karpushin
9e461ef6e1 Fixed import from external applications 2023-03-29 16:16:54 +03:00
pokamest
1ba301ed16 Merge pull request #201 from amnezia-vpn/bugfix/reset-container-settings-after-adding-new-one
bugfix/reset-container-settings-after-adding-new-one
2023-03-29 15:16:34 +02:00
pokamest
7e663b05d5 Merge pull request #202 from amnezia-vpn/fix/android_various_fixes
Fix/android various fixes
2023-03-29 15:15:17 +02:00
Dmitriy Karpushin
2225a735ca Fixed typo 2023-03-29 12:01:18 +03:00
Dmitriy Karpushin
90c8fbb495 Update Room to fix build on Apple M1 2023-03-29 09:53:18 +03:00
vladimir.kuznetsov
2b14efd3f8 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into bugfix/qssh-too-many-open-connections 2023-03-29 09:44:28 +03:00
vladimir.kuznetsov
3261c36f97 changed the existsAnyServer value to properly display locked settings 2023-03-29 09:44:06 +03:00
vladimir.kuznetsov
c48d65525a set m_installCredentials when visiting the ServerContainers page 2023-03-29 09:44:00 +03:00
vladimir.kuznetsov
5fa6e755b2 changed the existsAnyServer value to properly display locked settings 2023-03-29 09:39:56 +03:00
vladimir.kuznetsov
8bbc0b9e1a set m_installCredentials when visiting the ServerContainers page 2023-03-29 09:38:00 +03:00
Dmitriy Karpushin
3a5317f16a Implementation of "migration manager" to fix placement of config files issue appeared after moving from Qt 5 to Qt 6 2023-03-29 09:31:24 +03:00
Dmitriy Karpushin
c0bb06bf49 Fix of copying to clipboard 2023-03-29 09:31:12 +03:00
Dmitriy Karpushin
8d45af2034 Files now saving with the file picker, not with the sharing mechanism 2023-03-29 09:31:02 +03:00
Dmitriy Karpushin
5f85bf62f5 Missing def check 2023-03-29 09:30:52 +03:00
Dmitriy Karpushin
8fa409d6c1 Restoration of bandwidth meter after closing of GUI 2023-03-29 09:30:45 +03:00
Dmitriy Karpushin
7167c2f20d Fix of "Connect" button state after restoring of an app 2023-03-29 09:29:55 +03:00
Dmitriy Karpushin
20846c8eff * correct behavior of back button on Android
* removing of annoying debug logs on Android
2023-03-29 09:29:06 +03:00
pokamest
1b44a01efd Merge pull request #195 from cyBerta/focus
Camera focus when reading QR
2023-03-28 15:21:54 +02:00
pokamest
c4104dcd33 Merge pull request #196 from cyBerta/android_dev_onboarding
Android dev onboarding documentation
2023-03-28 15:20:53 +02:00
vladimir.kuznetsov
c319c3f520 changed the way to get QSsh::SshConnection, now all resources are cleaned up after use, but the disconnectFromHost function becomes useless 2023-03-27 08:17:41 +03:00
cyberta
85025695df add a section about how to get started for Android developers 2023-03-26 13:59:12 +02:00
vladimir.kuznetsov
f6ca22ecdd Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-03-26 11:52:22 +03:00
cyberta
8d9594ba36 add auto-focus to CameraActivity 2023-03-25 23:56:55 +01:00
pokamest
fe7c66cf1d Merge pull request #194 from amnezia-vpn/bugfix/clear-server-from-amnezia
bugfix/clear-server-from-amnezia
2023-03-25 13:33:23 +00:00
vladimir.kuznetsov
b5aa940701 added removal of stopped containers 2023-03-25 15:50:12 +03:00
bakhtiyork
698dfb67d1 iOS - libssh with mbedtls build 2023-03-24 11:41:27 +05:00
pokamest
38f2f1a3e4 Merge pull request #179 from amnezia-vpn/feature/linux-wireguard-implementation
feature/linux-wireguard-implementation
2023-03-21 23:49:39 +00:00
pokamest
b98c6ca5c5 Merge pull request #192 from amnezia-vpn/bugfix/check-server-port-on-dns-container
bugfix/check-server-port-on-dns-container
2023-03-21 23:08:03 +00:00
vladimir.kuznetsov
5641874811 added skip port busy check for DNS container.
- added script execution error check when checking ports busy
2023-03-20 17:29:23 +03:00
pokamest
1dd34035c9 Merge pull request #190 from amnezia-vpn/bugfix/empty-port-when-check-server-ports
bugfix/empty-port-when-check-server-ports
2023-03-20 12:50:08 +00:00
vladimir.kuznetsov
6bf170e273 Merge branch 'bugfix/empty-port-when-check-server-ports' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-03-20 08:53:00 +03:00
vladimir.kuznetsov
084ac9b916 added a default port if it is not in the config when scanning the server for busy ports 2023-03-20 08:50:57 +03:00
vladimir.kuznetsov
cebf061f85 Merge branch 'feature/qt6-libssh-support' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-03-20 05:47:37 +03:00
vladimir.kuznetsov
5641db0026 uncommented static link for qtkeychain 2023-03-20 05:45:53 +03:00
vladimir.kuznetsov
a42ec8eddb Merge branch 'feature/qt6-libssh-support' of github.com:amnezia-vpn/desktop-client into feature/check-user-in-sudo 2023-03-19 18:04:55 +03:00
vladimir.kuznetsov
ea9917dacc added a script to check the user in the sudo group
- move isServerDpkgBusy to separate script
2023-03-19 17:26:43 +03:00
vladimir.kuznetsov
6272ae842c Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-03-19 17:23:18 +03:00
vladimir.kuznetsov
b000eda126 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-client-management-panel 2023-03-19 17:15:13 +03:00
vladimir.kuznetsov
9962bac50b changed using cp to QFile to copy wireguard config 2023-03-19 17:05:48 +03:00
vladimir.kuznetsov
f0c3f1b9ba Merge branch 'feature/linux-wireguard-implementation' of github.com:amnezia-vpn/desktop-client into feature/linux-wireguard-implementation 2023-03-19 15:32:07 +03:00
vladimir.kuznetsov
ec8eeef428 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/linux-wireguard-implementation 2023-03-19 15:06:17 +03:00
pokamest
7eb1a4b489 Fixed certutil path on Windows 2023-03-19 11:58:22 +00:00
pokamest
23b23f0e38 Merge branch 'dev' into feature/linux-wireguard-implementation 2023-03-17 16:18:56 +00:00
pokamest
cba78190a8 iOS build fix 2023-03-16 11:43:18 -07:00
pokamest
e097a49186 Merge pull request #184 from amnezia-vpn/bugfix/fake-web-site-label-wizard
bugfix/fake-web-site-label-wizard
2023-03-16 16:57:29 +00:00
pokamest
e895c784c7 Merge pull request #183 from amnezia-vpn/bugfix/installed-container-button
bugfix/installed-container-button
2023-03-16 16:56:30 +00:00
vladimir.kuznetsov
7e1bcf84f0 fixed saving site from "fake web site" field when configuring openvpn over cloak via wizard 2023-03-16 18:59:06 +03:00
vladimir.kuznetsov
a92f1b82d0 fixed a bug with incorrect port detection when clicking the "scan installed containers" button 2023-03-16 16:47:26 +03:00
vladimir.kuznetsov
433e6901c6 fixed a bug when existing containers were overwritten in the GUI when clicking the "scan installed containers" button 2023-03-16 16:46:29 +03:00
pokamest
e16d835727 CentOS docker autostart fix 2023-03-16 12:35:01 +00:00
pokamest
a5cf2d37d4 Merge pull request #180 from amnezia-vpn/fix/target_sdk_31
Support of targetSdk 31 with its behaviour changes
2023-03-06 12:02:15 +00:00
Dmitriy Karpushin
4bd6fbd445 Support of targetSdk 31 with its behaviour changes 2023-03-06 12:11:37 +03:00
vladimir.kuznetsov
8f18933713 moved the function of checking the availability of wireguard config to ipc client 2023-03-02 17:46:16 +03:00
vladimir.kuznetsov
caad670dbf added wireguard connection implementation for Linux 2023-03-02 10:19:57 +03:00
vladimir.kuznetsov
2d30f86cc6 removed unused qtssh folder 2023-02-28 06:15:01 +03:00
pokamest
1dd79d9e31 Merge pull request #169 from amnezia-vpn/feature/container-existence-on-container-setup
feature/container-existence-on-container-setup
2023-02-27 22:27:10 +00:00
vladimir.kuznetsov
4171afe275 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-client-management-panel 2023-02-27 19:59:01 +03:00
vladimir.kuznetsov
a287192649 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-02-27 19:53:53 +03:00
vladimir.kuznetsov
f2e9631af4 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/container-existence-on-container-setup 2023-02-27 19:42:47 +03:00
pokamest
c756ab70ae Merge pull request #168 from amnezia-vpn/feature/port-availability-on-container-setup
feature/port-availability-on-container-setup
2023-02-27 03:26:57 +00:00
pokamest
2e57fe0dfd Merge pull request #177 from amnezia-vpn/feature/android_qr_code_scanner
Qr-code scanner for Android
2023-02-27 00:23:33 +00:00
vladimir.kuznetsov
be39d28be7 renamed selectedServerIndex for android 2023-02-25 18:48:10 +03:00
vladimir.kuznetsov
23a292b8ff Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/container-existence-on-container-setup 2023-02-25 18:22:08 +03:00
vladimir.kuznetsov
cdbb247780 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/port-availability-on-container-setup 2023-02-25 18:21:23 +03:00
vladimir.kuznetsov
69d4f0ce10 removed ContainerProps::containerTypeToString 2023-02-25 18:17:25 +03:00
vladimir.kuznetsov
2580475f67 added a button to scan the server for already installed containers
- refactoring of old code, redundant sections of code removed
2023-02-25 17:59:22 +03:00
pokamest
138789149c Merge branch 'dev' into feature/qt6-libssh-support 2023-02-23 18:46:43 +00:00
pokamest
1be66659d3 Merge pull request #178 from amnezia-vpn/bugfix/linux-missing-lib
bugfix/linux-missing-lib
2023-02-23 18:11:48 +00:00
vladimir.kuznetsov
6d3ba0ae72 added installation of libxkbcommon-x11-0 package for linux runner 2023-02-23 17:32:32 +03:00
vladimir.kuznetsov
04f61677d7 static link for qtkeychain 2023-02-23 17:28:19 +03:00
Dmitriy Karpushin
0096e65fe6 Increased build tools version 2023-02-22 14:48:38 +03:00
Dmitriy Karpushin
b870306c5d Support of multiple-code config 2023-02-22 14:22:03 +03:00
vladimir.kuznetsov
480b2181f0 made error output in the same style
- some code style refactoring
2023-02-22 10:01:43 +03:00
vladimir.kuznetsov
ddc3fe7807 Added the advanced settings page
- added a button to scan the server for installed containers
- added a check on the presence of installed containers before configuring the server, if the containers are already installed, then we will add them to the GUI
- added new control element - PopupWarning.qml
2023-02-20 09:46:50 +03:00
Dmitriy Karpushin
a86e8659f7 CameraActivity with Google ML KIT for decoding QR codes 2023-02-17 16:38:44 +03:00
pokamest
ae10dd639b Merge branch 'dev' into feature/qt6-libssh-support 2023-02-17 01:47:25 +00:00
Shahzain Ali
a0141624b9 Wg fix (#172)
Build fix for iOS
2023-02-15 15:41:18 +00:00
vladimir.kuznetsov
dc137620eb Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/port-availability-on-container-setup 2023-02-14 18:03:19 +03:00
vladimir.kuznetsov
e9b92b216a added a check for port availability when installing up a container
- added wireguard service copying to debug build folder
2023-02-14 18:02:51 +03:00
Nethius
24bf057d17 Merge pull request #174 from amnezia-vpn/fix/qt6_libssh_andorid_build
Fixed libssh android build
2023-02-13 18:13:34 +03:00
Dmitriy Karpushin
b68c6b6807 Little refactoring 2023-02-13 10:42:47 +03:00
pokamest
34a268624b Merge pull request #166 from amnezia-vpn/bugfix/wrong-fields-type-shadowsocks-config
bugfix/wrong-fields-type-shadowsocks-config
2023-02-10 20:22:42 +00:00
Dmitriy Karpushin
cdd527f3ac little fix 2023-02-10 13:57:15 +03:00
pokamest
1f048a6d04 Merge branch 'dev' into bugfix/wrong-fields-type-shadowsocks-config 2023-02-09 13:10:26 +00:00
pokamest
58cf10ffb2 Merge pull request #173 from amnezia-vpn/feature/deploy-unpacked-binaries
feature/added-deploy-binaries-that-are-not-packed-into-the-installer
2023-02-09 13:08:37 +00:00
pokamest
1ef14e129f Update deploy.yml 2023-02-09 11:15:50 +00:00
Dmitriy Karpushin
7c4030aaef fix macos build 2023-02-08 19:09:24 +03:00
Dmitriy Karpushin
c1bf0f8799 [WIP] dynamic linking 2023-02-08 16:06:18 +03:00
vladimir.kuznetsov
4b0a4aa5d2 removed unused code 2023-02-08 16:06:18 +03:00
vladimir.kuznetsov
115be88e5d added check for nullptr in sshclient 2023-02-08 16:06:18 +03:00
vladimir.kuznetsov
268bd8f1a6 added deploy binaries that are not packed into the installer 2023-02-08 09:44:52 +03:00
pokamest
1d9ff17380 Merge pull request #170 from amnezia-vpn/bugfix/cmake-version
bugfix/cmake-version
2023-02-07 17:05:55 +00:00
vladimir.kuznetsov
0fa0d72300 increased required version of cmake for LINUX variable to work properly 2023-02-07 19:45:42 +03:00
pokamest
677d166b1e Merge pull request #164 from amnezia-vpn/feature/cloak-and-ss-in-linux-bundle
feature/cloak-and-ss-in-linux-bundle
2023-02-07 16:27:04 +00:00
vladimir.kuznetsov
b5778a9cb5 if the container already exists, then add it to the list of containers in the client 2023-02-07 10:39:18 +03:00
vladimir.kuznetsov
b2fd94d20e added a check for the existence of the container before installing it 2023-02-06 19:19:49 +03:00
vladimir.kuznetsov
16969bc39b added conversion of the local_port and server_port fields from string to number when saving the shadowsocks config 2023-02-06 08:39:56 +03:00
Dmitriy Karpushin
3943314142 Fix of android build 2023-02-03 19:07:09 +03:00
vladimir.kuznetsov
f7ee532add Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/cloak-and-ss-in-linux-bundle 2023-02-02 13:08:23 +03:00
pokamest
2fdab4c196 Merge pull request #165 from amnezia-vpn/bugfix/cloak-transport-protocol
bugfix/cloak-transport-protocol
2023-02-02 09:17:00 +00:00
vladimir.kuznetsov
e6a95370c1 removed unused code 2023-02-02 08:36:50 +03:00
vladimir.kuznetsov
92907bced3 hardcoded tcp for the openvpn-cloak container 2023-02-02 08:09:07 +03:00
Dmitriy Karpushin
ca30b8b62a Correct path for openssl static lib 2023-02-01 17:16:45 +03:00
vladimir.kuznetsov
da9ac6ff25 added check for nullptr in sshclient 2023-02-01 09:56:55 +03:00
Dmitriy Karpushin
475de5250e New HEAD of qtkeychain (qt6 support) 2023-01-31 18:02:04 +03:00
Dmitriy Karpushin
7a9860ac29 OpenSSL for android build 2023-01-31 17:12:52 +03:00
pokamest
32ca02bcc7 Crash fix on VPN connection 2023-01-31 01:38:49 +00:00
pokamest
ddefb99e5e Merge branch 'dev' into feature/qt6-libssh-support 2023-01-31 00:53:24 +00:00
pokamest
ca4d6e0b2f Android cmake build fix 2023-01-31 00:47:01 +00:00
pokamest
c3fc3a3132 Merge pull request #163 from amnezia-vpn/feature/confirm-on-clear-and-delete-server
feature/confirm-on-clear-and-delete-server
2023-01-30 20:45:35 +00:00
pokamest
78b8a1c36f Merge pull request #162 from amnezia-vpn/bugfix/cloak-transport-protocol
bugfix/cloak-transport-protocol
2023-01-30 20:43:15 +00:00
pokamest
638c3492d6 Merge pull request #159 from amnezia-vpn/bugfix/linux-uninstall
bugfix/linux-uninstall
2023-01-30 20:37:46 +00:00
vladimir.kuznetsov
4c1699935c added binaries for cloak and shadowsocks to Linux bundle 2023-01-30 12:41:51 +03:00
vladimir.kuznetsov
25829451c8 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-client-management-panel 2023-01-29 09:52:12 +03:00
vladimir.kuznetsov
74fbce8b96 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2023-01-29 09:43:03 +03:00
vladimir.kuznetsov
542039df01 Changed notification text for "Forget this server" action 2023-01-29 09:01:48 +03:00
vladimir.kuznetsov
d652ecff21 For the openvpn-cloak container, the choice of the transport protocol in the openvpn settings is blocked 2023-01-29 08:39:31 +03:00
vladimir.kuznetsov
00c4cf300a fixed the width of the buttons in popupWithQuestion 2023-01-27 19:56:39 +03:00
vladimir.kuznetsov
da47054497 changed element type to confirm container deletion from MessageDialog to PopupWithQuestion
- fixed "back" button availability for readonly servers
2023-01-27 18:37:08 +03:00
vladimir.kuznetsov
051a2a3ef2 Added popup to confirm actions "Clear server from Amnesia software" and "Forget this server" 2023-01-27 10:25:14 +03:00
vladimir.kuznetsov
ee609f3e8f fixed warning with QFutureWatcher
- renamed readWireguardConfiguration function to match what it does
2023-01-24 09:43:45 +03:00
vladimir.kuznetsov
eb66354c76 fixed path to maintenancetool in linux
- added x11 to runningOnLinux() function
2023-01-22 08:26:29 +03:00
vladimir.kuznetsov
c7fb7e58cf Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into bugfix/linux-uninstall 2023-01-21 10:35:29 +03:00
vladimir.kuznetsov
c2b02a45a2 fixed path to linux install folderfixed path to installed application in linux 2023-01-21 10:35:01 +03:00
pokamest
e7ed532545 Disable fastline for iOS while it not fixed 2023-01-19 21:08:57 +00:00
pokamest
2a031320c2 Merge pull request #156 from amnezia-vpn/bugfix/wrong-artifacts-size
added qtshadertools to all targets
2023-01-19 20:59:00 +00:00
vladimir.kuznetsov
d0379fdede added qtshadertools to all targets 2023-01-19 18:36:54 +03:00
vladimir.kuznetsov
45016b76e7 moved crl-verify crl.pem to openvpn config templates 2023-01-19 17:49:17 +03:00
pokamest
ee8cd8ef26 Merge pull request #118 from amnezia-vpn/qt_migration
Migration to Qt6
2023-01-19 13:09:00 +00:00
pokamest
18d89e9cad Merge pull request #152 from amnezia-vpn/feature/android_qt6_moving
Moving to Qt 6 and cmake on Android client
2023-01-19 12:51:02 +00:00
pokamest
623c8ca6b0 Merge pull request #155 from amnezia-vpn/feature/android_bandwidth_counter
Fix of bandwidth counter for Android
2023-01-19 12:38:55 +00:00
Dmitriy Karpushin
39736e865e Merge branch 'feature/android_qt6_moving' into feature/android_bandwidth_counter
# Conflicts:
#	client/platforms/android/android_controller.cpp
#	client/platforms/android/android_controller.h
2023-01-19 14:09:12 +03:00
vladimir.kuznetsov
8ea80a616e Merge branch 'qt_migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-client-management-panel 2023-01-18 20:06:01 +03:00
vladimir.kuznetsov
c5df7f9bb7 added diagrams describing the process of obtaining information about clients 2023-01-18 19:55:12 +03:00
Dmitriy Karpushin
92374966fb Removing of unnecessary command 2023-01-18 16:12:30 +03:00
Dmitriy Karpushin
6bebfb861c Little cleanup 2023-01-18 15:54:19 +03:00
Dmitriy Karpushin
30ae13b245 Fix of signing code 2023-01-18 15:38:06 +03:00
pokamest
891f990e35 Merge pull request #154 from amnezia-vpn/dev
Release 2.1.2
2023-01-18 12:22:18 +00:00
Dmitriy Karpushin
2118327ae0 Fixes in path of build 2023-01-18 14:47:11 +03:00
Dmitriy Karpushin
6aed2902a7 Fixes in path of build 2023-01-18 14:37:58 +03:00
Dmitriy Karpushin
e149e32ce1 Changing the set of highlights 2023-01-18 11:36:16 +03:00
Dmitriy Karpushin
41f2af8c4e Some highlights were added 2023-01-18 11:27:01 +03:00
Dmitriy Karpushin
016f808345 Removing of unnecessary command 2023-01-18 11:11:27 +03:00
Dmitriy Karpushin
bc69524654 Changing of path of keystore location 2023-01-18 11:06:58 +03:00
Dmitriy Karpushin
3c6280c419 Changing of path of keystore location 2023-01-18 10:54:24 +03:00
pokamest
9d01a52a4a Merge pull request #145 from amnezia-vpn/feature/qt6-server-busy-notification
feature/qt6-server-busy-notification
2023-01-18 00:43:13 +00:00
pokamest
a8273a8fdc Merge pull request #153 from amnezia-vpn/bugfix/some-ui-small-fixes
bugfix/some-ui-small-fixes
2023-01-18 00:41:11 +00:00
vladimir.kuznetsov
d6d3bf6943 moved certificate content acquisition from ClientManagementLogic to ClientInfoLogic 2023-01-17 21:04:15 +03:00
vladimir.kuznetsov
f6e8346841 moved getClientsList and setClientsList from serverController 2023-01-17 18:41:36 +03:00
vladimir.kuznetsov
b9717e9894 removed unused code 2023-01-17 17:11:45 +03:00
Dmitriy Karpushin
6b3209e6ee Changing of the way of keystore fetching 2023-01-17 16:59:34 +03:00
Dmitriy Karpushin
0a6da5ead1 Platform version fix 2023-01-17 16:23:34 +03:00
Dmitriy Karpushin
53441148b8 Revert of Gradle upgrade 2023-01-17 16:12:42 +03:00
Dmitriy Karpushin
732d018819 Revert "Shadowsocks manifest fix"
This reverts commit e261a8ba21.
2023-01-17 16:09:06 +03:00
Dmitriy Karpushin
e261a8ba21 Shadowsocks manifest fix 2023-01-17 15:53:54 +03:00
Dmitriy Karpushin
c3c87bff74 Fix of GitHub Actions build 2023-01-17 15:34:37 +03:00
Dmitriy Karpushin
c3f423aad5 Little cleanup 2023-01-17 15:34:37 +03:00
pokamest
580975fda1 Merge branch 'qt_migration' into feature/qt6-server-busy-notification 2023-01-16 18:13:07 +00:00
pokamest
9f114a1dad Tiny fix [no ci] 2023-01-16 18:12:30 +00:00
pokamest
0ae93d0657 Merge pull request #144 from amnezia-vpn/refactoring/logging
refactoring/logging
2023-01-16 17:29:24 +00:00
vladimir.kuznetsov
3a210c5bab added wireguard key revocation 2023-01-16 20:24:37 +03:00
pokamest
44d2627e2a Tiny fix [no ci] 2023-01-16 17:11:00 +00:00
pokamest
6e882760f1 Merge branch 'qt_migration' into refactoring/logging 2023-01-16 16:10:39 +00:00
pokamest
ff79ffd1c8 Android tag deploy fix 2023-01-16 15:10:57 +00:00
vladimir.kuznetsov
3175b0c4ff Changed the indentation of the "Installed Protocols and Services" heading on the "Server Containers" page 2023-01-16 16:20:12 +03:00
Dmitry Karpushin
21779395ef Merge branch 'qt_migration' into feature/android_qt6_moving 2023-01-16 14:58:01 +03:00
Dmitriy Karpushin
32cbb698ee Support of apk signing for tag-deploy workflow 2023-01-16 14:30:08 +03:00
vladimir.kuznetsov
3f99c52349 change Flickable to FlickableType for ClientManagement and ClientInfo pages 2023-01-16 12:37:14 +03:00
vladimir.kuznetsov
19a41b2792 swapped "Clear client cached profile" and "Clear server from Amnesia software" buttons 2023-01-15 18:47:16 +03:00
vladimir.kuznetsov
599910daea added openvpn certificate revocation 2023-01-15 18:09:05 +03:00
vladimir.kuznetsov
bee42ea2fb fixed double call onEditingFinished when pressing Enter 2023-01-14 18:30:08 +03:00
vladimir.kuznetsov
221ea5ebb0 Merge branch 'qt_migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-server-busy-notification 2023-01-13 16:59:03 +03:00
vladimir.kuznetsov
f24df9fb05 Merge branch 'qt_migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-client-management-panel 2023-01-12 20:28:13 +03:00
vladimir.kuznetsov
ce2a122d51 added busy indicator when saving a list of clients, on the client info panel 2023-01-12 20:20:24 +03:00
Dmitriy Karpushin
e8242aec85 Android build script fix 2023-01-12 15:36:31 +03:00
Dmitriy Karpushin
6ed9dcbe93 Workflow build script fix 2023-01-12 15:19:39 +03:00
Dmitriy Karpushin
58371e6e43 New trigger for a workflow 2023-01-12 15:12:55 +03:00
Dmitriy Karpushin
2d8957489e Trigger alternative syntax 2023-01-12 14:55:11 +03:00
Dmitriy Karpushin
1fd0794bfb Workflow file formatting fix 2023-01-12 14:30:25 +03:00
Dmitriy Karpushin
58da60985f Error fix 2023-01-12 14:21:14 +03:00
Dmitriy Karpushin
6b6a3cd38e [WIP] Android release workflow test 2023-01-12 14:16:05 +03:00
pokamest
4b1df16ecf Merge pull request #148 from amnezia-vpn/feature/github-actions-artifacts
feature/github-actions-artifacts
2023-01-12 01:22:41 +00:00
vladimir.kuznetsov
24ea686e4d added busy indicator when loading a list of clients, on the client management panel 2023-01-11 21:36:18 +03:00
vladimir.kuznetsov
a7030cdcb9 added saving the list of clients for wireguard
- added error handling when getting/saving a list of clients
2023-01-11 20:36:47 +03:00
vladimir.kuznetsov
8c137ecc52 added page to display WireGuard client information 2023-01-10 16:21:45 +03:00
Dmitriy Karpushin
20e44aa891 Re-enabled multi-abi build 2023-01-10 13:19:19 +03:00
vladimir.kuznetsov
118bb53c03 fixed path to linux installer 2023-01-09 16:41:24 +03:00
Dmitriy Karpushin
7c3be9f0b0 Update of NDK version 2023-01-09 14:21:10 +03:00
Dmitriy Karpushin
d1990a4263 Adopted GitHub Actions build config for Qt6 2023-01-09 13:46:45 +03:00
vladimir.kuznetsov
396422ee3a increased storage time for artifacts up to 3 days 2023-01-09 12:44:36 +03:00
vladimir.kuznetsov
f735b401df added deploy artifacts to github actions, artifact lifetime 1 day 2023-01-09 12:41:04 +03:00
vladimir.kuznetsov
a42beb86c0 added client management panel
- added classes for displaying the client management panel
- added class for displaying the client info
- added page to display a list of clients
- added page to display OpenVpn client information
- added diagram with OpenVpn certificate revocation process
2023-01-09 12:38:01 +03:00
pokamest
85020270d5 MacOS deploy fix 2023-01-08 17:21:51 -08:00
pokamest
b1b9044021 Merge branch 'qt_migration' into refactoring/logging 2023-01-08 23:17:11 +00:00
pokamest
8da30b216f Cleanup 2023-01-08 23:10:46 +00:00
pokamest
167d3caa5d Merge branch 'dev' into qt_migration 2023-01-08 23:00:13 +00:00
pokamest
3259e6f0e8 Merge pull request #128 from amnezia-vpn/feature/ovpn-config-import
added import of configs in openvpn and wireguard formats
2023-01-08 22:26:39 +00:00
pokamest
64526c5232 Various ui fixes 2023-01-08 21:24:06 +00:00
pokamest
d9630afafd Merge branch 'dev' into feature/ovpn-config-import 2023-01-08 19:36:00 +00:00
pokamest
c8c6e62aa0 Merge pull request #141 from amnezia-vpn/add-scrollbar-on-flickables
Show Scrollbars whenever the scroll is not obvious
2023-01-08 12:32:55 +00:00
pokamest
7f561c30b3 Buttons margins 2023-01-08 12:32:07 +00:00
pokamest
1d8f342417 QML refactoring 2023-01-07 13:40:35 +00:00
vladimir.kuznetsov
6ec090ea0d added a "Cancel" button to interrupt the server configuration process when it is found that it is busy installing other software 2023-01-02 17:32:27 +03:00
vladimir.kuznetsov
08a8eadb49 added display of a notification that the server is busy installing third-party software
- refactoring doInstallAction functions
2023-01-01 22:08:39 +03:00
Dmitriy Karpushin
3e2835bef6 Rolling back GitHub Actions config 2022-12-29 15:04:42 +03:00
vladimir.kuznetsov
686fc754b2 renamed log class in service project to logger 2022-12-28 17:56:31 +03:00
Dmitriy Karpushin
ea17124d6d Fix of build type for GitHub Actions 2022-12-28 16:35:25 +03:00
Dmitriy Karpushin
4000041308 Fix of build type 2022-12-28 15:55:03 +03:00
Dmitriy Karpushin
1a50ed0316 Increased java version on runner 2022-12-28 14:45:45 +03:00
Dmitriy Karpushin
42038cd6e7 Fixed filenames 2022-12-28 14:26:44 +03:00
Dmitriy Karpushin
44c5b41cc7 Little fix 2022-12-28 13:57:41 +03:00
Dmitriy Karpushin
da7bd91514 Little fix 2022-12-28 13:52:14 +03:00
Dmitriy Karpushin
0206623c6f Correct way to set up QT_HOST_PATH variable 2022-12-28 13:42:29 +03:00
vladimir.kuznetsov
3b2948d4dd renamed debug class to logger 2022-12-28 13:41:45 +03:00
Dmitriy Karpushin
918aeb670e Added QT_HOST_PATH variable 2022-12-28 13:37:56 +03:00
Dmitriy Karpushin
fd9fec48a2 Replacing of qmake on cmake for GitHub Actions 2022-12-28 13:10:34 +03:00
vladimir.kuznetsov
77e51b40b8 removed unused logger 2022-12-28 13:09:33 +03:00
vladimir.kuznetsov
195663c6e3 Added activation and deactivation of logging without restarting the application 2022-12-28 06:52:02 +03:00
vladimir.kuznetsov
ce4ca5c4d5 Added display of a notification about the inclusion of logging on the main screen 2022-12-28 06:50:46 +03:00
Dmitriy Karpushin
3e276c4111 GitHub Actions fix #2 2022-12-27 20:06:11 +03:00
Dmitriy Karpushin
41a4dc2fa2 GitHub Actions fix 2022-12-27 20:00:45 +03:00
Dmitriy Karpushin
7851047421 multi-abi support 2022-12-27 17:54:14 +03:00
Dmitriy Karpushin
a30e478cbd Fix of cmake build 2022-12-27 17:14:44 +03:00
Dmitriy Karpushin
ad4b3dfad1 [WIP] cmake build for android 2022-12-27 15:37:58 +03:00
Dmitriy Karpushin
ad7fc937a9 Added missing files 2022-12-27 11:10:01 +03:00
vladimir.kuznetsov
fd905ef308 added margin for scrollbars for almost all flickable elements 2022-12-26 19:07:05 +03:00
pokamest
3f257af7a9 Merge pull request #131 from amnezia-vpn/qmake-to-cmake-migration
Qmake to cmake migration
2022-12-26 14:52:40 +00:00
vladimir.kuznetsov
030bb8fe76 Merge branch 'qt_migration' of github.com:amnezia-vpn/desktop-client into qmake-to-cmake-migration 2022-12-26 17:29:52 +03:00
pokamest
131601d9d2 Merge pull request #142 from amnezia-vpn/qt-migration-cleanup
Qt migration cleanup
2022-12-26 14:16:03 +00:00
vladimir.kuznetsov
64317ffef5 fixed deploy service additional data for debug target 2022-12-26 17:15:45 +03:00
vladimir.kuznetsov
911e65af55 Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2022-12-26 17:08:27 +03:00
Dmitriy Karpushin
82165eaf37 1) Fixed theme
2) Fixed VPN connection
2022-12-26 14:00:45 +03:00
vladimir.kuznetsov
4a75f2ebca Moved ssh lib wrapper from SshSession to SshClient 2022-12-26 12:43:51 +03:00
vladimir.kuznetsov
be39b3be8c implementation of sending commands via ssh_channel_request_exec() 2022-12-26 10:12:42 +03:00
vladimir.kuznetsov
50e8aff8fa added ssh_channel_close() in ShhSession 2022-12-25 15:46:56 +03:00
pokamest
804a790392 FlickableType added 2022-12-24 16:41:53 +00:00
vladimir.kuznetsov
d04566a6c4 fix for macos build 2022-12-24 18:21:08 +03:00
Dmitriy Karpushin
6c614a4b3c Moving to Qt6:
1) removing of deprecated classes
2) update of IPC mechanism
2022-12-23 17:32:20 +03:00
vladimir.kuznetsov
3277717a7f Added error handling
Added write to channel in callbacks
2022-12-23 14:50:48 +03:00
vladimir.kuznetsov
f9b2829396 removed linking with botan and qssh 2022-12-23 10:13:06 +03:00
vladimir.kuznetsov
81cf108471 moved and formatted code for sftp to sshSession class 2022-12-22 19:55:30 +03:00
vladimir.kuznetsov
5075fe358e added callbacks for output from a remote host 2022-12-21 08:13:06 +03:00
vladimir.kuznetsov
c8085a368f added class to open ssh connection using libssh and write data to ssh channel 2022-12-20 13:43:46 +03:00
Shahzain Ali
8191c25dd7 Delete amnezia-ios-certificates 2022-12-20 00:37:30 +05:00
Shahzain Ali
dc4b2bd52e added submodule 2022-12-20 00:22:12 +05:00
Shahzain Ali
ca60afbcee Update deploy.yml 2022-12-19 17:06:47 +05:00
Shahzain Ali
374b74b710 Update deploy.yml 2022-12-19 17:03:33 +05:00
Shahzain Ali
ae0d3d78cd Testflight upload test 2022-12-19 17:02:25 +05:00
vladimir.kuznetsov
f9f197afd0 removed unused code 2022-12-18 19:36:19 +03:00
vladimir.kuznetsov
93c43ecbc3 removed unused qzxing folder 2022-12-18 18:27:20 +03:00
vladimir.kuznetsov
1fd1b0388b removed unused code 2022-12-18 18:27:08 +03:00
vladimir.kuznetsov
833364a94e added SortFilterProxyModel submodule 2022-12-18 18:11:41 +03:00
vladimir.kuznetsov
893c105bf2 removed SortFilterProxyModel sources 2022-12-18 18:07:32 +03:00
vladimir.kuznetsov
e481bd4ec5 added deploy artifacts to github actions, artifact lifetime 1 day 2022-12-18 09:45:26 +03:00
vladimir.kuznetsov
b0489aa61b Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2022-12-18 09:17:35 +03:00
vladimir.kuznetsov
376bc29e95 set OPENSSL_SSL_LIBRARY for ios 2022-12-17 22:18:14 +03:00
vladimir.kuznetsov
bd22e330a7 set OPENSSL_CRYPTO_LIBRARY for ios
- removed linking with brew openssl for ios
2022-12-17 22:02:38 +03:00
vladimir.kuznetsov
9ce7114f8c added variables for OpenSSL 2022-12-17 21:48:45 +03:00
vladimir.kuznetsov
1303da1c20 openedsl linking method changed 2022-12-17 21:34:59 +03:00
vladimir.kuznetsov
c6bb33fa84 added display of "pure" config if it was imported in native format
- changed the method of passing the isThirdPartyConfig parameter to page logic
- removed adding hostname to the server name when importing configs in native format
- fixed display of the "$proto settings" button when clicking on the protocol on the "Installed services" page
2022-12-17 21:00:48 +03:00
vladimir.kuznetsov
22939a6707 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/ovpn-config-import 2022-12-17 17:27:26 +03:00
Hamza ARBI
9222877306 Show Scrollbars whenever the scroll is not obvious 2022-12-17 12:06:19 +01:00
Shahzain Ali
5d8264e854 Update launch.png 2022-12-16 18:48:14 +05:00
pokamest
77124e098c Merge branch 'qt_migration' into qmake-to-cmake-migration 2022-12-16 04:45:43 -08:00
pokamest
bd0a70d024 Merge pull request #140 from amnezia-vpn/bugfix/drawer-clickability
Bugfix/drawer-clickability
2022-12-16 13:43:49 +01:00
Shahzain Ali
914700712e OpenSSL finding issue fixed. 2022-12-16 15:27:06 +05:00
vladimir.kuznetsov
80d792915a fixed clickability of "drawer" elements
- added Qt.PointingHandCursor to SelectContainer drawer
- fixed some warnings
2022-12-15 21:16:59 +03:00
Dmitriy Karpushin
54dc363231 iOS fix + Android connection status restoration fix 2022-12-15 18:46:15 +03:00
pokamest
36c436af50 gitignore fix 2022-12-15 11:26:25 +01:00
Shahzain Ali
73eb9259e2 Update CMakeLists.txt 2022-12-15 14:26:45 +05:00
pokamest
951d915326 libssh init 2022-12-14 21:50:52 +01:00
vladimir.kuznetsov
14c25480ce changed working directory to call openvpn.sh 2022-12-14 22:26:06 +03:00
vladimir.kuznetsov
77d87f8c50 set working directory to call openvpn.sh 2022-12-14 21:55:51 +03:00
vladimir.kuznetsov
ab389d4817 for osxtools and networkextension/CMakeLists.txt CMAKE_CURRENT_SOURCE_DIR changed to CLIENT_ROOT_DIR 2022-12-14 21:29:33 +03:00
vladimir.kuznetsov
58b9e0cd7c for osxtools and networkextension/CMakeLists.txt CMAKE_CURRENT_LIST_DIR changed to CMAKE_CURRENT_SOURCE_DIR 2022-12-14 21:16:24 +03:00
vladimir.kuznetsov
ed2f5af204 Removed "cd client" for ios, also changed CMAKE_SOURCE_DIR to CMAKE_CURRENT_LIST_DIR.
Removed duplicate deployment files for macos
2022-12-14 20:58:49 +03:00
vladimir.kuznetsov
5b2f1f8969 processing of 3rdparty libraries moved to a separate cmake file 2022-12-14 20:32:13 +03:00
vladimir.kuznetsov
a2122cb7d7 moved changes from .pro file 2022-12-14 19:55:14 +03:00
vladimir.kuznetsov
d680702b15 change path to cmake folder 2022-12-14 19:17:58 +03:00
vladimir.kuznetsov
d15de499dc Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into qmake-to-cmake-migration 2022-12-14 19:16:38 +03:00
vladimir.kuznetsov
bd382e3cc7 moved the cmake folder to client root folder 2022-12-14 19:16:12 +03:00
Dmitriy Karpushin
d417fa58ab OpenVPN bandwidth counter for Android 2022-12-14 18:52:19 +03:00
Shahzain Ali
ca9cb997b5 Fixed openVPN issue.
Now OpenVPN moved to main target and fixed search path issue, becuase I face below error while archiving. Invalid Bundle. The bundle at 'AmneziaVPN.app/PlugIns/AmneziaVPNNetworkExtension.appex' contains disallowed nested bundles.
2022-12-14 17:28:16 +05:00
Shahzain Ali
ebd920f3b2 Setting target membership on Media.xcassets 2022-12-14 16:56:20 +05:00
vladimir.kuznetsov
a611ddea2d removed environment OPENSSL_ROOT_DIR variable 2022-12-13 23:52:43 +03:00
vladimir.kuznetsov
75614e0bbb set environment OPENSSL_ROOT_DIR variable 2022-12-13 23:39:58 +03:00
vladimir.kuznetsov
dafef6463a added:
- set PKG_CONFIG_PATH for openssl
- use find_package for precompiled openssl

removed:
- set CMAKE_PREFIX_PATH for openssl
- renaming ios openssl libs after copying to bin dir
2022-12-13 21:39:02 +03:00
vladimir.kuznetsov
61d502eea4 removed find_package for openssl 2022-12-13 20:49:46 +03:00
vladimir.kuznetsov
71aa525dfd set CMAKE_PREFIX_PATH for openssl 2022-12-13 20:36:12 +03:00
vladimir.kuznetsov
c0e3875dfd renaming ios openssl libs after copying to bin dir 2022-12-13 20:23:17 +03:00
pokamest
9c188e0acd Merge branch 'qt_migration' into qmake-to-cmake-migration 2022-12-13 15:34:38 +01:00
pokamest
1de143362c Merge branch 'dev' into qt_migration 2022-12-13 15:09:05 +01:00
vladimir.kuznetsov
7e37b6c151 removed CMAKE_PREFIX_PATH for openssl 2022-12-12 22:22:08 +03:00
vladimir.kuznetsov
0fa84a8b84 set CMAKE_PREFIX_PATH for openssl 2022-12-12 21:39:27 +03:00
vladimir.kuznetsov
236ae57d01 use find_package for precompiled openssl 2022-12-12 20:50:23 +03:00
pokamest
7345f464a5 Merge pull request #138 from amnezia-vpn/feature/android_config_export_import
Export/import of configuration files on Android
2022-12-12 16:48:23 +01:00
pokamest
3c45f2abe2 Merge branch 'dev' into feature/ovpn-config-import 2022-12-12 14:42:12 +01:00
pokamest
9c5e1faf46 Build fixes 2022-12-12 14:41:54 +01:00
pokamest
ce02d3a829 Merge branch 'dev' into feature/ovpn-config-import 2022-12-12 14:01:57 +01:00
pokamest
1b80c59e65 Merge pull request #137 from amnezia-vpn/bugfix/config-without-containers-import
bugfix: import config without containers
2022-12-12 13:30:28 +01:00
Hamza ARBI
f20f528a11 Server selection always in range (#130)
* Server selection stays always in the list's range
* Removed the usage of QZxing module from PageQrDecoder page
* Fixed null spelling on qml instead of nil
2022-12-12 13:28:03 +01:00
dartsyms
814b66c04a Various fixes for iOS (#126)
* Readme update, solution for wireguard make in M1 machines,
* import file and restore enabled.
* xcode_patcher.rb fixed, Now no need to add openVPN framewrok in Embed frameworks manually.
* Now xcode_patcher.rb will add OpenVPN Framework to Embed Frameworks in main target, instead of Network extension.
* Update iosvpnprotocol.swift
* Protocol wasn't detected because it is working on localized description of tunnel, fixed cases.
* Code cleanup
* Speed issue fixed for wireguard.
* GetDeviceIp and bytes(speed of OpenVPN) fixed.
*Device IP method wasn't working as expected, so I replaced. and for speed in OpenVPN we need to handle message seperately for bytes.
*QR progress added with progressbar and text.
2022-12-12 13:16:12 +01:00
vladimir.kuznetsov
00ad2e7a80 added path to openssl libs for ios 2022-12-11 18:25:44 +03:00
vladimir.kuznetsov
8f7e5e491f fixed macos openssl lib types 2022-12-11 17:59:18 +03:00
vladimir.kuznetsov
19101176a7 added link_libraries() for zlib 2022-12-11 17:22:59 +03:00
vladimir.kuznetsov
0bc383fec2 Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2022-12-11 17:09:26 +03:00
vladimir.kuznetsov
4df918d6a5 added qtshadertools to actions and cmake
- cleaned up CMakeLists in client project
2022-12-11 10:26:31 +03:00
Shahzain Ali
d3cbd8cdae Update deploy.yml 2022-12-11 04:21:28 +05:00
Shahzain Ali
0fa5dc225c Reverting shadertools in cmake. 2022-12-11 04:19:24 +05:00
Shahzain Ali
b14f14c45a Update CMakeLists.txt 2022-12-11 04:09:45 +05:00
Shahzain Ali
0851f4fdd4 Added Qt6ShaderTools in cmake 2022-12-11 04:01:15 +05:00
Shahzain Ali
807b3370e7 Adding qtshadertools module in qt installation 2022-12-11 03:42:46 +05:00
Shahzain Ali
a0f114e15c Fixing openvpn 2022-12-11 03:22:59 +05:00
vladimir.kuznetsov
1401fcd97d disabled some libssh options 2022-12-10 20:15:05 +03:00
vladimir.kuznetsov
efcd291e65 Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2022-12-10 19:07:00 +03:00
vladimir.kuznetsov
f98792714e set working directory to call openvpn.sh 2022-12-10 18:46:17 +03:00
vladimir.kuznetsov
5649f85b58 set QT_HOST_PATH for ios target 2022-12-10 18:09:41 +03:00
vladimir.kuznetsov
cfaba932e0 changeGed libz lib name for linux target 2022-12-10 18:00:50 +03:00
vladimir.kuznetsov
b1db4e8a7a Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2022-12-10 17:58:57 +03:00
vladimir.kuznetsov
ab9c11e038 set ios root dir as CMAKE_PREFIX_PATH 2022-12-09 18:12:39 +03:00
vladimir.kuznetsov
4d621dcbfe set CMAKE_PREFIX_PATH in CMakeLists file 2022-12-09 17:44:57 +03:00
vladimir.kuznetsov
a45537cbf3 added DCMAKE_PREFIX_PATH to IOS target 2022-12-09 17:30:46 +03:00
vladimir.kuznetsov
2d3ac286ac skip section with openssl copy for linux 2022-12-09 16:18:02 +03:00
vladimir.kuznetsov
4e96b5d4a6 added libz lib name for linux target 2022-12-09 15:57:31 +03:00
Shahzain Ali
9294324732 fixing host path 2022-12-09 04:24:16 +05:00
Shahzain Ali
b92422594b Merge branch 'qmake-to-cmake-migration' of https://github.com/amnezia-vpn/desktop-client into qmake-to-cmake-migration 2022-12-09 04:13:37 +05:00
Shahzain Ali
ea2637b1b4 Setting QT_BUILD_TOOLS_WHEN_CROSS_COMPILING ON 2022-12-09 04:13:14 +05:00
Shahzain Ali
c97b4859c1 Update deploy.yml 2022-12-09 04:05:25 +05:00
Shahzain Ali
7a2f42de30 Update deploy.yml 2022-12-09 03:58:36 +05:00
Shahzain Ali
99f5f78fc7 Update deploy.yml 2022-12-09 03:48:12 +05:00
Shahzain Ali
668f0ca675 Update deploy.yml 2022-12-09 03:47:09 +05:00
Shahzain Ali
6a89a51ea6 added QT_TOOL_CHAIN for ios cmake 2022-12-09 03:38:29 +05:00
Shahzain Ali
df6b0f3945 Update deploy.yml 2022-12-09 03:11:31 +05:00
Shahzain Ali
65cf243373 Update deploy.yml 2022-12-09 03:10:26 +05:00
Shahzain Ali
2ef7813219 Update deploy.yml 2022-12-09 03:06:16 +05:00
Shahzain Ali
216efd74bf Update deploy.yml 2022-12-09 03:04:43 +05:00
Shahzain Ali
b9d027a44a Update deploy.yml 2022-12-09 03:03:17 +05:00
Shahzain Ali
9097dd9645 actions for ios using cmake 2022-12-09 02:59:35 +05:00
Shahzain Ali
d784e26913 MacOS issue fixed. 2022-12-09 02:33:46 +05:00
vladimir.kuznetsov
cb69298385 Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into feature/qt6-libssh-support 2022-12-08 21:41:33 +03:00
vladimir.kuznetsov
a8fc42a17e added copying OpenSSL libraries, for windows and macos, to the folder with binaries, because we have the wrong folder structure with the OpenSSL library 2022-12-08 21:40:51 +03:00
Shahzain Ali
005008814a icon added in cmake. 2022-12-08 21:34:55 +05:00
Shahzain Ali
ad3bbaedb3 getting openvpn.sh script message. 2022-12-08 18:22:07 +05:00
Dmitriy Karpushin
cad0dabe42 Export/import of configuration filed on Android 2022-12-08 11:51:28 +03:00
Shahzain Ali
48fa3c8aec Update CMakeLists.txt 2022-12-07 20:36:22 +05:00
Shahzain Ali
fb585cbac0 OpenVPN integrated successfully 2022-12-07 20:35:43 +05:00
Shahzain Ali
dd1adda1a6 postbuild command fix. 2022-12-07 00:19:02 +05:00
vladimir.kuznetsov
3742583508 added zlib to submodules. Added build and link zlib, libssh in CMakeLists.txt 2022-12-06 18:17:10 +03:00
Shahzain Ali
3c6cd623af version issues fixed 2022-12-06 19:18:38 +05:00
Shahzain Ali
70c6e69b36 updatinf info.plist for .vpn type. 2022-12-06 03:09:45 +05:00
Shahzain Ali
943e58d32a Wireguard working. 2022-12-06 02:47:46 +05:00
Shahzain Ali
5237058016 Added launcher 2022-12-06 02:18:45 +05:00
Shahzain Ali
b87c5f8a51 iOS building successfully
Need to remove postbuild commands most probably from osxtools.cmake
2022-12-06 00:42:48 +05:00
Shahzain Ali
43e7a03af4 Some fixes.
Now team is preselected in signing.
2022-12-05 20:47:12 +05:00
pokamest
19fce4975d Merge branch 'dev' into feature/ovpn-config-import 2022-12-04 22:04:51 +01:00
pokamest
a9217810e7 Remove travis builds and tiny refactoring 2022-12-04 21:54:22 +01:00
Mykola Baibuz
a87610c856 Use libssh for server setup script
That gives some advantages in supported key types.
2022-12-04 01:43:53 +03:00
vladimir.kuznetsov
0ec0cb1b19 feature: added libssh submodule 2022-12-04 01:43:34 +03:00
vladimir.kuznetsov
9b1678a06c Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into bugfix/config-without-containers-import 2022-12-03 15:26:32 +03:00
vladimir.kuznetsov
0da63062d7 bugfix: fixed transition to the "Installed services" page when importing a config that does not have installed containers 2022-12-03 15:23:52 +03:00
Shahzain Ali
c8dd12eb20 Some more progress in cmake
Still have errors, currently not using apple-compile.sh building completely using cmake.
2022-12-02 22:26:10 +05:00
Shahzain Ali
008592f13b Architecture change not needed for ios build
CMAKE_OSX_ARCHITECTURES not needed for ios, it is setting x86_64 for all targets in ios.
2022-12-02 15:07:05 +05:00
vladimir.kuznetsov
56b9972053 build script for macos now uses cmake 2022-12-01 20:26:00 +03:00
vladimir.kuznetsov
1335c94bbc added include directory for botan ios 2022-12-01 20:24:04 +03:00
vladimir.kuznetsov
21a6ab369e Merge branch 'qmake-to-cmake-migration' of github.com:amnezia-vpn/desktop-client into qmake-to-cmake-migration 2022-12-01 20:11:56 +03:00
vladimir.kuznetsov
2a80117d42 Merge remote-tracking branch 'remotes/origin/qt6-github-actions' into qmake-to-cmake-migration 2022-12-01 20:05:36 +03:00
Shahzain Ali
e65d312503 Merge branch 'qmake-to-cmake-migration' of https://github.com/amnezia-vpn/desktop-client into qmake-to-cmake-migration 2022-12-01 20:40:00 +05:00
Shahzain Ali
5fc34e643c Adding network extenstionn, fixing cmake.
Botan cmake changes, cmake APPLE/IOS fixes, wireguard added, Currently removed openvpn implementation, once wireguard is stable then will add openVPN framework.
Current progress is it is generating xcode project using
mkdir build-ios
/Users/shahzainali/Qt/6.4.1/ios/bin/qt-cmake . -B build-ios -GXcode
Need to select team only for Network extension only. select AmneizaVPN to run.
current issue is related to Botan.
2022-12-01 20:26:45 +05:00
pokamest
3463a84903 Merge branch 'qt_migration' into qmake-to-cmake-migration 2022-11-30 15:02:55 +01:00
pokamest
48dc532de6 Merge branch 'dev' into qt_migration 2022-11-30 14:26:44 +01:00
Shahzain Ali
20cb62483f Moved all libraries to LIBS variable 2022-11-30 15:36:25 +05:00
pokamest
dcb5828313 GitHub actions (#133)
GitHub actions
2022-11-30 01:51:18 +01:00
pokamest
74860256b9 Merge pull request #136 from amnezia-vpn/bugfix/notarize-app-macos
fixed options parsing for enable macos NOTARIZE_APP
2022-11-30 01:21:19 +01:00
vladimir.kuznetsov
97457f17c1 fixed options parsing for enable macos NOTARIZE_APP 2022-11-29 22:11:02 +03:00
Shahzain Ali
de9167cae6 Frameworks, libcrypto, libssl and some properties added for iOS. 2022-11-29 18:00:59 +05:00
vladimir.kuznetsov
2e5171c205 added matrix for all android arch 2022-11-29 00:55:32 +03:00
Shahzain Ali
a0b5491178 Merge branch 'qt_migration' into qmake-to-cmake-migration 2022-11-28 19:23:28 +05:00
vladimir.kuznetsov
fc8ef8678b Merge remote-tracking branch 'remotes/origin/qt_migration' into qmake-to-cmake-migration 2022-11-28 14:50:20 +03:00
Shahzain Ali
2dc1f2ea5b Setting minimum version to 13
QT 6.4 required minimum ios 13
https://doc.qt.io/qt-6/supported-platforms.html
2022-11-28 15:56:48 +05:00
Shahzain Ali
7999527582 Update README.md 2022-11-28 15:44:55 +05:00
Shahzain Ali
14be6506ee Qt5 to QT6 fixes. 2022-11-28 15:36:33 +05:00
vladimir.kuznetsov
c85ad470ba qt version in github actions changed to 6.4.1 2022-11-27 12:08:48 +03:00
vladimir.kuznetsov
8b6afcc5ec removed unused qzxing folder 2022-11-27 01:35:13 +03:00
vladimir.kuznetsov
813dced6df added qt6 modules installation to github actions 2022-11-27 01:30:36 +03:00
vladimir.kuznetsov
0a39866045 for github actions added step to build android application 2022-11-27 01:21:42 +03:00
vladimir.kuznetsov
48734689d8 for github actions added step to build macos and linux application 2022-11-27 01:21:41 +03:00
vladimir.kuznetsov
dfe927dcbd for github actions added step to build ios application 2022-11-27 01:21:41 +03:00
vladimir.kuznetsov
ca158def31 temporarily turned off the deployment of artifacts 2022-11-27 01:21:41 +03:00
vladimir.kuznetsov
409386336d for github actions added steps to build x32/x64 windows application 2022-11-27 01:21:41 +03:00
vladimir.kuznetsov
eeed6c3474 chore/revert link to dev qtkeychain submodule 2022-11-27 01:21:40 +03:00
pokamest
3296cd6c39 GH actions 12 2022-11-27 01:21:40 +03:00
pokamest
60e25d9c67 GH actions 11 2022-11-27 01:21:40 +03:00
pokamest
ec65e2025e GH actions 10 2022-11-27 01:21:39 +03:00
pokamest
f09020c3bc GH actions 9 2022-11-27 01:21:39 +03:00
pokamest
91baaed96d GH actions 8 2022-11-27 01:21:39 +03:00
pokamest
64de64ce33 GH actions 7 2022-11-27 01:21:38 +03:00
pokamest
b685e7008e GH actions 6 2022-11-27 01:21:38 +03:00
pokamest
375b3d776c GH actions 5 2022-11-27 01:21:38 +03:00
pokamest
c1fddd7164 GH actions 4 2022-11-27 01:21:37 +03:00
pokamest
3af9bf9e12 GH actions 3 2022-11-27 01:21:37 +03:00
pokamest
9ef5d0c144 GH actions 3 2022-11-27 01:21:37 +03:00
pokamest
3d1b37dc85 gh actions 2 2022-11-27 01:21:36 +03:00
pokamest
80ce8347f6 GH actions 1 2022-11-27 01:21:36 +03:00
vladimir.kuznetsov
3eb7e1392d feature/added cmake support for linux 2022-11-20 21:25:15 +03:00
vladimir.kuznetsov
ac78a44d74 fixed padding in build script 2022-11-18 17:06:52 +03:00
vladimir.kuznetsov
87fed9fde3 fixed connection with qssh 2022-11-18 16:42:22 +03:00
vladimir.kuznetsov
2564430046 build script now uses cmake, also:
- fixed linking qt6keychain and SortFilterProxyModel
- added translations
2022-11-15 23:31:55 +03:00
vladimir.kuznetsov
663861dc09 for debug target added deploy files required to run the application on Windows, also:
- added deploy additional files for android
- fixed include android libraries
2022-11-15 14:16:36 +03:00
vladimir.kuznetsov
2d6a12101e in CMakeLists source files are common for all platforms, now added via FILE(GLOB) 2022-11-14 22:22:38 +03:00
vladimir.kuznetsov
e40110fa4c added platform specific commands to cmake files 2022-11-12 23:52:15 +03:00
vladimir.kuznetsov
6ac162f3cd added cmake files for client project 2022-11-09 23:54:30 +03:00
vladimir.kuznetsov
aea1d16e31 added files for linux and mac to CMakeLists for server and wireguard-service projects 2022-11-08 21:32:17 +03:00
vladimir.kuznetsov
16e26ef215 added CMakeLists for server and wireguard-service projects 2022-11-07 23:59:09 +03:00
vladimir.kuznetsov
7270e701d4 hostname is now added to the server name for imported openvpn and wireguard configs 2022-11-05 19:40:51 +03:00
pokamest
c8010d4d52 Merge pull request #125 from amnezia-vpn/qt_migration-settings-btn
Added Settings button on Start Page
2022-11-05 16:42:24 +03:00
vladimir.kuznetsov
6941b7463e added display of wireguard configs, such a config will be displayed as raw text 2022-11-04 23:31:39 +03:00
vladimir.kuznetsov
99a6cd82b2 added import of configs in wireguard format 2022-11-03 23:39:58 +03:00
vladimir.kuznetsov
1a44307664 added protocol_defs for new config keywords 2022-11-01 23:24:58 +03:00
vladimir.kuznetsov
53d7a92a0d added import of configs in .ovpn format
- on the "OpenVPN Settings" page, such a config will be displayed as raw text
2022-11-01 23:12:42 +03:00
Hamza ARBI
4ba1f47423 Disable Servers settings item when no server has been set
Fix the logic of *Add Server* to comeback to start page instead of push when no server is set
2022-10-30 22:53:45 +01:00
Hamza ARBI
c38e47b726 Update SvgImageType icon color when the item is disabled 2022-10-30 02:06:51 +01:00
Hamza ARBI
e6a4d79b86 Add settings button on PageStart
Disable some items when no Server has been set
2022-10-30 02:06:20 +01:00
pokamest
b62d0697be Merge pull request #123 from amnezia-vpn/openvpn_addditional_configs
OpenVPN additional config
2022-10-26 17:02:13 +03:00
vladimir.kuznetsov
f90ebbbb4e added inclusion of an additional client/server config when generating configs from templates
- fixed name in additional server config field
2022-10-26 14:06:03 +03:00
Hamza ARBI
ab39802512 Using Basic theme in first place 2022-10-24 14:05:28 +01:00
Hamza ARBI
84da67adda Using Basic style in the first place 2022-10-24 13:56:12 +01:00
Hamza ARBI
cfff3c6d97 Used Universal Theme to fix QtQuick Controls 2022-10-24 13:50:41 +01:00
Hamza ARBI
cc3d9e0d2d Fix all QML headers and change the deprecated QML components
* QZXing : Error while integrating it
2022-10-20 20:09:17 +01:00
pokamest
442e7eb015 Merge branch 'dev' into qt_migration 2022-10-15 19:46:26 +03:00
pokamest
59248b7c2e Merge pull request #114 from outspace/dev
Set security screen for Android app
2022-09-23 23:41:42 +03:00
Mykola Baibuz
f2d7a45b74 Set security screen for Android app
This will guarantee that even apps running with root privileges are unable to directly capture information displayed by the app on the screen.
2022-09-23 22:03:28 +03:00
pokamest
c79b6147ea Merge pull request #113 from outspace/dev
Add auth protection for ssh key export (Android)
2022-09-22 21:15:35 +03:00
Mykola Baibuz
d93be76505 Add auth protection for ssh key export
We use a builtin keyguard for ssh key export protection on Android.

This protection works only if some protection is set on the phone.

https://developer.android.com/reference/android/app/KeyguardManager#isDeviceSecure()
2022-09-19 12:32:06 +03:00
pokamest
5fff65db5a Tiny fixes 2022-09-19 00:44:00 +03:00
pokamest
53e240add7 Android manifest fix 2022-09-12 14:57:00 +03:00
pokamest
9cfc65eeda Version bump 2022-09-11 00:24:43 +03:00
pokamest
47c305d557 Merge pull request #111 from amnezia-vpn/qrcodegen
qzxing removed, Qrcodegen added
2022-09-10 19:58:19 +03:00
pokamest
c5ba89b054 Code cleanup 2022-09-10 19:57:44 +03:00
pokamest
de8977723a Merge branch 'dev' into qrcodegen 2022-09-09 15:36:45 +03:00
pokamest
8cea93de94 Travis build fix 2022-09-09 15:34:09 +03:00
pokamest
e25cbe54d9 Merge branch 'dev' into qrcodegen 2022-09-09 15:02:14 +03:00
pokamest
b356522f94 Secure settings crash fix 2022-09-09 15:01:11 +03:00
pokamest
7a6c1de5d5 QrCoreGen 2022-09-07 09:51:03 +03:00
pokamest
fb07adf7c1 Travis fix 2022-09-05 02:06:58 +03:00
pokamest
9ceadd44c9 Travis fix 2022-09-05 01:56:39 +03:00
pokamest
e1c529ab91 Travis ccache 2022-09-05 01:38:29 +03:00
pokamest
ce27af6083 Travis build fix 2022-09-05 00:33:27 +03:00
pokamest
ac7d224645 Travis build fix 2022-09-05 00:11:55 +03:00
pokamest
df26f492a7 Travis build fix 2022-09-04 23:27:00 +03:00
pokamest
448c01ca99 Travis build fix 2022-09-04 14:49:33 +03:00
pokamest
bd7a9e5444 Merge pull request #106 from karolsteve/dev
Fix Android build on Travis
2022-09-04 14:15:54 +03:00
pokamest
1e717710b6 Merge pull request #109 from amnezia-vpn/Linux_deploy_script
Linux deploy script
2022-09-03 16:33:37 +03:00
pokamest
3cb14ad3bc Tiny Linux build scripts fixes 2022-09-03 06:31:59 -07:00
leetthewire
4769a67936 Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into Linux_deploy_script 2022-09-03 06:22:20 +04:00
leetthewire
279f866bf5 completed build linux script 2022-09-03 06:21:37 +04:00
leetthewire
5cbe7600a6 updated gitignore 2022-09-03 06:21:14 +04:00
pokamest
cdb1a4c288 Fix for AVP-01-006 - inscure app config permissions 2022-09-02 12:39:46 -07:00
pokamest
7d09d41a7d Merge pull request #108 from amnezia-vpn/dev
Release 2.1.0
2022-09-02 14:08:31 +03:00
pokamest
340bbd8727 Merge pull request #107 from amnezia-vpn/Linux_libs_deps
Linux libraries dependency for service
2022-09-01 18:03:18 +03:00
leetthewire
53c916ea4f Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into Linux_libs_deps 2022-09-01 17:45:39 +04:00
leetthewire
6451337274 fixed service lib path 2022-09-01 17:45:15 +04:00
pokamest
294b75ce2d QtKeyChain usage fix 2022-08-31 13:29:28 -07:00
pokamest
0ca4f3b104 Fix for CommandLineParser 2022-08-31 16:54:46 +03:00
pokamest
ac74510d47 Some fixes for Qt6 Android 2022-08-31 15:18:33 +03:00
pokamest
33ec69d33a Merge pull request #102 from omortie/qt_migration
migrated the codebase to Qt6 and fixed some compatibility issues
2022-08-31 13:53:55 +03:00
Steve Tchatchouang
f6d329ac48 Fix Android job CI 2022-08-30 14:00:40 +01:00
Steve Tchatchouang
a56fbeb611 Fix android build script
Using correct qt binaries folder (gcc64 -> Android)
2022-08-30 13:58:03 +01:00
Mortie
8c20a67cfa migrated the codebase to Qt6 and fixed some compatibility issues
* used a Qt6 ported version of SortFilterProxyModel
* used an updated Qt6 compatible version of QXZing
* added a flag to windows linker to avoid WinMain problem of MSVCRTD
* renamed utils.cpp to utilities.cpp for avoiding confusion with the same file name in SortFilterProxyModel
2022-08-29 12:21:09 +04:30
pokamest
fffa4fc031 Merge pull request #101 from amnezia-vpn/openvpn_random_mgmt_port
Openvpn random mgmt port [AVP-01-010]
2022-08-29 03:00:06 +03:00
pokamest
3316b73ab6 Select random management port 2022-08-29 02:58:23 +03:00
pokamest
211f7b7965 Merge pull request #100 from amnezia-vpn/check_openvpn_config
Check openvpn config for scripts [AVP-01-014]
2022-08-29 02:08:14 +03:00
pokamest
3a5a7bf674 Check openvpn config for scripts
QML refactoring
2022-08-29 01:32:42 +03:00
pokamest
7c749a964c Merge pull request #94 from amnezia-vpn/AVP-01-011
AVP-01-011 (Privileged process access list)
2022-08-27 19:21:45 +03:00
pokamest
997c8c87d0 Cleanup 2022-08-27 18:41:44 +03:00
pokamest
ed6a417d7e Merge branch 'dev' into AVP-01-011 2022-08-27 18:31:20 +03:00
pokamest
4a54f545a4 Merge pull request #99 from amnezia-vpn/qtkeychain
QtKeyChain module added [AVP-01-005, AVP-01-015]
2022-08-27 18:18:22 +03:00
pokamest
789902b79a Secure settings rework 2022-08-27 17:35:43 +03:00
pokamest
266859af19 Build fix for iOS 2022-08-26 03:19:34 -07:00
pokamest
9cca1a4819 Merge pull request #97 from amnezia-vpn/secure-config-2
App refactoring + secure config for mobile devices [AVP-01-005, AVP-01-015]
2022-08-26 01:02:12 +03:00
pokamest
aae1da3aa8 Cleanup code 2022-08-26 00:58:24 +03:00
pokamest
aed688224b App refactoring finished 2022-08-26 00:35:03 +03:00
pokamest
3ce1ec708d App refactoring finished 2022-08-25 17:35:28 +03:00
pokamest
510a564797 App refactoring 2022-08-25 12:47:02 +03:00
pokamest
b36517babb Merge branch 'dev' into secure-config-2 2022-08-24 20:40:10 +03:00
pokamest
415d18338e Secure config WIP 2022-08-24 18:51:35 +03:00
pokamest
14384131f4 Secure config WIP 2022-08-24 07:38:13 -07:00
pokamest
b3d54ce57e PageServerContainers animation fixed [ci skip] 2022-08-24 16:58:00 +03:00
pokamest
b5890340e3 Secure settings rework 2022-08-23 22:47:23 +03:00
pokamest
050d987d3b Merge branch 'dev' into qt_migration 2022-08-20 17:27:57 +03:00
pokamest
c4651cd915 Travis build fix 2022-08-20 17:24:11 +03:00
pokamest
b5f97c0d94 Travis build fix 2022-08-20 00:51:57 +03:00
pokamest
35165ba2b8 Travis build fix 2022-08-19 23:56:45 +03:00
pokamest
aeb1dcdf15 Travis build fix 2022-08-19 23:26:34 +03:00
pokamest
37730744e7 Travis build fix 2022-08-19 22:45:03 +03:00
pokamest
f821fe0356 Travis ios build 2022-08-19 22:23:52 +03:00
pokamest
ba16fdb548 Travis build fix 2022-08-19 18:47:39 +03:00
pokamest
144e6f59c8 Travis build fix 2022-08-19 18:35:17 +03:00
pokamest
2e42c5e875 Travis builds for Linux and Android 2022-08-19 16:17:37 +03:00
pokamest
eec8743e2f Travis ci fix 2022-08-18 19:57:46 +03:00
pokamest
e5e5684e2e Travis ci fix 2022-08-18 19:02:05 +03:00
pokamest
efddc6ccec Travis build fix 2022-08-18 17:01:34 +03:00
pokamest
5aef46733b Travis build fix 2022-08-18 15:31:10 +03:00
pokamest
201782184c Travis build fix 2022-08-18 15:20:27 +03:00
pokamest
5f2ef046e1 Travis build fix 2022-08-18 15:10:54 +03:00
pokamest
42398950e4 Fix for iOS 2022-08-16 08:28:41 -07:00
pokamest
506c8af1ea MacOS build script renamed 2022-08-16 03:37:46 -07:00
pokamest
70d9c516af Old MacOS build script deleted 2022-08-16 03:36:40 -07:00
pokamest
11ad86b9db Merge pull request #92 from amnezia-vpn/Linux_deploy_refactored
Linux deploy refactored
2022-08-16 13:08:30 +03:00
pokamest
2e9cfa6973 Merge pull request #93 from amnezia-vpn/Linux_install_scripts
Fixed installing scripts for Linux
2022-08-16 13:07:15 +03:00
pokamest
13e2c325e1 Merge pull request #95 from amnezia-vpn/easyrsa_cleanup
Cleanup easyrsa
2022-08-16 13:02:27 +03:00
pokamest
7e428a273f Merge pull request #91 from amnezia-vpn/Linux_errors_for_containers
Error descriptions for containers
2022-08-16 13:00:48 +03:00
pokamest
aa4bd516a9 Merge pull request #90 from amnezia-vpn/Linux_fix_sh_permissions
AVP-01-001 (Fix permissions for Linux and MacOS)
2022-08-15 23:27:44 +03:00
pokamest
82f8675b68 Merge pull request #96 from amnezia-vpn/android_7_wireguard_fix
Fix: infinite reconnect when using wireguard on Android 7 and 7.1
2022-08-15 23:17:39 +03:00
dimmdev
fdcb994e7a Fix: infinite reconnect when using wireguard on Android 7 and 7.1 2022-08-15 08:16:08 +05:00
pokamest
e89fa23533 Permissions fix for MacOS 2022-08-11 06:12:30 -07:00
pokamest
21d4f0f569 Cleanup easyrsa 2022-08-11 12:30:42 +03:00
pokamest
625201e559 Fix write permissions on macOS nac Linux 2022-08-11 12:29:09 +03:00
leetthewire
d36378fcbf fixed installing scripts 2022-08-11 01:23:57 +04:00
leetthewire
929ecfd42b linux deploy refactored 2022-08-11 01:20:27 +04:00
leetthewire
44496e424a errors for containers 2022-08-11 01:14:37 +04:00
leetthewire
1eb789e847 fixed permissions of a sh script 2022-08-11 00:58:07 +04:00
leetthewire
1ab76617df prepared to commit permissions of a sh script 2022-08-11 00:57:42 +04:00
pokamest
3bff653bbb IpcServerProcess permit list 2022-08-10 22:15:00 +03:00
pokamest
4b7a8c6d6e Start Qt6 migration 2022-08-10 14:00:04 +03:00
pokamest
9236be7fbd Merge pull request #70 from amnezia-vpn/android_shadowsocks
ShadowSocks implementation for Android
2022-08-09 17:12:36 +03:00
pokamest
fd9b922b21 Merge branch 'dev' into android_shadowsocks 2022-08-09 17:11:11 +03:00
pokamest
eea88f6e11 Cleanup 2022-08-09 17:06:03 +03:00
pokamest
eb47c968ae Build fix - MobileUtils.cpp 2022-08-08 19:46:39 +03:00
pokamest
560019b26c Build fix - typo in client.pro 2022-08-08 19:12:00 +03:00
pokamest
589e07f869 wireguard-tools submodule updated 2022-08-08 14:27:07 +03:00
pokamest
585de53148 Secure settings refactoring 2022-08-06 19:47:29 +03:00
pokamest
1e85b25438 Backup/restore config 2022-08-05 18:59:47 +03:00
pokamest
71b57bfed1 Secure settings 2 2022-08-05 14:31:12 +03:00
eugenyorbitsoftcom
870cb26e01 new line 2022-08-05 14:15:11 +06:00
eugenyorbitsoftcom
9a180b098f try read and write chipher Settings 2022-08-04 11:49:00 +06:00
eugenyorbitsoftcom
06682c333f remove kSecAttrService 2022-08-03 10:52:59 +06:00
eugenyorbitsoftcom
18c0aa5c81 kSecClassGenericPassword 2022-08-03 10:46:59 +06:00
eugenyorbitsoftcom
e49b468fd5 writeToKeychain, readFromKeychain 2022-08-02 15:52:03 +06:00
eugenyorbitsoftcom
7e5748b3a6 fix building project 2022-08-01 16:30:57 +06:00
eugenyorbitsoftcom
e99aa86863 fix building project 2022-08-01 15:57:16 +06:00
eugenyorbitsoftcom
bc6ae1d1b5 Merge branch 'dev' into secure-config 2022-08-01 10:55:33 +06:00
pokamest
df94a87a51 Merge pull request #83 from amnezia-vpn/open-config-in-app
iOS features : Open config in app, share configs
2022-07-31 23:40:08 +03:00
pokamest
9f7b2de311 Merge branch 'dev' into open-config-in-app 2022-07-31 23:39:11 +03:00
pokamest
dab6e10881 Wordpress site in the Tor network 2022-07-30 16:20:41 +03:00
eugenyorbitsoftcom
3b78c3a929 chiperSettings 2022-07-29 14:58:22 +06:00
eugenyorbitsoftcom
7029968c47 SecureFormat AES-GCM 2022-07-29 10:36:54 +06:00
pokamest
a8fe4e6aab Docker images fix: log driver=none 2022-07-27 17:34:43 +03:00
pokamest
b93dd8cb9b Build fix 2022-07-27 03:22:46 +03:00
ddd
0ba614961d fixed AVP-01-001 WP2, permissions on update-resolv-conf.sh 2022-07-16 13:23:17 +04:00
eugenyorbitsoftcom
79c56d440c fix LD_RUNPATH_SEARCH_PATHS 2022-07-14 13:01:40 +06:00
eugenyorbitsoftcom
9601506270 share file for iOS 2022-07-13 16:08:55 +06:00
eugenyorbitsoftcom
9ed16b81e8 read imported file configuration 2022-07-11 16:08:57 +06:00
eugenyorbitsoftcom
1800c1ff12 added ability import amnezia vpn config 2022-07-11 11:06:01 +06:00
pokamest
a8067bee36 Merge pull request #78 from amnezia-vpn/ios-wireguard
Ios wireguard fix and version bump
2022-07-07 16:31:19 +03:00
Alex Kh
f879663033 Applied fix from spamming button issue solution, bumped app version, and build number 2022-07-07 17:26:40 +04:00
eugenyorbitsoftcom
d618af19d6 fix crash 2022-07-07 17:16:45 +04:00
Alex Kh
8aa61bf5bc Bump version 2022-07-06 23:17:02 +04:00
pokamest
cd70f4b1c9 Merge pull request #53 from amnezia-vpn/ios-wireguard
iOS initial support
2022-07-06 16:26:50 +03:00
pokamest
240e55029b Merge pull request #77 from amnezia-vpn/qr-code-native-ios
Qr code reader native for iOS
2022-07-06 16:23:19 +03:00
eugenyorbitsoftcom
9aabe7c72e QRCodeReader for iOS 2022-07-06 14:02:56 +06:00
eugenyorbitsoftcom
6744dce57e QRCodeReader (WIP) 2022-07-06 11:51:45 +06:00
Alex Kh
d38e40d53f Latest updates before starting anew 2 2022-06-30 21:10:43 +04:00
Alex Kh
aa1b561bc0 Latest updates before starting anew 2022-06-30 21:10:34 +04:00
pokamest
6674b7890c Merge pull request #71 from AlexKLWS/improve-build-process
Improve build process for iOS
2022-06-30 17:57:35 +03:00
pokamest
a3a62165e9 Merge pull request #73 from amnezia-vpn/linux_v2
Linux v2
2022-06-29 21:47:22 +03:00
pokamest
8eb5a62737 Disable QUERY_ALL_PACKAGES manifest for Android 2022-06-26 15:01:04 +03:00
pokamest
c5ef462937 v. 2.0.10 2022-06-11 15:52:44 +03:00
Pokamest Nikak
eca397b45f Docker fixes - FROM alpine:3.15 2022-06-10 16:19:29 +03:00
unknown
9f7a583c92 local path fix 2022-06-04 13:20:59 +03:00
leetthewire
a59077b94f cleaned up 2022-05-11 22:54:55 +00:00
leetthewire
d61bfaa993 Merge branch 'dev' of https://github.com/amnezia-vpn/desktop-client into linux_v2 2022-05-11 22:49:50 +00:00
leetthewire
a17690f88b linux data folder updated 2022-05-11 22:10:54 +00:00
leetthewire
271e948c1f clean up /platform/linux/ folder 2022-05-11 22:05:00 +00:00
leetthewire
ac7de6213a clean up /platform/linux/ folder 2022-05-11 22:04:01 +00:00
Alex Korzh
7ff6b64742 Replace die with killProcess in apple_compile 2022-04-29 18:02:38 +04:00
Alex Korzh
531e0ad19d Update README 2022-04-29 13:44:46 +04:00
Alex Korzh
cc7112fb66 Reduce path to non-homebrew path 2022-04-28 16:58:47 +04:00
Alex Korzh
cf08af31ac Ensure Tun2Socks go deps are installed and up to date with latest go 2022-04-28 16:32:38 +04:00
Alex Korzh
1fdcf3877e Remove unused xcode_patcher 2022-04-28 14:56:19 +04:00
Alex Korzh
0fadf035db Add potential go PATH to config build settings 2022-04-28 14:55:58 +04:00
Alex Korzh
58b1c4b511 Update xcode patcher to use WireGuardKitGo folder for iOS project 2022-04-28 14:08:28 +04:00
Alex Korzh
0cc8feac57 Improve Tun2Socks error message 2022-04-28 14:05:30 +04:00
Alex Korzh
ba1efd57a5 Create and use version file from WireGuardKitGo on iOS for consistency 2022-04-28 14:05:14 +04:00
aman
29656fb9a6 Shadowsocks protocol added 2022-04-26 23:49:20 +05:30
Alex Korzh
92d79ebeea Clean up comments 2022-04-24 19:40:02 +04:00
Alex Korzh
3a69107eac Clean up apple compile script 2022-04-24 19:37:56 +04:00
Alex Korzh
4bfb528526 Kill prepare process if any of steps failed 2022-04-24 19:25:43 +04:00
Alex Korzh
fe9dd1d014 Rename ios_compile to apple_compile since it could be used for macOS 2022-04-24 17:32:21 +04:00
Grigory Dobrov
4829c8b314 Merge branch 'fix_inf_windows' into dev 2022-04-17 08:33:46 +03:00
aman
59b4bf5267 Shadowsocks added as a library folder in android 2022-04-16 20:18:27 +05:30
leetthewire
c19f34570d first build 2022-04-14 16:41:39 -07:00
Grigory Dobrov
94d29796b8 fixed line endings for windows drivers *.inf files 2022-04-13 00:45:19 +03:00
leetthewire
e9f44ffcc6 maked first build 2022-04-02 08:02:27 -07:00
leetthewire
a261ab4f0c editing linux sources 2022-04-02 07:31:54 -07:00
aman
929bcf03a0 Android shadowsocks code added 2022-04-01 10:05:58 +05:30
pokamest
a6a69ab1b6 cert updated 2022-03-26 23:15:29 +03:00
leetthewire
39de79d3cd started to file updating for linux build 2022-03-25 12:32:36 -07:00
leetthewire
40ab540179 Merge branch 'dev' of https://github.com/amnezia-vpn/desktop-client into linux_v2 2022-03-22 03:41:29 -07:00
leetthewire
7d7b6f4475 prepared to build 2022-03-22 03:40:47 -07:00
aman
ccdd433e35 Shadowsocks open source code added 2022-03-17 11:38:48 +05:30
aman
4a6ea38ef8 so files for shadowsocks added 2022-03-16 00:41:45 +05:30
Alex Kh
b20e25f052 Move frameworks from extemsion to host app 2022-02-23 18:57:06 +04:00
Alex Kh
8591d4e96c Merge remote-tracking branch 'origin/dev' into ios-wireguard 2022-02-23 18:51:25 +04:00
pokamest
912051637a Android manifest fix, IPC refactoring 2022-02-22 02:08:57 +03:00
pokamest
c233f767f4 Multiple ui fixes, save file function reimpl 2022-02-15 17:08:55 +03:00
Alex Kh
e1293c2c74 Merge remote-tracking branch 'origin/dev' into ios-wireguard 2022-02-15 10:55:45 +04:00
aman
b63bf2465f Android service issue fixed - VPN is keep running when connected and ui closed 2022-02-13 22:52:04 +05:30
pokamest
505c9c6218 Various fixes 2022-02-09 15:23:20 +03:00
pokamest
14350240eb Merge branch 'dev' 2022-02-07 08:42:52 +03:00
pokamest
cb21991efa DNS container fix, Cloak binaries updated 2022-02-05 18:02:49 +03:00
pokamest
49e58c25f2 Installer version bump 2022-02-05 16:08:53 +03:00
pokamest
ac6000a2ae Svg icons, dns ui fix 2022-02-05 15:52:14 +03:00
pokamest
6d1c9edc24 Log panel added 2022-02-04 17:49:48 +03:00
pokamest
1a7fa3746d DNS service fixes for all containers 2022-02-02 02:12:29 +03:00
pokamest
f7a57ffeb4 Cloak container arm support, ss updated 2022-02-02 01:52:37 +03:00
pokamest
ad9d45a154 Dns selection implemented 2022-02-01 19:48:59 +03:00
pokamest
5fffb2afe3 Dns container to internal network 2022-01-31 16:08:22 +03:00
pokamest
1269114074 Cleanup berfore uninstall, post-uninstall refactoring 2022-01-31 00:10:51 +03:00
pokamest
d24f6ae064 Logs functions fixes 2022-01-30 17:35:57 +03:00
pokamest
95fe09489c Vpn and wizard pages fixes 2022-01-28 16:03:21 +03:00
pokamest
1a144da36d SFTP fixes for Macos 2022-01-24 14:29:37 -08:00
pokamest
8e26da1759 Macos build fixes 2022-01-23 15:25:53 -08:00
pokamest
daf53226c3 SFTP fixes 2022-01-24 02:01:56 +03:00
pokamest
2b9e615e51 Various fixes 2022-01-23 19:16:40 +03:00
pokamest
02acbecef5 Re-resolve sites after VPN Connected 2022-01-22 20:00:06 +03:00
pokamest
8f28964ce2 Tiny ui fixes 2022-01-22 18:19:57 +03:00
pokamest
495e74e2f0 Sites page fix 2022-01-22 18:19:38 +03:00
Alex Kh
543bd1a777 Merge remote-tracking branch 'origin/dev' into ios-wireguard 2022-01-06 21:08:50 +04:00
Alex Kh
7c0518843f ShadowSocks disabled for production while in debug/testing mode 2021-12-31 11:04:01 +04:00
Alex Kh
7131257354 missing files added 2021-12-31 10:58:36 +04:00
Alex Kh
db527be97c VPN over Shadowsocks, three providers added, still unstable (testing, not for production) 2021-12-31 10:57:58 +04:00
Alex Kh
7c46e42820 Merge remote-tracking branch 'origin/dev' into ios-wireguard 2021-12-31 10:56:40 +04:00
Alex Kh
6a98cdf974 Insert assets on project generation stage, add static versioning (makes sense on project regeneration) 2021-12-23 15:38:02 +04:00
Alex Kh
9ca8c66c47 Tried to get rid of crashes on sequential vpn turn on/off 2021-12-23 13:13:55 +04:00
Alex Kh
56754d616b Added fastlane scripts, old ids cleaned up 2021-12-22 17:38:17 +04:00
Alex Kh
39e348948c Merge conflicts in .gitmodules resolved 2021-12-21 23:21:10 +04:00
Alex Kh
6583090d4f [WIP] shadowsocks implementation added 2021-12-21 23:17:22 +04:00
Alex Kh
40996888c9 [WIP] shadowsocks implementation prepare 2021-12-13 11:47:09 +04:00
pokamest
1ce26b3ada Merge pull request #43 from boscogh/master
dockerfiles: Added support of Shadowsocks for aarch64
2021-10-25 16:37:39 +03:00
Pavel Malyutin
e7092ae769 dockerfiles: Added support of Shadowsocks for aarch64 2021-10-20 10:26:33 +00:00
pokamest
b8b0ffb626 Merge pull request #21 from amnezia-vpn/dev
Release 1.8.1
2021-06-24 16:48:50 +03:00
2759 changed files with 497348 additions and 1521441 deletions

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
deploy/data/windows/x64/tap/windows_7/OemVista.inf eol=crlf
deploy/data/windows/x64/tap/windows_10/OemVista.inf eol=crlf
deploy/data/windows/x32/tap/windows_7/OemVista.inf eol=crlf
deploy/data/windows/x32/tap/windows_10/OemVista.inf eol=crlf
client/3rd/* linguist-vendored

329
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,329 @@
name: 'Deploy workflow'
on: [push]
jobs:
Build-Linux-Ubuntu:
name: 'Build-Linux-Ubuntu'
runs-on: ubuntu-latest
env:
QT_VERSION: 6.5.0
QIF_VERSION: 4.5
steps:
- name: 'Install Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtremoteobjects qt5compat qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
tools: 'tools_ifw'
set-env: 'true'
extra: '--external 7z'
- name: 'Get sources'
uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 10
- name: 'Setup ccache'
uses: hendrikmuhs/ccache-action@v1.2
- name: 'Build project'
run: |
sudo apt-get install libxkbcommon-x11-0
export QT_BIN_DIR=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64/bin
export QIF_BIN_DIR=${{ runner.temp }}/Qt/Tools/QtInstallerFramework/${{ env.QIF_VERSION }}/bin
bash deploy/build_linux.sh
- name: 'Upload installer artifact'
uses: actions/upload-artifact@v3
with:
name: AmneziaVPN_Linux_installer
path: deploy/AmneziaVPN_Linux_Installer
retention-days: 7
- name: 'Upload unpacked artifact'
uses: actions/upload-artifact@v3
with:
name: AmneziaVPN_Linux_unpacked
path: deploy/AppDir
retention-days: 7
# ------------------------------------------------------
Build-Windows:
name: Build-Windows
runs-on: windows-latest
env:
QT_VERSION: 6.5.0
QIF_VERSION: 4.5
BUILD_ARCH: 64
steps:
- name: 'Get sources'
uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 10
- name: 'Setup ccache'
uses: hendrikmuhs/ccache-action@v1.2
- name: 'Install Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
modules: 'qtremoteobjects qt5compat qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
tools: 'tools_ifw'
set-env: 'true'
extra: '--external 7z'
- name: 'Setup mvsc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: 'x64'
- name: 'Build project'
shell: cmd
run: |
set BUILD_ARCH=${{ env.BUILD_ARCH }}
set QT_BIN_DIR="${{ runner.temp }}\\Qt\\${{ env.QT_VERSION }}\\msvc2019_64\\bin"
set QIF_BIN_DIR="${{ runner.temp }}\\Qt\\Tools\\QtInstallerFramework\\${{ env.QIF_VERSION }}\\bin"
call deploy\\build_windows.bat
- name: 'Upload installer artifact'
uses: actions/upload-artifact@v3
with:
name: AmneziaVPN_Windows_installer
path: AmneziaVPN_x${{ env.BUILD_ARCH }}.exe
retention-days: 7
- name: 'Upload unpacked artifact'
uses: actions/upload-artifact@v3
with:
name: AmneziaVPN_Windows_unpacked
path: deploy\\build_${{ env.BUILD_ARCH }}\\client\\Release
retention-days: 7
# ------------------------------------------------------
Build-IOS:
name: 'Build-IOS'
runs-on: macos-latest
env:
QT_VERSION: 6.5.0
steps:
- name: 'Setup xcode'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13.4'
- name: 'Install desktop Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'mac'
target: 'desktop'
modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia'
arch: 'clang_64'
dir: ${{ runner.temp }}
set-env: 'true'
- name: 'Install iOS Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'mac'
target: 'ios'
modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install go'
uses: actions/setup-go@v3
- name: 'Setup gomobile'
run: |
export PATH=$PATH:~/go/bin
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
- name: 'Get sources'
uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 10
- name: 'Setup ccache'
uses: hendrikmuhs/ccache-action@v1.2
- name: 'Build project'
run: |
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/ios/bin"
export QT_MACOS_ROOT_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos"
export QT_IOS_BIN=$QT_BIN_DIR
export PATH=$PATH:~/go/bin
mkdir build-ios
$QT_IOS_BIN/qt-cmake . -B build-ios -GXcode -DQT_HOST_PATH=$QT_MACOS_ROOT_DIR
# - name: iOS Build/Release With Multiple Targets Action
# uses: kumarsunil0007/build-ios-action@latest
# with:
# project-path: build-ios/AmneziaVPN.xcodeproj
# p12-base64: ~/amnezia-vpn/amnezia-ios-certificates/certs/distribution/443886Q5PL.p12
# mobileprovision-base64: ~/amnezia-vpn/amnezia-ios-certificates/testprofilez.mobileprovision
# code-signing-identity: 'iOS Distribution'
# team-id: 'X7UJ388FXK'
# configuration: Release
# ------------------------------------------------------
Build-MacOS:
name: 'Build-MacOS'
runs-on: macos-latest
env:
QT_VERSION: 6.5.0
QIF_VERSION: 4.5
steps:
- name: 'Setup xcode'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13.4'
- name: 'Install Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'mac'
target: 'desktop'
arch: 'clang_64'
modules: 'qtremoteobjects qt5compat qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
tools: 'tools_ifw'
set-env: 'true'
extra: '--external 7z'
- name: 'Get sources'
uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 10
- name: 'Setup ccache'
uses: hendrikmuhs/ccache-action@v1.2
- name: 'Build project'
run: |
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin"
export QIF_BIN_DIR="${{ runner.temp }}/Qt/Tools/QtInstallerFramework/${{ env.QIF_VERSION }}/bin"
bash deploy/build_macos.sh
- name: 'Upload installer artifact'
uses: actions/upload-artifact@v3
with:
name: AmneziaVPN_MacOS_installer
path: AmneziaVPN.dmg
retention-days: 7
- name: 'Upload unpacked artifact'
uses: actions/upload-artifact@v3
with:
name: AmneziaVPN_MacOS_unpacked
path: deploy/build/client/AmneziaVPN.app
retention-days: 7
# ------------------------------------------------------
Build-Android:
name: 'Build-Android'
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
arch: ['android_x86_64', 'android_x86'] #, 'android_armv7', 'android_arm64_v8a']
env:
QT_VERSION: 6.5.0
steps:
- name: 'Install desktop Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install android Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'android'
arch: ${{ matrix.arch }}
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install GO'
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: 'Get sources'
uses: actions/checkout@v3
with:
submodules: 'true'
fetch-depth: 10
- name: 'Setup ccache'
uses: hendrikmuhs/ccache-action@v1.2
- name: 'Setup Java'
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: 'Build project'
run: |
export QT_HOST_PATH="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64"
export NDK_VERSION=23c
export ANDROID_NDK_PLATFORM=android-23
export ANDROID_NDK_HOME=${{ runner.temp }}/android-ndk-r${NDK_VERSION}
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
export ANDROID_CURRENT_ARCH=${{ matrix.arch }}
if [ ! -f $ANDROID_NDK_ROOT/ndk-build ]; then
wget https://dl.google.com/android/repository/android-ndk-r${NDK_VERSION}-linux.zip -qO ${{ runner.temp }}/ndk.zip &&
unzip -q -d ${{ runner.temp }} ${{ runner.temp }}/ndk.zip ;
fi
export QT_BIN_DIR=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/${{ matrix.arch }}/bin
bash deploy/build_android.sh

142
.github/workflows/tag-deploy.yml vendored Normal file
View File

@@ -0,0 +1,142 @@
name: 'Release deploy workflow'
on:
workflow_dispatch:
# push:
# tags:
# - **
jobs:
Build-Android-Release:
name: 'Build-Android-Release'
runs-on: ubuntu-latest
env:
QT_VERSION: 6.4.1
QIF_VERSION: 4.5
steps:
- name: 'Install desktop Qt'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install android Qt x86_64'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'android'
arch: 'android_x86_64'
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install android Qt x86'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'android'
arch: 'android_x86'
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install android Qt arm_v7'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'android'
arch: 'android_armv7'
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Install android Qt arm_v8'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: 'linux'
target: 'android'
arch: 'android_arm64_v8a'
modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
dir: ${{ runner.temp }}
setup-python: 'true'
set-env: 'true'
extra: '--external 7z'
- name: 'Get sources'
uses: actions/checkout@v3
with:
path: main
submodules: 'true'
fetch-depth: 10
- name: 'Preparations before keystore fetching'
run: |
mkdir keystore
- name: 'Getting keystore'
uses: actions/checkout@v3
with:
repository: amnezia-vpn/amnezia-android-certificates
ssh-key: ${{ secrets.ANDROID_CERTS_SSH_PRIVATE_KEY }}
path: keystore
- name: 'Setup ccache'
uses: hendrikmuhs/ccache-action@v1.2
- name: 'Setup Java'
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: 'Build project'
run: |
export QT_HOST_PATH="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64"
export NDK_VERSION=23c
export ANDROID_NDK_PLATFORM=android-23
export ANDROID_NDK_HOME=${{ runner.temp }}/android-ndk-r${NDK_VERSION}
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
if [ ! -f $ANDROID_NDK_ROOT/ndk-build ]; then
wget https://dl.google.com/android/repository/android-ndk-r${NDK_VERSION}-linux.zip -qO ${{ runner.temp }}/ndk.zip &&
unzip -q -d ${{ runner.temp }} ${{ runner.temp }}/ndk.zip ;
fi
export QT_BIN_DIR=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/android_arm64_v8a/bin
cd main
bash deploy/build_android.sh
- name: 'Signing APK'
run: |
pwd
ANDROID_BUILD_TOOLS_VERSION=30.0.3
${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION}/zipalign -f -v 4 AmneziaVPN-release-unsigned.apk AmneziaVPN-release-aligned.apk
${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION}/apksigner sign --out AmneziaVPN-release-signed.apk --ks keystore/debug.keystore --ks-key-alias ${{ secrets.DEBUG_ANDROID_KEYSTORE_KEY_ALIAS }} --ks-pass pass:${{secrets.DEBUG_ANDROID_KEYSTOTE_KEY_PASS }} AmneziaVPN-release-aligned.apk
- name: 'Upload'
uses: actions/upload-artifact@v3
with:
name: Release APK
path: ${{ runner.temp }}/main/AmneziaVPN-release-signed.apk

19
.gitignore vendored
View File

@@ -23,8 +23,14 @@ qrc_*.cpp
ui_*.h
Makefile*
*build-*
compile_commands.json
# fastlane
client/fastlane/report.xml
client/fastlane/build/*
# Qt-es
client/Release-iphoneos/
client/Debug-iphoneos/
client/.xcode/
client/.qmake.cache
@@ -39,6 +45,7 @@ client/qrc_*.cpp
client/ui_*.h
client/ui_*.cpp
client/Makefile*
client/fastlane/build/
client/*build-*
client/AmneziaVPN.xcodeproj
client/Debug-iphonesimulator/
@@ -48,7 +55,7 @@ client/qmlcache_loader.cpp
client/rep_ipc_interface_replica.h
client/resources_qmlcache.qrc
client/3rd/OpenVPNAdpter/build/
client/3rd/ShadowSocks/build/
# QtCreator
*.autosave
@@ -60,6 +67,12 @@ client/3rd/OpenVPNAdpter/build/
# QtCtreator CMake
CMakeLists.txt.user*
# Linux files
*.7z
deploy/AppDir
deploy/Tools
deploy/AmneziaVPN*Installer*
# MACOS files
.DS_Store
client/.DS_Store
@@ -113,3 +126,7 @@ captures/
# Android Profiling
*.hprof
client/3rd/ShadowSocks/ss_ios.xcconfig
# UML generated pics
out/

View File

@@ -1,27 +0,0 @@
variables:
GIT_STRATEGY: clone
stages:
- build
build-windows:
stage: build
tags:
- windows
script:
- cmd.exe /k "deploy\windows-env.bat && cd deploy && windows.bat"
artifacts:
name: artifacts-windows
paths:
- AmneziaVPN.exe
build-macos:
stage: build
tags:
- macos
script:
- cd deploy && ./macos.sh
artifacts:
name: artifacts-macos
paths:
- AmneziaVPN.dmg

59
.gitmodules vendored
View File

@@ -1,6 +1,3 @@
[submodule "3rd/QtSsh"]
path = 3rd/QtSsh
url = https://github.com/amnezia-vpn/QtSsh.git
[submodule "client/3rd/wireguard-tools"]
path = client/3rd/wireguard-tools
url = https://github.com/WireGuard/wireguard-tools/
@@ -9,7 +6,55 @@
url = https://github.com/WireGuard/wireguard-apple
[submodule "client/3rd/OpenVPNAdapter"]
path = client/3rd/OpenVPNAdapter
url = https://github.com/ss-abramchuk/OpenVPNAdapter.git
[submodule "client/3rd/qzxing"]
path = client/3rd/qzxing
url = https://github.com/ftylitak/qzxing.git
url = https://github.com/amnezia-vpn/OpenVPNAdapter.git
[submodule "client/3rd/ShadowPath"]
path = client/3rd/ShadowPath
url = https://github.com/qman9501/ShadowPath
[submodule "client/3rd/outline-go-tun2socks"]
path = client/3rd/outline-go-tun2socks
url = https://github.com/Jigsaw-Code/outline-go-tun2socks.git
[submodule "client/3rd/CocoaAsyncSocket"]
path = client/3rd/CocoaAsyncSocket
url = https://github.com/robbiehanson/CocoaAsyncSocket.git
[submodule "client/3rd/CocoaLumberjack"]
path = client/3rd/CocoaLumberjack
url = https://github.com/CocoaLumberjack/CocoaLumberjack.git
[submodule "client/3rd/qtkeychain"]
path = client/3rd/qtkeychain
url = https://github.com/frankosterfeld/qtkeychain.git
[submodule "client/3rd/libssh"]
path = client/3rd/libssh
url = https://git.libssh.org/projects/libssh.git/
[submodule "client/3rd/zlib"]
path = client/3rd/zlib
url = https://github.com/madler/zlib.git
[submodule "client/3rd/SortFilterProxyModel"]
path = client/3rd/SortFilterProxyModel
url = https://github.com/mitchcurtis/SortFilterProxyModel.git
[submodule "client/android/cpp/openvpn3"]
path = client/android/cpp/openvpn3
url = https://github.com/amnezia-vpn/openvpn3.git
[submodule "client/android/cpp/asio"]
path = client/android/cpp/asio
url = https://github.com/chriskohlhoff/asio
[submodule "client/android/cpp/lz4"]
path = client/android/cpp/lz4
url = https://github.com/lz4/lz4.git
[submodule "client/android/cpp/mbedtls"]
path = client/android/cpp/mbedtls
url = https://github.com/ARMmbed/mbedtls.git
[submodule "client/android/cpp/openvpn"]
path = client/android/cpp/openvpn
url = https://github.com/schwabe/openvpn.git
[submodule "client/android/cpp/openssl"]
path = client/android/cpp/openssl
url = https://github.com/schwabe/platform_external_openssl.git
[submodule "client/android/cpp/cloak"]
path = client/android/cpp/cloak
url = https://github.com/amnezia-vpn/Cloak
[submodule "client/android/cpp/lzo"]
path = client/android/cpp/lzo
url = https://github.com/amnezia-vpn/lzo.git
[submodule "client/3rd/mbedtls"]
path = client/3rd/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git

47
.gitpod.Dockerfile vendored Normal file
View File

@@ -0,0 +1,47 @@
FROM gitpod/workspace-full-vnc
USER gitpod
RUN sudo apt-get -q update \
&& sudo apt-get install -yq \
build-essential \
libgl1-mesa-dev \
libgstreamer-gl1.0-0 \
libpulse-dev \
libsecret-1-dev \
libxcb-glx0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-render0 \
libxcb-shape0 \
libxcb-shm0 \
libxcb-sync1 \
libxcb-util1 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb1 \
libxkbcommon-dev \
libxkbcommon-x11-0 \
libxcb-xkb-dev \
p7zip-full \
&& sudo rm -rf /var/lib/apt/lists/*
RUN sudo pip3 install aqtinstall
ARG QT_VERSION=6.4.1
ARG QT_ARCH=gcc_64
ARG QT_DIR=/opt/qt
RUN sudo aqt install-qt --outputdir ${QT_DIR} linux desktop ${QT_VERSION} ${QT_ARCH} --modules \
qtremoteobjects \
qt5compat \
qtshadertools
ENV QT_BIN_DIR=${QT_DIR}/${QT_VERSION}/${QT_ARCH}/bin
ARG QIF_VERSION=4.5
ARG QIF_DIR=/opt/qif
RUN sudo aqt install-tool --outputdir ${QIF_DIR} linux desktop tools_ifw
ENV QIF_BIN_DIR=${QIF_DIR}/Tools/QtInstallerFramework/${QIF_VERSION}/bin

8
.gitpod.yml Normal file
View File

@@ -0,0 +1,8 @@
tasks:
- init: >-
deploy/build_linux.sh
image:
file: .gitpod.Dockerfile
vscode:
extensions:
- llvm-vs-code-extensions.vscode-clangd

View File

@@ -1,144 +0,0 @@
language: cpp
branches:
only:
- master
- dev
- /\d+\.\d+/
jobs:
include:
- name: MacOS
os: osx
osx_image: xcode12.5
env:
- QT_VERSION=5.15.2
- QIF_VERSION=4.1
- QT_BIN_DIR=$HOME/Qt/$QT_VERSION/clang_64/bin
- QIF_BIN_DIR=$QT_BIN_DIR/../../../Tools/QtInstallerFramework/$QIF_VERSION/bin
script:
- |
if [ ! -f $HOME/Qt/$QT_VERSION/clang_64/bin/qmake ]; then \
brew install p7zip && \
python3 -m pip install --upgrade pip && \
pip install -U aqtinstall requests py7zr && \
pip show aqtinstall && \
python3 -m aqt install --outputdir $HOME/Qt $QT_VERSION mac desktop clang_64 -m qtbase && \
python3 -m aqt tool --outputdir $HOME/Qt mac tools_ifw $QIF_VERSION qt.tools.ifw.${QIF_VERSION/./};
fi
- bash deploy/build_macos.sh
deploy:
provider: releases
token: $GH_TOKEN
skip_cleanup: true
file:
- "AmneziaVPN_unsigned.dmg"
on:
tags: true
branch: master
- name: Windows_x64
os: windows
env:
- PATH=/c/Python39:/c/Python39/Scripts:$PATH
- QT_VERSION=5.14.2
- QIF_VERSION=4.1
- QT_BIN_DIR="c:\\Qt\\$QT_VERSION\\msvc2017_64\\bin"
- QIF_BIN_DIR="c:\\Qt\\Tools\\QtInstallerFramework\\${QIF_VERSION}\\bin"
- BUILD_ARCH=64
before_install:
- if [ ! -f /C/Qt/$QT_VERSION/msvc2017_64/bin/qmake ]; then choco install python --version 3.9.1; fi
script:
- dir "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build"
- dir "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools"
- |
if [ ! -f /C/Qt/$QT_VERSION/msvc2017_64/bin/qmake ]; then \
python -m pip install --upgrade pip && \
pip3 install -U aqtinstall requests py7zr && \
pip3 show aqtinstall && \
python -m aqt install --outputdir /C/Qt $QT_VERSION windows desktop win64_msvc2017_64 -m qtbase && \
python -m aqt tool --outputdir /C/Qt windows tools_ifw $QIF_VERSION qt.tools.ifw.${QIF_VERSION/./}; \
fi
- echo set BUILD_ARCH=$BUILD_ARCH > winbuild.bat
- echo set QT_BIN_DIR="$QT_BIN_DIR" >> winbuild.bat
- echo set QIF_BIN_DIR="$QIF_BIN_DIR" >> winbuild.bat
- echo call \""C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvars${BUILD_ARCH}.bat\"" >> winbuild.bat
- echo call \""C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\" -arch=amd64" >> winbuild.bat
- echo set WIN_CERT_PW=$WIN_CERT_PW >> winbuild.bat
- echo call deploy\\build_windows.bat >> winbuild.bat
- cmd //c winbuild.bat
deploy:
provider: releases
token: $GH_TOKEN
skip_cleanup: true
file:
- "AmneziaVPN_x64.exe"
on:
tags: true
branch: master
- name: Windows_x32
os: windows
env:
- PATH=/c/Python39:/c/Python39/Scripts:$PATH
- QT_VERSION=5.14.2
- QIF_VERSION=4.1
- QT_BIN_DIR="c:\\Qt\\${QT_VERSION}\\msvc2017\\bin"
- QIF_BIN_DIR="c:\\Qt\\Tools\\QtInstallerFramework\\${QIF_VERSION}\\bin"
- BUILD_ARCH=32
before_install:
- if [ ! -f /C/Qt/$QT_VERSION/msvc2017/bin/qmake ]; then choco install python --version 3.9.1; fi
script:
- dir "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build"
- dir "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools"
- |
if [ ! -f /C/Qt/$QT_VERSION/msvc2017/bin/qmake ]; then \
python -m pip install --upgrade pip && \
pip3 install -U aqtinstall requests py7zr && \
pip3 show aqtinstall && \
python -m aqt install --outputdir /C/Qt $QT_VERSION windows desktop win32_msvc2017 -m qtbase && \
python -m aqt tool --outputdir /C/Qt windows tools_ifw $QIF_VERSION qt.tools.ifw.${QIF_VERSION/./}; \
fi
- echo call \""C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\"" > winbuild.bat
- echo set BUILD_ARCH=$BUILD_ARCH >> winbuild.bat
- echo set QT_BIN_DIR="$QT_BIN_DIR" >> winbuild.bat
- echo set QIF_BIN_DIR="$QIF_BIN_DIR" >> winbuild.bat
- echo call \""C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvars${BUILD_ARCH}.bat\"" >> winbuild.bat
- echo set WIN_CERT_PW=$WIN_CERT_PW >> winbuild.bat
- echo call deploy\\build_windows.bat >> winbuild.bat
- cmd //c winbuild.bat
deploy:
provider: releases
token: $GH_TOKEN
skip_cleanup: true
file:
- "AmneziaVPN_x32.exe"
on:
tags: true
branch: master
deploy:
skip_cleanup: true
before_cache:
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew cleanup; fi
# Cache only .git files under "/usr/local/Homebrew" so "brew update" does not take 5min every build
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then find /usr/local/Homebrew \! -regex ".+\.git.+" -delete; fi
cache:
directories:
- $HOME/Qt
- /C/Qt
- $HOME/Library/Caches/Homebrew

View File

@@ -1,6 +0,0 @@
TEMPLATE = subdirs
SUBDIRS = client
!ios:!android {
SUBDIRS += service platform
}

26
CMakeLists.txt Normal file
View File

@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
set(PROJECT AmneziaVPN)
project(${PROJECT} VERSION 3.0.7.4
DESCRIPTION "AmneziaVPN"
HOMEPAGE_URL "https://amnezia.org/"
)
set(RELEASE_DATE "2023-05-15")
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
if(ANDROID)
set(QT_ANDROID_BUILD_ALL_ABIS ON)
endif()
if(APPLE AND NOT IOS)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
endif()
add_subdirectory(client)
if(NOT IOS AND NOT ANDROID)
add_subdirectory(service)
include(${CMAKE_SOURCE_DIR}/deploy/installer/config.cmake)
endif()

106
README.md
View File

@@ -1,16 +1,16 @@
# Amnezia VPN
## _The best client for self-hosted VPN_
[![Build Status](https://travis-ci.com/amnezia-vpn/desktop-client.svg?branch=master)](https://travis-ci.com/amnezia-vpn/desktop-client)
[![Build Status](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml/badge.svg?branch=dev)](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml?query=branch:dev)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/amnezia-vpn/amnezia-client)
Amnezia is a VPN client with the key feature of deploying your own VPN server on you virtual server.
## Features
- Very easy to use - enter your ip address, ssh login and password, and Amnezia client will automatically install VPN docker containers to your server and connect to VPN.
- OpenVPN and OpenVPN over ShadowSocks protocols support.
- Custom VPN routing mode support - add any sites to client to enable VPN only for them.
- Windows and MacOS support.
- Unsecure sharing connection profile for family use.
- OpenVPN, ShadowSocks, WireGuard, IKEv2 protocols support.
- Split tunneling support - add any sites to client to enable VPN only for them (only for desktops)
- Windows, MacOS, Linux, Android, iOS releases.
## Tech
@@ -20,19 +20,103 @@ AmneziaVPN uses a number of open source projects to work:
- [OpenVPN](https://openvpn.net/)
- [ShadowSocks](https://shadowsocks.org/)
- [Qt](https://www.qt.io/)
- [EasyRSA](https://github.com/OpenVPN/easy-rsa) - part of OpenVPN
- [CygWin](https://www.cygwin.com/) - only for Windiws, used for launching EasyRSA scripts
- [QtSsh](https://github.com/jaredtao/QtSsh) - forked form Qt Creator
- [LibSsh](https://libssh.org) - forked form Qt Creator
- and more...
## Checking out the source code
Make sure to pull all submodules after checking out the repo.
```bash
git submodule update --init
```
## Development
Want to contribute? Welcome!
### Building sources and deployment
Easiest way to build your own executables - is to fork project and configure [Travis CI](https://travis-ci.com/)
Or you can build sources manually using Qt Creator. Qt >= 14.2 supported.
Look to the `build_macos.sh` and `build_windows.bat` scripts in `deploy` folder for details.
Look deploy folder for build scripts.
### How to build iOS app from source code on MacOS
1. First, make sure you have [XCode](https://developer.apple.com/xcode/) installed, at least version 14 or higher.
2. We use QT to generate the XCode project. we need QT version 6.4. Install QT for macos in [here](https://doc.qt.io/qt-6/macos.html)
3. Install cmake is require. We recommend cmake version 3.25. You can install cmake in [here](https://cmake.org/download/)
4. You also need to install go >= v1.16. If you don't have it done already,
download go from the [official website](https://golang.org/dl/) or use Homebrew.
Latest version is recommended. Install gomobile
```bash
export PATH=$PATH:~/go/bin
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
```
5. Build project
```bash
export QT_BIN_DIR="<PATH-TO-QT-FOLDER>/Qt/<QT-VERSION>/ios/bin"
export QT_IOS_BIN=$QT_BIN_DIR
export PATH=$PATH:~/go/bin
mkdir build-ios
$QT_IOS_BIN/qt-cmake . -B build-ios -GXcode -DQT_HOST_PATH=$QT_BIN_DIR
```
Replace PATH-TO-QT-FOLDER and QT-VERSION to your environment
If you get `gomobile: command not found` make sure to set PATH to the location
of the bin folder where gomobile was installed. Usually, it's in `GOPATH`.
```bash
export PATH=$(PATH):/path/to/GOPATH/bin
```
5. Open XCode project. You can then run/test/archive/ship the app.
If build fails with the following error
```
make: ***
[$(PROJECTDIR)/client/build/AmneziaVPN.build/Debug-iphoneos/wireguard-go-bridge/goroot/.prepared]
Error 1
```
Add a user defined variable to both AmneziaVPN and WireGuardNetworkExtension targets' build settings with
key `PATH` and value `${PATH}/path/to/bin/folder/with/go/executable`, e.g. `${PATH}:/usr/local/go/bin`.
if above error still persists on you M1 Mac, then most probably you need to install arch based cmake
```
arch -arm64 brew install cmake
```
Build might fail with "source files not found" error the first time you try it, because modern XCode build system compiles
dependencies in parallel, and some dependencies end up being built after the ones that
require them. In this case simply restart the build.
## How to build the Android app
_tested on Mac OS_
The Android app has the following requirements:
* JDK 11
* Android platform SDK 33
* cmake 3.25.0
After you have installed QT, QT Creator and Android Studio installed, you need to configure QT Creator correctly. Click in the top menu bar on `QT Creator` -> `Preferences` -> `Devices` and select the tab `Android`.
* set path to jdk 11
* set path to Android SDK ($ANDROID_HOME)
In case you get errors regarding missing SDK or 'sdkmanager not running', you cannot fix them by correcting the paths and you have some spare GBs on your disk, you can let QT Creator install all requirements by choosing an empty folder for `Android SDK location` and click on `Set Up SDK`. Be aware: This will install a second Android SDK and NDK on your machine!
Double check that the right cmake version is configured: Click on `QT Creator` -> `Preferences` and click on the side menu on `Kits`. Under the center content view's `Kits` tab you'll find an entry `CMake Tool`. If the default selected CMake version is lower than 3.25.0, install on your system CMake >= 3.25.0 and choose `System CMake at <path>` from the drop down list. If this entry is missing, you either have not installed CMake yet or QT Creator hasn't found the path to it. In that case click in the preferences window on the side menu item `CMake`, then on the tab `Tools`in the center content view and finally on the Button `Add` to set the path to your installed CMake.
Please make sure that you have selected Android Platform SDK 33 for your project: click in the main view's side menu on on `Projects`, on the left you'll see a section `Build & Run` showing different Android build targets. You can select any of them, Amnezia VPN's project setup is designed in a way that always all Android targets will be build. Click on the targets submenu item `Build` and scroll in the center content view to `Build Steps`. Click on `Details` at the end of the headline `Build Android APK` (The `Details` button might be hidden in case QT Creator Window is not running in full screen!). Here we are: choose `android-33` as `Android Build platform SDK`.
That's it you should be ready to compile the project from QT Creator!
### Development flow
After you've hit the build button, QT-Creator copies the whole project to a folder in the repositories parent directory. The folder should look something like `build-amnezia-client-Android_Qt_<version>_Clang_<architecture>-<BuildType>`.
If you want to develop Amnezia VPNs Android components written in Kotlin, such as components using system APIs, you need to import the generated project in Android Studio with `build-amnezia-client-Android_Qt_<version>_Clang_<architecture>-<BuildType>/client/android-build` as the projects root directory. While you should be able to compile the generated project from Android Studio, you cannot work directly in the repository's Android project. So whenever you are confident with your work in the generated project, you'll need to copy and paste the affected files to the corresponding path in the repositories Android project so that you can add and commit your changes!
You may face compiling issues in QT Creator after you've worked in Android Studio on the generated project. Just do a `./gradlew clean` in the generated project's root directory (`<path>/client/android-build/.`) and you should be good to continue.
## License
GPL v.3

1
client/3rd/CocoaAsyncSocket vendored Submodule

1
client/3rd/CocoaLumberjack vendored Submodule

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>PacketProcessor.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,18 @@
//
// CocoaAsyncSocket.h
// CocoaAsyncSocket
//
// Created by Derek Clarkson on 10/08/2015.
// CocoaAsyncSocket project is in the public domain.
//
#import <Foundation/Foundation.h>
//! Project version number for CocoaAsyncSocket.
FOUNDATION_EXPORT double cocoaAsyncSocketVersionNumber;
//! Project version string for CocoaAsyncSocket.
FOUNDATION_EXPORT const unsigned char cocoaAsyncSocketVersionString[];
#import <CocoaAsyncSocket/GCDAsyncSocket.h>
#import <CocoaAsyncSocket/GCDAsyncUdpSocket.h>

View File

@@ -0,0 +1,6 @@
framework module CocoaAsyncSocket {
umbrella header "CocoaAsyncSocket.h"
export *
module * { export * }
}

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Headers/CocoaAsyncSocket.h</key>
<data>
19xueMkhcDCf6A2ihyiTCDjWjd4=
</data>
<key>Headers/GCDAsyncSocket.h</key>
<data>
JwDJxahaKup9fnB5MJuoxDHbdDs=
</data>
<key>Headers/GCDAsyncUdpSocket.h</key>
<data>
9hL7D86xSUKQ1TBRDa+fDNkDlqI=
</data>
<key>Info.plist</key>
<data>
eCKEB+C8HfC7DIu6eNc6P3wxyLo=
</data>
<key>Modules/module.modulemap</key>
<data>
+n94rYTWDjekX3imyh+PSyA9vgA=
</data>
</dict>
<key>files2</key>
<dict>
<key>Headers/CocoaAsyncSocket.h</key>
<dict>
<key>hash</key>
<data>
19xueMkhcDCf6A2ihyiTCDjWjd4=
</data>
<key>hash2</key>
<data>
VpE7gL1U1p/0urO77FEjPNjY06qrttQJnalOd+6VYDQ=
</data>
</dict>
<key>Headers/GCDAsyncSocket.h</key>
<dict>
<key>hash</key>
<data>
JwDJxahaKup9fnB5MJuoxDHbdDs=
</data>
<key>hash2</key>
<data>
JL0b2lWPgVphz/ekZLsGMKrShDXTK2YY53aKtusc9hk=
</data>
</dict>
<key>Headers/GCDAsyncUdpSocket.h</key>
<dict>
<key>hash</key>
<data>
9hL7D86xSUKQ1TBRDa+fDNkDlqI=
</data>
<key>hash2</key>
<data>
uNVm5yZ0jBhGDXZuAynPXvem1qcBvAVdWXAewQdJbh8=
</data>
</dict>
<key>Modules/module.modulemap</key>
<dict>
<key>hash</key>
<data>
+n94rYTWDjekX3imyh+PSyA9vgA=
</data>
<key>hash2</key>
<data>
RoVn8xMeEnU3Izg0DtYjYL/krI8V7qw0sa7Ggf+08Rs=
</data>
</dict>
</dict>
<key>rules</key>
<dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleSignature</key>
<string>????</string>
</dict>
</plist>

View File

@@ -0,0 +1,19 @@
//
// PacketProcessor.h
// PacketProcessor
//
// Created by sanchez on 20.12.2021.
//
#import <Foundation/Foundation.h>
//! Project version number for PacketProcessor.
FOUNDATION_EXPORT double PacketProcessorVersionNumber;
//! Project version string for PacketProcessor.
FOUNDATION_EXPORT const unsigned char PacketProcessorVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <PacketProcessor/PublicHeader.h>
#import "TunnelInterface.h"

View File

@@ -0,0 +1,23 @@
//
// TunnelInterface.h
// Potatso
//
// Created by LEI on 12/23/15.
// Copyright © 2015 TouchingApp. All rights reserved.
//
#import <Foundation/Foundation.h>
@import NetworkExtension;
#define TunnelMTU 1600
#define kTun2SocksStoppedNotification @"kTun2SocksStoppedNotification"
@interface TunnelInterface : NSObject
+ (TunnelInterface *)sharedInterface;
+ (NSError *)setupWithPacketTunnelFlow:(NEPacketTunnelFlow *)packetFlow;
+ (void)processPackets;
+ (void)writePacket: (NSData *)packet;
+ (void)startTun2Socks: (int)socksServerPort;
+ (void)stop;
@end

View File

@@ -0,0 +1,239 @@
//
// TunnelInterface.m
// Potatso
//
// Created by LEI on 12/23/15.
// Copyright © 2015 TouchingApp. All rights reserved.
//
#import "TunnelInterface.h"
#import <netinet/ip.h>
#import "ipv4/lwip/ip4.h"
#import "lwip/udp.h"
#import "lwip/ip.h"
#import <arpa/inet.h>
#import "inet_chksum.h"
#import "tun2socks/tun2socks.h"
@import CocoaAsyncSocket;
#define kTunnelInterfaceErrorDomain [NSString stringWithFormat:@"%@.TunnelInterface", [[NSBundle mainBundle] bundleIdentifier]]
@interface TunnelInterface () <GCDAsyncUdpSocketDelegate>
@property (nonatomic) NEPacketTunnelFlow *tunnelPacketFlow;
@property (nonatomic) NSMutableDictionary *udpSession;
@property (nonatomic) GCDAsyncUdpSocket *udpSocket;
@property (nonatomic) int readFd;
@property (nonatomic) int writeFd;
@end
@implementation TunnelInterface
+ (TunnelInterface *)sharedInterface {
static dispatch_once_t onceToken;
static TunnelInterface *interface;
dispatch_once(&onceToken, ^{
interface = [TunnelInterface new];
});
return interface;
}
- (instancetype)init {
self = [super init];
if (self) {
_udpSession = [NSMutableDictionary dictionaryWithCapacity:5];
_udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_queue_create("udp", NULL)];
}
return self;
}
+ (NSError *)setupWithPacketTunnelFlow:(NEPacketTunnelFlow *)packetFlow {
if (packetFlow == nil) {
return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey: @"PacketTunnelFlow can't be nil."}];
}
[TunnelInterface sharedInterface].tunnelPacketFlow = packetFlow;
NSError *error;
GCDAsyncUdpSocket *udpSocket = [TunnelInterface sharedInterface].udpSocket;
[udpSocket bindToPort:0 error:&error];
if (error) {
return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"UDP bind fail(%@).", [error localizedDescription]]}];
}
[udpSocket beginReceiving:&error];
if (error) {
return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"UDP bind fail(%@).", [error localizedDescription]]}];
}
int fds[2];
if (pipe(fds) < 0) {
return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Unable to pipe."}];
}
[TunnelInterface sharedInterface].readFd = fds[0];
[TunnelInterface sharedInterface].writeFd = fds[1];
return nil;
}
+ (void)startTun2Socks: (int)socksServerPort {
[NSThread detachNewThreadSelector:@selector(_startTun2Socks:) toTarget:[TunnelInterface sharedInterface] withObject:@(socksServerPort)];
}
+ (void)stop {
stop_tun2socks();
}
+ (void)writePacket:(NSData *)packet {
dispatch_async(dispatch_get_main_queue(), ^{
[[TunnelInterface sharedInterface].tunnelPacketFlow writePackets:@[packet] withProtocols:@[@(AF_INET)]];
});
}
+ (void)processPackets {
__weak typeof(self) weakSelf = self;
[[TunnelInterface sharedInterface].tunnelPacketFlow readPacketsWithCompletionHandler:^(NSArray<NSData *> * _Nonnull packets, NSArray<NSNumber *> * _Nonnull protocols) {
for (NSData *packet in packets) {
uint8_t *data = (uint8_t *)packet.bytes;
struct ip_hdr *iphdr = (struct ip_hdr *)data;
uint8_t proto = IPH_PROTO(iphdr);
if (proto == IP_PROTO_UDP) {
[[TunnelInterface sharedInterface] handleUDPPacket:packet];
}else if (proto == IP_PROTO_TCP) {
[[TunnelInterface sharedInterface] handleTCPPPacket:packet];
}
}
[weakSelf processPackets];
}];
}
- (void)_startTun2Socks: (NSNumber *)socksServerPort {
char socks_server[50];
sprintf(socks_server, "127.0.0.1:%d", (int)([socksServerPort integerValue]));
#if TCP_DATA_LOG_ENABLE
char *log_lvel = "debug";
#else
char *log_lvel = "none";
#endif
char *argv[] = {
"tun2socks",
"--netif-ipaddr",
"192.0.2.4",
"--netif-netmask",
"255.255.255.0",
"--loglevel",
log_lvel,
"--socks-server-addr",
socks_server
};
tun2socks_main(sizeof(argv)/sizeof(argv[0]), argv, self.readFd, TunnelMTU);
close(self.readFd);
close(self.writeFd);
[[NSNotificationCenter defaultCenter] postNotificationName:kTun2SocksStoppedNotification object:nil];
}
- (void)handleTCPPPacket: (NSData *)packet {
uint8_t message[TunnelMTU+2];
memcpy(message + 2, packet.bytes, packet.length);
message[0] = packet.length / 256;
message[1] = packet.length % 256;
write(self.writeFd , message , packet.length + 2);
}
- (void)handleUDPPacket: (NSData *)packet {
uint8_t *data = (uint8_t *)packet.bytes;
int data_len = (int)packet.length;
struct ip_hdr *iphdr = (struct ip_hdr *)data;
uint8_t version = IPH_V(iphdr);
switch (version) {
case 4: {
uint16_t iphdr_hlen = IPH_HL(iphdr) * 4;
data = data + iphdr_hlen;
data_len -= iphdr_hlen;
struct udp_hdr *udphdr = (struct udp_hdr *)data;
data = data + sizeof(struct udp_hdr *);
data_len -= sizeof(struct udp_hdr *);
NSData *outData = [[NSData alloc] initWithBytes:data length:data_len];
struct in_addr dest = { iphdr->dest.addr };
NSString *destHost = [NSString stringWithUTF8String:inet_ntoa(dest)];
NSString *key = [self strForHost:iphdr->dest.addr port:udphdr->dest];
NSString *value = [self strForHost:iphdr->src.addr port:udphdr->src];;
self.udpSession[key] = value;
[self.udpSocket sendData:outData toHost:destHost port:ntohs(udphdr->dest) withTimeout:30 tag:0];
} break;
case 6: {
} break;
}
}
- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress:(NSData *)address withFilterContext:(id)filterContext {
const struct sockaddr_in *addr = (const struct sockaddr_in *)[address bytes];
ip_addr_p_t dest ={ addr->sin_addr.s_addr };
in_port_t dest_port = addr->sin_port;
NSString *strHostPort = self.udpSession[[self strForHost:dest.addr port:dest_port]];
NSArray *hostPortArray = [strHostPort componentsSeparatedByString:@":"];
int src_ip = [hostPortArray[0] intValue];
int src_port = [hostPortArray[1] intValue];
uint8_t *bytes = (uint8_t *)[data bytes];
int bytes_len = (int)data.length;
int udp_length = sizeof(struct udp_hdr) + bytes_len;
int total_len = IP_HLEN + udp_length;
ip_addr_p_t src = {src_ip};
struct ip_hdr *iphdr = generateNewIPHeader(IP_PROTO_UDP, dest, src, total_len);
struct udp_hdr udphdr;
udphdr.src = dest_port;
udphdr.dest = src_port;
udphdr.len = hton16(udp_length);
udphdr.chksum = hton16(0);
uint8_t *udpdata = malloc(sizeof(uint8_t) * udp_length);
memcpy(udpdata, &udphdr, sizeof(struct udp_hdr));
memcpy(udpdata + sizeof(struct udp_hdr), bytes, bytes_len);
ip_addr_t odest = { dest.addr };
ip_addr_t osrc = { src_ip };
struct pbuf *p_udp = pbuf_alloc(PBUF_TRANSPORT, udp_length, PBUF_RAM);
pbuf_take(p_udp, udpdata, udp_length);
struct udp_hdr *new_udphdr = (struct udp_hdr *) p_udp->payload;
new_udphdr->chksum = inet_chksum_pseudo(p_udp, IP_PROTO_UDP, p_udp->len, &odest, &osrc);
uint8_t *ipdata = malloc(sizeof(uint8_t) * total_len);
memcpy(ipdata, iphdr, IP_HLEN);
memcpy(ipdata + sizeof(struct ip_hdr), p_udp->payload, udp_length);
NSData *outData = [[NSData alloc] initWithBytes:ipdata length:total_len];
free(ipdata);
free(iphdr);
free(udpdata);
pbuf_free(p_udp);
[TunnelInterface writePacket:outData];
}
struct ip_hdr *generateNewIPHeader(u8_t proto, ip_addr_p_t src, ip_addr_p_t dest, uint16_t total_len) {
struct ip_hdr *iphdr = malloc(sizeof(struct ip_hdr));
IPH_VHL_SET(iphdr, 4, IP_HLEN / 4);
IPH_TOS_SET(iphdr, 0);
IPH_LEN_SET(iphdr, htons(total_len));
IPH_ID_SET(iphdr, 0);
IPH_OFFSET_SET(iphdr, 0);
IPH_TTL_SET(iphdr, 64);
IPH_PROTO_SET(iphdr, IP_PROTO_UDP);
iphdr->src = src;
iphdr->dest = dest;
IPH_CHKSUM_SET(iphdr, 0);
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
return iphdr;
}
- (NSString *)strForHost: (int)host port: (int)port {
return [NSString stringWithFormat:@"%d:%d",host, port];
}
@end

View File

@@ -0,0 +1,400 @@
/**
* @file BLog.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* A global object for logging.
*/
#ifndef BADVPN_BLOG_H
#define BADVPN_BLOG_H
#include <stdarg.h>
#include <string.h>
#include "misc/debug.h"
#include "misc/memref.h"
#include "base/BMutex.h"
// auto-generated channel numbers and number of channels
#include "generated/blog_channels_defines.h"
// keep in sync with level names in BLog.c!
#define BLOG_ERROR 1
#define BLOG_WARNING 2
#define BLOG_NOTICE 3
#define BLOG_INFO 4
#define BLOG_DEBUG 5
#define BLog(...) BLog_LogToChannel(BLOG_CURRENT_CHANNEL, __VA_ARGS__)
#define BContextLog(context, ...) BLog_ContextLog((context), BLOG_CURRENT_CHANNEL, __VA_ARGS__)
#define BLOG_CCCC(context) BLog_MakeChannelContext((context), BLOG_CURRENT_CHANNEL)
typedef void (*_BLog_log_func) (int channel, int level, const char *msg);
typedef void (*_BLog_free_func) (void);
struct _BLog_channel {
const char *name;
int loglevel;
};
struct _BLog_global {
#ifndef NDEBUG
int initialized; // initialized statically
#endif
struct _BLog_channel channels[BLOG_NUM_CHANNELS];
_BLog_log_func log_func;
_BLog_free_func free_func;
BMutex mutex;
#ifndef NDEBUG
int logging;
#endif
char logbuf[2048];
int logbuf_pos;
};
extern struct _BLog_channel blog_channel_list[];
extern struct _BLog_global blog_global;
typedef void (*BLog_logfunc) (void *);
typedef struct {
BLog_logfunc logfunc;
void *logfunc_user;
} BLogContext;
typedef struct {
BLogContext context;
int channel;
} BLogChannelContext;
static int BLogGlobal_GetChannelByName (const char *channel_name);
static void BLog_Init (_BLog_log_func log_func, _BLog_free_func free_func);
static void BLog_Free (void);
static void BLog_SetChannelLoglevel (int channel, int loglevel);
static int BLog_WouldLog (int channel, int level);
static void BLog_Begin (void);
static void BLog_AppendVarArg (const char *fmt, va_list vl);
static void BLog_Append (const char *fmt, ...);
static void BLog_AppendBytes (MemRef data);
static void BLog_Finish (int channel, int level);
static void BLog_LogToChannelVarArg (int channel, int level, const char *fmt, va_list vl);
static void BLog_LogToChannel (int channel, int level, const char *fmt, ...);
static void BLog_LogViaFuncVarArg (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, va_list vl);
static void BLog_LogViaFunc (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, ...);
static BLogContext BLog_RootContext (void);
static BLogContext BLog_MakeContext (BLog_logfunc logfunc, void *logfunc_user);
static void BLog_ContextLogVarArg (BLogContext context, int channel, int level, const char *fmt, va_list vl);
static void BLog_ContextLog (BLogContext context, int channel, int level, const char *fmt, ...);
static BLogChannelContext BLog_MakeChannelContext (BLogContext context, int channel);
static void BLog_ChannelContextLogVarArg (BLogChannelContext ccontext, int level, const char *fmt, va_list vl);
static void BLog_ChannelContextLog (BLogChannelContext ccontext, int level, const char *fmt, ...);
void BLog_InitStdout (void);
void BLog_InitStderr (void);
int BLogGlobal_GetChannelByName (const char *channel_name)
{
int i;
for (i = 0; i < BLOG_NUM_CHANNELS; i++) {
if (!strcmp(blog_channel_list[i].name, channel_name)) {
return i;
}
}
return -1;
}
void BLog_Init (_BLog_log_func log_func, _BLog_free_func free_func)
{
ASSERT(!blog_global.initialized)
#ifndef NDEBUG
blog_global.initialized = 1;
#endif
// initialize channels
memcpy(blog_global.channels, blog_channel_list, BLOG_NUM_CHANNELS * sizeof(struct _BLog_channel));
blog_global.log_func = log_func;
blog_global.free_func = free_func;
#ifndef NDEBUG
blog_global.logging = 0;
#endif
blog_global.logbuf_pos = 0;
blog_global.logbuf[0] = '\0';
ASSERT_FORCE(BMutex_Init(&blog_global.mutex))
}
void BLog_Free (void)
{
ASSERT(blog_global.initialized)
#ifndef NDEBUG
ASSERT(!blog_global.logging)
#endif
BMutex_Free(&blog_global.mutex);
#ifndef NDEBUG
blog_global.initialized = 0;
#endif
blog_global.free_func();
}
void BLog_SetChannelLoglevel (int channel, int loglevel)
{
ASSERT(blog_global.initialized)
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(loglevel >= 0 && loglevel <= BLOG_DEBUG)
blog_global.channels[channel].loglevel = loglevel;
}
int BLog_WouldLog (int channel, int level)
{
ASSERT(blog_global.initialized)
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
return (level <= blog_global.channels[channel].loglevel);
}
void BLog_Begin (void)
{
ASSERT(blog_global.initialized)
BMutex_Lock(&blog_global.mutex);
#ifndef NDEBUG
ASSERT(!blog_global.logging)
blog_global.logging = 1;
#endif
}
void BLog_AppendVarArg (const char *fmt, va_list vl)
{
ASSERT(blog_global.initialized)
#ifndef NDEBUG
ASSERT(blog_global.logging)
#endif
ASSERT(blog_global.logbuf_pos >= 0)
ASSERT(blog_global.logbuf_pos < sizeof(blog_global.logbuf))
int w = vsnprintf(blog_global.logbuf + blog_global.logbuf_pos, sizeof(blog_global.logbuf) - blog_global.logbuf_pos, fmt, vl);
if (w >= sizeof(blog_global.logbuf) - blog_global.logbuf_pos) {
blog_global.logbuf_pos = sizeof(blog_global.logbuf) - 1;
} else {
blog_global.logbuf_pos += w;
}
}
void BLog_Append (const char *fmt, ...)
{
ASSERT(blog_global.initialized)
#ifndef NDEBUG
ASSERT(blog_global.logging)
#endif
va_list vl;
va_start(vl, fmt);
BLog_AppendVarArg(fmt, vl);
va_end(vl);
}
void BLog_AppendBytes (MemRef data)
{
ASSERT(blog_global.initialized)
#ifndef NDEBUG
ASSERT(blog_global.logging)
#endif
ASSERT(blog_global.logbuf_pos >= 0)
ASSERT(blog_global.logbuf_pos < sizeof(blog_global.logbuf))
size_t avail = (sizeof(blog_global.logbuf) - 1) - blog_global.logbuf_pos;
data.len = (data.len > avail ? avail : data.len);
memcpy(blog_global.logbuf + blog_global.logbuf_pos, data.ptr, data.len);
blog_global.logbuf_pos += data.len;
blog_global.logbuf[blog_global.logbuf_pos] = '\0';
}
void BLog_Finish (int channel, int level)
{
ASSERT(blog_global.initialized)
#ifndef NDEBUG
ASSERT(blog_global.logging)
#endif
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
ASSERT(BLog_WouldLog(channel, level))
ASSERT(blog_global.logbuf_pos >= 0)
ASSERT(blog_global.logbuf_pos < sizeof(blog_global.logbuf))
ASSERT(blog_global.logbuf[blog_global.logbuf_pos] == '\0')
blog_global.log_func(channel, level, blog_global.logbuf);
#ifndef NDEBUG
blog_global.logging = 0;
#endif
blog_global.logbuf_pos = 0;
blog_global.logbuf[0] = '\0';
BMutex_Unlock(&blog_global.mutex);
}
void BLog_LogToChannelVarArg (int channel, int level, const char *fmt, va_list vl)
{
ASSERT(blog_global.initialized)
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
if (!BLog_WouldLog(channel, level)) {
return;
}
BLog_Begin();
BLog_AppendVarArg(fmt, vl);
BLog_Finish(channel, level);
}
void BLog_LogToChannel (int channel, int level, const char *fmt, ...)
{
ASSERT(blog_global.initialized)
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
if (!BLog_WouldLog(channel, level)) {
return;
}
va_list vl;
va_start(vl, fmt);
BLog_Begin();
BLog_AppendVarArg(fmt, vl);
BLog_Finish(channel, level);
va_end(vl);
}
void BLog_LogViaFuncVarArg (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, va_list vl)
{
ASSERT(blog_global.initialized)
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
if (!BLog_WouldLog(channel, level)) {
return;
}
BLog_Begin();
func(arg);
BLog_AppendVarArg(fmt, vl);
BLog_Finish(channel, level);
}
void BLog_LogViaFunc (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, ...)
{
ASSERT(blog_global.initialized)
ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS)
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
if (!BLog_WouldLog(channel, level)) {
return;
}
va_list vl;
va_start(vl, fmt);
BLog_Begin();
func(arg);
BLog_AppendVarArg(fmt, vl);
BLog_Finish(channel, level);
va_end(vl);
}
static void BLog__root_logfunc (void *unused)
{
}
static BLogContext BLog_RootContext (void)
{
return BLog_MakeContext(BLog__root_logfunc, NULL);
}
static BLogContext BLog_MakeContext (BLog_logfunc logfunc, void *logfunc_user)
{
ASSERT(logfunc)
BLogContext context;
context.logfunc = logfunc;
context.logfunc_user = logfunc_user;
return context;
}
static void BLog_ContextLogVarArg (BLogContext context, int channel, int level, const char *fmt, va_list vl)
{
BLog_LogViaFuncVarArg(context.logfunc, context.logfunc_user, channel, level, fmt, vl);
}
static void BLog_ContextLog (BLogContext context, int channel, int level, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
BLog_ContextLogVarArg(context, channel, level, fmt, vl);
va_end(vl);
}
static BLogChannelContext BLog_MakeChannelContext (BLogContext context, int channel)
{
BLogChannelContext ccontext;
ccontext.context = context;
ccontext.channel = channel;
return ccontext;
}
static void BLog_ChannelContextLogVarArg (BLogChannelContext ccontext, int level, const char *fmt, va_list vl)
{
BLog_ContextLogVarArg(ccontext.context, ccontext.channel, level, fmt, vl);
}
static void BLog_ChannelContextLog (BLogChannelContext ccontext, int level, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
BLog_ChannelContextLogVarArg(ccontext, level, fmt, vl);
va_end(vl);
}
#endif

View File

@@ -0,0 +1,75 @@
/**
* @file BLog.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stddef.h>
#include <Foundation/Foundation.h>
#include "BLog.h"
#ifndef BADVPN_PLUGIN
struct _BLog_channel blog_channel_list[] = {
#include "generated/blog_channels_list.h"
};
struct _BLog_global blog_global = {
#ifndef NDEBUG
0
#endif
};
#endif
// keep in sync with level numbers in BLog.h!
static char *level_names[] = { NULL, "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG" };
static void stdout_log (int channel, int level, const char *msg)
{
NSLog(@"%s(%s): %s\n", level_names[level], blog_global.channels[channel].name, msg);
}
static void stderr_log (int channel, int level, const char *msg)
{
NSLog(@"%s(%s): %s\n", level_names[level], blog_global.channels[channel].name, msg);
}
static void stdout_stderr_free (void)
{
}
void BLog_InitStdout (void)
{
BLog_Init(stdout_log, stdout_stderr_free);
}
void BLog_InitStderr (void)
{
BLog_Init(stderr_log, stdout_stderr_free);
}

View File

@@ -0,0 +1,150 @@
/**
* @file BLog_syslog.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
#include <stdio.h>
#include <syslog.h>
#include "misc/debug.h"
#include "BLog_syslog.h"
static int resolve_facility (char *str, int *out)
{
if (!strcmp(str, "authpriv")) {
*out = LOG_AUTHPRIV;
}
else if (!strcmp(str, "cron")) {
*out = LOG_CRON;
}
else if (!strcmp(str, "daemon")) {
*out = LOG_DAEMON;
}
else if (!strcmp(str, "ftp")) {
*out = LOG_FTP;
}
else if (!strcmp(str, "local0")) {
*out = LOG_LOCAL0;
}
else if (!strcmp(str, "local1")) {
*out = LOG_LOCAL1;
}
else if (!strcmp(str, "local2")) {
*out = LOG_LOCAL2;
}
else if (!strcmp(str, "local3")) {
*out = LOG_LOCAL3;
}
else if (!strcmp(str, "local4")) {
*out = LOG_LOCAL4;
}
else if (!strcmp(str, "local5")) {
*out = LOG_LOCAL5;
}
else if (!strcmp(str, "local6")) {
*out = LOG_LOCAL6;
}
else if (!strcmp(str, "local7")) {
*out = LOG_LOCAL7;
}
else if (!strcmp(str, "lpr")) {
*out = LOG_LPR;
}
else if (!strcmp(str, "mail")) {
*out = LOG_MAIL;
}
else if (!strcmp(str, "news")) {
*out = LOG_NEWS;
}
else if (!strcmp(str, "syslog")) {
*out = LOG_SYSLOG;
}
else if (!strcmp(str, "user")) {
*out = LOG_USER;
}
else if (!strcmp(str, "uucp")) {
*out = LOG_UUCP;
}
else {
return 0;
}
return 1;
}
static int convert_level (int level)
{
ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG)
switch (level) {
case BLOG_ERROR:
return LOG_ERR;
case BLOG_WARNING:
return LOG_WARNING;
case BLOG_NOTICE:
return LOG_NOTICE;
case BLOG_INFO:
return LOG_INFO;
case BLOG_DEBUG:
return LOG_DEBUG;
default:
ASSERT(0)
return 0;
}
}
static struct {
char ident[200];
} syslog_global;
static void syslog_log (int channel, int level, const char *msg)
{
syslog(convert_level(level), "%s: %s", blog_global.channels[channel].name, msg);
}
static void syslog_free (void)
{
closelog();
}
int BLog_InitSyslog (char *ident, char *facility_str)
{
int facility;
if (!resolve_facility(facility_str, &facility)) {
return 0;
}
snprintf(syslog_global.ident, sizeof(syslog_global.ident), "%s", ident);
openlog(syslog_global.ident, 0, facility);
BLog_Init(syslog_log, syslog_free);
return 1;
}

View File

@@ -0,0 +1,42 @@
/**
* @file BLog_syslog.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* BLog syslog backend.
*/
#ifndef BADVPN_BLOG_SYSLOG_H
#define BADVPN_BLOG_SYSLOG_H
#include "misc/debug.h"
#include "base/BLog.h"
int BLog_InitSyslog (char *ident, char *facility) WARN_UNUSED;
#endif

View File

@@ -0,0 +1,101 @@
/**
* @file BMutex.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BADVPN_BMUTEX_H
#define BADVPN_BMUTEX_H
#if !defined(BADVPN_THREAD_SAFE) || (BADVPN_THREAD_SAFE != 0 && BADVPN_THREAD_SAFE != 1)
#error BADVPN_THREAD_SAFE is not defined or incorrect
#endif
#if BADVPN_THREAD_SAFE
#include <pthread.h>
#endif
#include "misc/debug.h"
#include "base/DebugObject.h"
typedef struct {
#if BADVPN_THREAD_SAFE
pthread_mutex_t pthread_mutex;
#endif
DebugObject d_obj;
} BMutex;
static int BMutex_Init (BMutex *o) WARN_UNUSED;
static void BMutex_Free (BMutex *o);
static void BMutex_Lock (BMutex *o);
static void BMutex_Unlock (BMutex *o);
static int BMutex_Init (BMutex *o)
{
#if BADVPN_THREAD_SAFE
if (pthread_mutex_init(&o->pthread_mutex, NULL) != 0) {
return 0;
}
#endif
DebugObject_Init(&o->d_obj);
return 1;
}
static void BMutex_Free (BMutex *o)
{
DebugObject_Free(&o->d_obj);
#if BADVPN_THREAD_SAFE
int res = pthread_mutex_destroy(&o->pthread_mutex);
B_USE(res)
ASSERT(res == 0)
#endif
}
static void BMutex_Lock (BMutex *o)
{
DebugObject_Access(&o->d_obj);
#if BADVPN_THREAD_SAFE
int res = pthread_mutex_lock(&o->pthread_mutex);
B_USE(res)
ASSERT(res == 0)
#endif
}
static void BMutex_Unlock (BMutex *o)
{
DebugObject_Access(&o->d_obj);
#if BADVPN_THREAD_SAFE
int res = pthread_mutex_unlock(&o->pthread_mutex);
B_USE(res)
ASSERT(res == 0)
#endif
}
#endif

View File

@@ -0,0 +1,205 @@
/**
* @file BPending.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stddef.h>
#include "misc/debug.h"
#include "misc/offset.h"
#include "BPending.h"
#include "BPending_list.h"
#include "structure/SLinkedList_impl.h"
void BPendingGroup_Init (BPendingGroup *g)
{
// init jobs list
BPending__List_Init(&g->jobs);
// init pending counter
DebugCounter_Init(&g->pending_ctr);
// init debug object
DebugObject_Init(&g->d_obj);
}
void BPendingGroup_Free (BPendingGroup *g)
{
DebugCounter_Free(&g->pending_ctr);
ASSERT(BPending__List_IsEmpty(&g->jobs))
DebugObject_Free(&g->d_obj);
}
int BPendingGroup_HasJobs (BPendingGroup *g)
{
DebugObject_Access(&g->d_obj);
return !BPending__List_IsEmpty(&g->jobs);
}
void BPendingGroup_ExecuteJob (BPendingGroup *g)
{
ASSERT(!BPending__List_IsEmpty(&g->jobs))
DebugObject_Access(&g->d_obj);
// get a job
BSmallPending *p = BPending__List_First(&g->jobs);
ASSERT(!BPending__ListIsRemoved(p))
ASSERT(p->pending)
// remove from jobs list
BPending__List_RemoveFirst(&g->jobs);
// set not pending
BPending__ListMarkRemoved(p);
#ifndef NDEBUG
p->pending = 0;
#endif
// execute job
p->handler(p->user);
return;
}
BSmallPending * BPendingGroup_PeekJob (BPendingGroup *g)
{
DebugObject_Access(&g->d_obj);
return BPending__List_First(&g->jobs);
}
void BSmallPending_Init (BSmallPending *o, BPendingGroup *g, BSmallPending_handler handler, void *user)
{
// init arguments
o->handler = handler;
o->user = user;
// set not pending
BPending__ListMarkRemoved(o);
#ifndef NDEBUG
o->pending = 0;
#endif
// increment pending counter
DebugCounter_Increment(&g->pending_ctr);
// init debug object
DebugObject_Init(&o->d_obj);
}
void BSmallPending_Free (BSmallPending *o, BPendingGroup *g)
{
DebugCounter_Decrement(&g->pending_ctr);
DebugObject_Free(&o->d_obj);
ASSERT(o->pending == !BPending__ListIsRemoved(o))
// remove from jobs list
if (!BPending__ListIsRemoved(o)) {
BPending__List_Remove(&g->jobs, o);
}
}
void BSmallPending_SetHandler (BSmallPending *o, BSmallPending_handler handler, void *user)
{
DebugObject_Access(&o->d_obj);
// set handler
o->handler = handler;
o->user = user;
}
void BSmallPending_Set (BSmallPending *o, BPendingGroup *g)
{
DebugObject_Access(&o->d_obj);
ASSERT(o->pending == !BPending__ListIsRemoved(o))
// remove from jobs list
if (!BPending__ListIsRemoved(o)) {
BPending__List_Remove(&g->jobs, o);
}
// insert to jobs list
BPending__List_Prepend(&g->jobs, o);
// set pending
#ifndef NDEBUG
o->pending = 1;
#endif
}
void BSmallPending_Unset (BSmallPending *o, BPendingGroup *g)
{
DebugObject_Access(&o->d_obj);
ASSERT(o->pending == !BPending__ListIsRemoved(o))
if (!BPending__ListIsRemoved(o)) {
// remove from jobs list
BPending__List_Remove(&g->jobs, o);
// set not pending
BPending__ListMarkRemoved(o);
#ifndef NDEBUG
o->pending = 0;
#endif
}
}
int BSmallPending_IsSet (BSmallPending *o)
{
DebugObject_Access(&o->d_obj);
ASSERT(o->pending == !BPending__ListIsRemoved(o))
return !BPending__ListIsRemoved(o);
}
void BPending_Init (BPending *o, BPendingGroup *g, BPending_handler handler, void *user)
{
BSmallPending_Init(&o->base, g, handler, user);
o->g = g;
}
void BPending_Free (BPending *o)
{
BSmallPending_Free(&o->base, o->g);
}
void BPending_Set (BPending *o)
{
BSmallPending_Set(&o->base, o->g);
}
void BPending_Unset (BPending *o)
{
BSmallPending_Unset(&o->base, o->g);
}
int BPending_IsSet (BPending *o)
{
return BSmallPending_IsSet(&o->base);
}

View File

@@ -0,0 +1,250 @@
/**
* @file BPending.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Module for managing a queue of jobs pending execution.
*/
#ifndef BADVPN_BPENDING_H
#define BADVPN_BPENDING_H
#include <stdint.h>
#include "misc/debugcounter.h"
#include "structure/SLinkedList.h"
#include "base/DebugObject.h"
struct BSmallPending_s;
#include "BPending_list.h"
#include "structure/SLinkedList_decl.h"
/**
* Job execution handler.
* It is guaranteed that the associated {@link BSmallPending} object was
* in set state.
* The {@link BSmallPending} object enters not set state before the handler
* is called.
*
* @param user as in {@link BSmallPending_Init}
*/
typedef void (*BSmallPending_handler) (void *user);
/**
* Job execution handler.
* It is guaranteed that the associated {@link BPending} object was
* in set state.
* The {@link BPending} object enters not set state before the handler
* is called.
*
* @param user as in {@link BPending_Init}
*/
typedef void (*BPending_handler) (void *user);
/**
* Object that contains a list of jobs pending execution.
*/
typedef struct {
BPending__List jobs;
DebugCounter pending_ctr;
DebugObject d_obj;
} BPendingGroup;
/**
* Object for queuing a job for execution.
*/
typedef struct BSmallPending_s {
BPending_handler handler;
void *user;
BPending__ListNode pending_node; // optimization: if not pending, .next is this
#ifndef NDEBUG
uint8_t pending;
#endif
DebugObject d_obj;
} BSmallPending;
/**
* Object for queuing a job for execution. This is a convenience wrapper
* around {@link BSmallPending} with an extra field to remember the
* {@link BPendingGroup} being used.
*/
typedef struct {
BSmallPending base;
BPendingGroup *g;
} BPending;
/**
* Initializes the object.
*
* @param g the object
*/
void BPendingGroup_Init (BPendingGroup *g);
/**
* Frees the object.
* There must be no {@link BPending} or {@link BSmallPending} objects using
* this group.
*
* @param g the object
*/
void BPendingGroup_Free (BPendingGroup *g);
/**
* Checks if there is at least one job in the queue.
*
* @param g the object
* @return 1 if there is at least one job, 0 if not
*/
int BPendingGroup_HasJobs (BPendingGroup *g);
/**
* Executes the top job on the job list.
* The job is removed from the list and enters
* not set state before being executed.
* There must be at least one job in job list.
*
* @param g the object
*/
void BPendingGroup_ExecuteJob (BPendingGroup *g);
/**
* Returns the top job on the job list, or NULL if there are none.
*
* @param g the object
* @return the top job if there is at least one job, NULL if not
*/
BSmallPending * BPendingGroup_PeekJob (BPendingGroup *g);
/**
* Initializes the object.
* The object is initialized in not set state.
*
* @param o the object
* @param g pending group to use
* @param handler job execution handler
* @param user value to pass to handler
*/
void BSmallPending_Init (BSmallPending *o, BPendingGroup *g, BSmallPending_handler handler, void *user);
/**
* Frees the object.
* The execution handler will not be called after the object
* is freed.
*
* @param o the object
* @param g pending group. Must be the same as was used in {@link BSmallPending_Init}.
*/
void BSmallPending_Free (BSmallPending *o, BPendingGroup *g);
/**
* Changes the job execution handler.
*
* @param o the object
* @param handler job execution handler
* @param user value to pass to handler
*/
void BSmallPending_SetHandler (BSmallPending *o, BSmallPending_handler handler, void *user);
/**
* Enables the job, pushing it to the top of the job list.
* If the object was already in set state, the job is removed from its
* current position in the list before being pushed.
* The object enters set state.
*
* @param o the object
* @param g pending group. Must be the same as was used in {@link BSmallPending_Init}.
*/
void BSmallPending_Set (BSmallPending *o, BPendingGroup *g);
/**
* Disables the job, removing it from the job list.
* If the object was not in set state, nothing is done.
* The object enters not set state.
*
* @param o the object
* @param g pending group. Must be the same as was used in {@link BSmallPending_Init}.
*/
void BSmallPending_Unset (BSmallPending *o, BPendingGroup *g);
/**
* Checks if the job is in set state.
*
* @param o the object
* @return 1 if in set state, 0 if not
*/
int BSmallPending_IsSet (BSmallPending *o);
/**
* Initializes the object.
* The object is initialized in not set state.
*
* @param o the object
* @param g pending group to use
* @param handler job execution handler
* @param user value to pass to handler
*/
void BPending_Init (BPending *o, BPendingGroup *g, BPending_handler handler, void *user);
/**
* Frees the object.
* The execution handler will not be called after the object
* is freed.
*
* @param o the object
*/
void BPending_Free (BPending *o);
/**
* Enables the job, pushing it to the top of the job list.
* If the object was already in set state, the job is removed from its
* current position in the list before being pushed.
* The object enters set state.
*
* @param o the object
*/
void BPending_Set (BPending *o);
/**
* Disables the job, removing it from the job list.
* If the object was not in set state, nothing is done.
* The object enters not set state.
*
* @param o the object
*/
void BPending_Unset (BPending *o);
/**
* Checks if the job is in set state.
*
* @param o the object
* @return 1 if in set state, 0 if not
*/
int BPending_IsSet (BPending *o);
#endif

View File

@@ -0,0 +1,4 @@
#define SLINKEDLIST_PARAM_NAME BPending__List
#define SLINKEDLIST_PARAM_FEATURE_LAST 0
#define SLINKEDLIST_PARAM_TYPE_ENTRY struct BSmallPending_s
#define SLINKEDLIST_PARAM_MEMBER_NODE pending_node

View File

@@ -0,0 +1,39 @@
/**
* @file DebugObject.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "DebugObject.h"
#ifndef BADVPN_PLUGIN
#ifndef NDEBUG
DebugCounter debugobject_counter = DEBUGCOUNTER_STATIC;
#if BADVPN_THREAD_SAFE
pthread_mutex_t debugobject_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
#endif
#endif

View File

@@ -0,0 +1,147 @@
/**
* @file DebugObject.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Object used for detecting leaks.
*/
#ifndef BADVPN_DEBUGOBJECT_H
#define BADVPN_DEBUGOBJECT_H
#include <stdint.h>
#if !defined(BADVPN_THREAD_SAFE) || (BADVPN_THREAD_SAFE != 0 && BADVPN_THREAD_SAFE != 1)
#error BADVPN_THREAD_SAFE is not defined or incorrect
#endif
#if BADVPN_THREAD_SAFE
#include <pthread.h>
#endif
#include "misc/debug.h"
#include "misc/debugcounter.h"
#define DEBUGOBJECT_VALID UINT32_C(0x31415926)
/**
* Object used for detecting leaks.
*/
typedef struct {
#ifndef NDEBUG
uint32_t c;
#endif
} DebugObject;
/**
* Initializes the object.
*
* @param obj the object
*/
static void DebugObject_Init (DebugObject *obj);
/**
* Frees the object.
*
* @param obj the object
*/
static void DebugObject_Free (DebugObject *obj);
/**
* Does nothing.
*
* @param obj the object
*/
static void DebugObject_Access (const DebugObject *obj);
/**
* Does nothing.
* There must be no {@link DebugObject}'s initialized.
*/
static void DebugObjectGlobal_Finish (void);
#ifndef NDEBUG
extern DebugCounter debugobject_counter;
#if BADVPN_THREAD_SAFE
extern pthread_mutex_t debugobject_mutex;
#endif
#endif
void DebugObject_Init (DebugObject *obj)
{
#ifndef NDEBUG
obj->c = DEBUGOBJECT_VALID;
#if BADVPN_THREAD_SAFE
ASSERT_FORCE(pthread_mutex_lock(&debugobject_mutex) == 0)
#endif
DebugCounter_Increment(&debugobject_counter);
#if BADVPN_THREAD_SAFE
ASSERT_FORCE(pthread_mutex_unlock(&debugobject_mutex) == 0)
#endif
#endif
}
void DebugObject_Free (DebugObject *obj)
{
ASSERT(obj->c == DEBUGOBJECT_VALID)
#ifndef NDEBUG
obj->c = 0;
#if BADVPN_THREAD_SAFE
ASSERT_FORCE(pthread_mutex_lock(&debugobject_mutex) == 0)
#endif
DebugCounter_Decrement(&debugobject_counter);
#if BADVPN_THREAD_SAFE
ASSERT_FORCE(pthread_mutex_unlock(&debugobject_mutex) == 0)
#endif
#endif
}
void DebugObject_Access (const DebugObject *obj)
{
ASSERT(obj->c == DEBUGOBJECT_VALID)
}
void DebugObjectGlobal_Finish (void)
{
#ifndef NDEBUG
DebugCounter_Free(&debugobject_counter);
#endif
}
#endif

View File

@@ -0,0 +1,112 @@
/**
* @file BufferWriter.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "misc/debug.h"
#include "flow/BufferWriter.h"
static void output_handler_recv (BufferWriter *o, uint8_t *data)
{
ASSERT(!o->out_have)
// set output packet
o->out_have = 1;
o->out = data;
}
void BufferWriter_Init (BufferWriter *o, int mtu, BPendingGroup *pg)
{
ASSERT(mtu >= 0)
// init output
PacketRecvInterface_Init(&o->recv_interface, mtu, (PacketRecvInterface_handler_recv)output_handler_recv, o, pg);
// set no output packet
o->out_have = 0;
DebugObject_Init(&o->d_obj);
#ifndef NDEBUG
o->d_mtu = mtu;
o->d_writing = 0;
#endif
}
void BufferWriter_Free (BufferWriter *o)
{
DebugObject_Free(&o->d_obj);
// free output
PacketRecvInterface_Free(&o->recv_interface);
}
PacketRecvInterface * BufferWriter_GetOutput (BufferWriter *o)
{
DebugObject_Access(&o->d_obj);
return &o->recv_interface;
}
int BufferWriter_StartPacket (BufferWriter *o, uint8_t **buf)
{
ASSERT(!o->d_writing)
DebugObject_Access(&o->d_obj);
if (!o->out_have) {
return 0;
}
if (buf) {
*buf = o->out;
}
#ifndef NDEBUG
o->d_writing = 1;
#endif
return 1;
}
void BufferWriter_EndPacket (BufferWriter *o, int len)
{
ASSERT(len >= 0)
ASSERT(len <= o->d_mtu)
ASSERT(o->out_have)
ASSERT(o->d_writing)
DebugObject_Access(&o->d_obj);
// set no output packet
o->out_have = 0;
// finish packet
PacketRecvInterface_Done(&o->recv_interface, len);
#ifndef NDEBUG
o->d_writing = 0;
#endif
}

View File

@@ -0,0 +1,107 @@
/**
* @file BufferWriter.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Object for writing packets to a {@link PacketRecvInterface} client
* in a best-effort fashion.
*/
#ifndef BADVPN_FLOW_BUFFERWRITER_H
#define BADVPN_FLOW_BUFFERWRITER_H
#include <stdint.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "flow/PacketRecvInterface.h"
/**
* Object for writing packets to a {@link PacketRecvInterface} client
* in a best-effort fashion.
*/
typedef struct {
PacketRecvInterface recv_interface;
int out_have;
uint8_t *out;
DebugObject d_obj;
#ifndef NDEBUG
int d_mtu;
int d_writing;
#endif
} BufferWriter;
/**
* Initializes the object.
* The object is initialized in not writing state.
*
* @param o the object
* @param mtu maximum input packet length
* @param pg pending group
*/
void BufferWriter_Init (BufferWriter *o, int mtu, BPendingGroup *pg);
/**
* Frees the object.
*
* @param o the object
*/
void BufferWriter_Free (BufferWriter *o);
/**
* Returns the output interface.
*
* @param o the object
* @return output interface
*/
PacketRecvInterface * BufferWriter_GetOutput (BufferWriter *o);
/**
* Attempts to provide a memory location for writing a packet.
* The object must be in not writing state.
* On success, the object enters writing state.
*
* @param o the object
* @param buf if not NULL, on success, the memory location will be stored here.
* It will have space for MTU bytes.
* @return 1 on success, 0 on failure
*/
int BufferWriter_StartPacket (BufferWriter *o, uint8_t **buf) WARN_UNUSED;
/**
* Submits a packet written to the buffer.
* The object must be in writing state.
* Yhe object enters not writing state.
*
* @param o the object
* @param len length of the packet that was written. Must be >=0 and
* <=MTU.
*/
void BufferWriter_EndPacket (BufferWriter *o, int len);
#endif

View File

@@ -0,0 +1,131 @@
/**
* @file PacketBuffer.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "misc/debug.h"
#include "misc/balloc.h"
#include "flow/PacketBuffer.h"
static void input_handler_done (PacketBuffer *buf, int in_len);
static void output_handler_done (PacketBuffer *buf);
void input_handler_done (PacketBuffer *buf, int in_len)
{
ASSERT(in_len >= 0)
ASSERT(in_len <= buf->input_mtu)
DebugObject_Access(&buf->d_obj);
// remember if buffer is empty
int was_empty = (buf->buf.output_avail < 0);
// submit packet to buffer
ChunkBuffer2_SubmitPacket(&buf->buf, in_len);
// if there is space, schedule receive
if (buf->buf.input_avail >= buf->input_mtu) {
PacketRecvInterface_Receiver_Recv(buf->input, buf->buf.input_dest);
}
// if buffer was empty, schedule send
if (was_empty) {
PacketPassInterface_Sender_Send(buf->output, buf->buf.output_dest, buf->buf.output_avail);
}
}
void output_handler_done (PacketBuffer *buf)
{
DebugObject_Access(&buf->d_obj);
// remember if buffer is full
int was_full = (buf->buf.input_avail < buf->input_mtu);
// remove packet from buffer
ChunkBuffer2_ConsumePacket(&buf->buf);
// if buffer was full and there is space, schedule receive
if (was_full && buf->buf.input_avail >= buf->input_mtu) {
PacketRecvInterface_Receiver_Recv(buf->input, buf->buf.input_dest);
}
// if there is more data, schedule send
if (buf->buf.output_avail >= 0) {
PacketPassInterface_Sender_Send(buf->output, buf->buf.output_dest, buf->buf.output_avail);
}
}
int PacketBuffer_Init (PacketBuffer *buf, PacketRecvInterface *input, PacketPassInterface *output, int num_packets, BPendingGroup *pg)
{
ASSERT(PacketPassInterface_GetMTU(output) >= PacketRecvInterface_GetMTU(input))
ASSERT(num_packets > 0)
// init arguments
buf->input = input;
buf->output = output;
// init input
PacketRecvInterface_Receiver_Init(buf->input, (PacketRecvInterface_handler_done)input_handler_done, buf);
// set input MTU
buf->input_mtu = PacketRecvInterface_GetMTU(buf->input);
// init output
PacketPassInterface_Sender_Init(buf->output, (PacketPassInterface_handler_done)output_handler_done, buf);
// allocate buffer
int num_blocks = ChunkBuffer2_calc_blocks(buf->input_mtu, num_packets);
if (num_blocks < 0) {
goto fail0;
}
if (!(buf->buf_data = (struct ChunkBuffer2_block *)BAllocArray(num_blocks, sizeof(buf->buf_data[0])))) {
goto fail0;
}
// init buffer
ChunkBuffer2_Init(&buf->buf, buf->buf_data, num_blocks, buf->input_mtu);
// schedule receive
PacketRecvInterface_Receiver_Recv(buf->input, buf->buf.input_dest);
DebugObject_Init(&buf->d_obj);
return 1;
fail0:
return 0;
}
void PacketBuffer_Free (PacketBuffer *buf)
{
DebugObject_Free(&buf->d_obj);
// free buffer
BFree(buf->buf_data);
}

View File

@@ -0,0 +1,77 @@
/**
* @file PacketBuffer.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output.
*/
#ifndef BADVPN_FLOW_PACKETBUFFER_H
#define BADVPN_FLOW_PACKETBUFFER_H
#include <stdint.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "structure/ChunkBuffer2.h"
#include "flow/PacketRecvInterface.h"
#include "flow/PacketPassInterface.h"
/**
* Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output.
*/
typedef struct {
DebugObject d_obj;
PacketRecvInterface *input;
int input_mtu;
PacketPassInterface *output;
struct ChunkBuffer2_block *buf_data;
ChunkBuffer2 buf;
} PacketBuffer;
/**
* Initializes the buffer.
* Output MTU must be >= input MTU.
*
* @param buf the object
* @param input input interface
* @param output output interface
* @param num_packets minimum number of packets the buffer must hold. Must be >0.
* @param pg pending group
* @return 1 on success, 0 on failure
*/
int PacketBuffer_Init (PacketBuffer *buf, PacketRecvInterface *input, PacketPassInterface *output, int num_packets, BPendingGroup *pg) WARN_UNUSED;
/**
* Frees the buffer.
*
* @param buf the object
*/
void PacketBuffer_Free (PacketBuffer *buf);
#endif

View File

@@ -0,0 +1,125 @@
/**
* @file PacketPassConnector.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stddef.h>
#include "misc/debug.h"
#include "flow/PacketPassConnector.h"
static void input_handler_send (PacketPassConnector *o, uint8_t *data, int data_len)
{
ASSERT(data_len >= 0)
ASSERT(data_len <= o->input_mtu)
ASSERT(o->in_len == -1)
DebugObject_Access(&o->d_obj);
// remember input packet
o->in_len = data_len;
o->in = data;
if (o->output) {
// schedule send
PacketPassInterface_Sender_Send(o->output, o->in, o->in_len);
}
}
static void output_handler_done (PacketPassConnector *o)
{
ASSERT(o->in_len >= 0)
ASSERT(o->output)
DebugObject_Access(&o->d_obj);
// have no input packet
o->in_len = -1;
// allow input to send more packets
PacketPassInterface_Done(&o->input);
}
void PacketPassConnector_Init (PacketPassConnector *o, int mtu, BPendingGroup *pg)
{
ASSERT(mtu >= 0)
// init arguments
o->input_mtu = mtu;
// init input
PacketPassInterface_Init(&o->input, o->input_mtu, (PacketPassInterface_handler_send)input_handler_send, o, pg);
// have no input packet
o->in_len = -1;
// have no output
o->output = NULL;
DebugObject_Init(&o->d_obj);
}
void PacketPassConnector_Free (PacketPassConnector *o)
{
DebugObject_Free(&o->d_obj);
// free input
PacketPassInterface_Free(&o->input);
}
PacketPassInterface * PacketPassConnector_GetInput (PacketPassConnector *o)
{
DebugObject_Access(&o->d_obj);
return &o->input;
}
void PacketPassConnector_ConnectOutput (PacketPassConnector *o, PacketPassInterface *output)
{
ASSERT(!o->output)
ASSERT(PacketPassInterface_GetMTU(output) >= o->input_mtu)
DebugObject_Access(&o->d_obj);
// set output
o->output = output;
// init output
PacketPassInterface_Sender_Init(o->output, (PacketPassInterface_handler_done)output_handler_done, o);
// if we have an input packet, schedule send
if (o->in_len >= 0) {
PacketPassInterface_Sender_Send(o->output, o->in, o->in_len);
}
}
void PacketPassConnector_DisconnectOutput (PacketPassConnector *o)
{
ASSERT(o->output)
DebugObject_Access(&o->d_obj);
// set no output
o->output = NULL;
}

View File

@@ -0,0 +1,102 @@
/**
* @file PacketPassConnector.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* A {@link PacketPassInterface} layer which allows the output to be
* connected and disconnected on the fly.
*/
#ifndef BADVPN_FLOW_PACKETPASSCONNECTOR_H
#define BADVPN_FLOW_PACKETPASSCONNECTOR_H
#include <stdint.h>
#include "base/DebugObject.h"
#include "flow/PacketPassInterface.h"
/**
* A {@link PacketPassInterface} layer which allows the output to be
* connected and disconnected on the fly.
*/
typedef struct {
PacketPassInterface input;
int input_mtu;
int in_len;
uint8_t *in;
PacketPassInterface *output;
DebugObject d_obj;
} PacketPassConnector;
/**
* Initializes the object.
* The object is initialized in not connected state.
*
* @param o the object
* @param mtu maximum input packet size. Must be >=0.
* @param pg pending group
*/
void PacketPassConnector_Init (PacketPassConnector *o, int mtu, BPendingGroup *pg);
/**
* Frees the object.
*
* @param o the object
*/
void PacketPassConnector_Free (PacketPassConnector *o);
/**
* Returns the input interface.
* The MTU of the interface will be as in {@link PacketPassConnector_Init}.
*
* @param o the object
* @return input interface
*/
PacketPassInterface * PacketPassConnector_GetInput (PacketPassConnector *o);
/**
* Connects output.
* The object must be in not connected state.
* The object enters connected state.
*
* @param o the object
* @param output output to connect. Its MTU must be >= MTU specified in
* {@link PacketPassConnector_Init}.
*/
void PacketPassConnector_ConnectOutput (PacketPassConnector *o, PacketPassInterface *output);
/**
* Disconnects output.
* The object must be in connected state.
* The object enters not connected state.
*
* @param o the object
*/
void PacketPassConnector_DisconnectOutput (PacketPassConnector *o);
#endif

View File

@@ -0,0 +1,405 @@
/**
* @file PacketPassFairQueue.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "misc/debug.h"
#include "misc/offset.h"
#include "misc/minmax.h"
#include "misc/compare.h"
#include "flow/PacketPassFairQueue.h"
static int compare_flows (PacketPassFairQueueFlow *f1, PacketPassFairQueueFlow *f2)
{
int cmp = B_COMPARE(f1->time, f2->time);
if (cmp) {
return cmp;
}
return B_COMPARE((uintptr_t)f1, (uintptr_t)f2);
}
#include "PacketPassFairQueue_tree.h"
#include "structure/SAvl_impl.h"
static uint64_t get_current_time (PacketPassFairQueue *m)
{
if (m->sending_flow) {
return m->sending_flow->time;
}
uint64_t time = 0; // to remove warning
int have = 0;
PacketPassFairQueueFlow *first_flow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0);
if (first_flow) {
ASSERT(first_flow->is_queued)
time = first_flow->time;
have = 1;
}
if (m->previous_flow) {
if (!have || m->previous_flow->time < time) {
time = m->previous_flow->time;
have = 1;
}
}
return (have ? time : 0);
}
static void increment_sent_flow (PacketPassFairQueueFlow *flow, uint64_t amount)
{
PacketPassFairQueue *m = flow->m;
ASSERT(amount <= FAIRQUEUE_MAX_TIME)
ASSERT(!flow->is_queued)
ASSERT(!m->sending_flow)
// does time overflow?
if (amount > FAIRQUEUE_MAX_TIME - flow->time) {
// get time to subtract
uint64_t subtract;
PacketPassFairQueueFlow *first_flow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0);
if (!first_flow) {
subtract = flow->time;
} else {
ASSERT(first_flow->is_queued)
subtract = first_flow->time;
}
// subtract time from all flows
for (LinkedList1Node *list_node = LinkedList1_GetFirst(&m->flows_list); list_node; list_node = LinkedList1Node_Next(list_node)) {
PacketPassFairQueueFlow *someflow = UPPER_OBJECT(list_node, PacketPassFairQueueFlow, list_node);
// don't subtract more time than there is, except for the just finished flow,
// where we allow time to underflow and then overflow to the correct value after adding to it
if (subtract > someflow->time && someflow != flow) {
ASSERT(!someflow->is_queued)
someflow->time = 0;
} else {
someflow->time -= subtract;
}
}
}
// add time to flow
flow->time += amount;
}
static void schedule (PacketPassFairQueue *m)
{
ASSERT(!m->sending_flow)
ASSERT(!m->previous_flow)
ASSERT(!m->freeing)
ASSERT(!PacketPassFairQueue__Tree_IsEmpty(&m->queued_tree))
// get first queued flow
PacketPassFairQueueFlow *qflow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0);
ASSERT(qflow->is_queued)
// remove flow from queue
PacketPassFairQueue__Tree_Remove(&m->queued_tree, 0, qflow);
qflow->is_queued = 0;
// schedule send
PacketPassInterface_Sender_Send(m->output, qflow->queued.data, qflow->queued.data_len);
m->sending_flow = qflow;
m->sending_len = qflow->queued.data_len;
}
static void schedule_job_handler (PacketPassFairQueue *m)
{
ASSERT(!m->sending_flow)
ASSERT(!m->freeing)
DebugObject_Access(&m->d_obj);
// remove previous flow
m->previous_flow = NULL;
if (!PacketPassFairQueue__Tree_IsEmpty(&m->queued_tree)) {
schedule(m);
}
}
static void input_handler_send (PacketPassFairQueueFlow *flow, uint8_t *data, int data_len)
{
PacketPassFairQueue *m = flow->m;
ASSERT(flow != m->sending_flow)
ASSERT(!flow->is_queued)
ASSERT(!m->freeing)
DebugObject_Access(&flow->d_obj);
if (flow == m->previous_flow) {
// remove from previous flow
m->previous_flow = NULL;
} else {
// raise time
flow->time = bmax_uint64(flow->time, get_current_time(m));
}
// queue flow
flow->queued.data = data;
flow->queued.data_len = data_len;
int res = PacketPassFairQueue__Tree_Insert(&m->queued_tree, 0, flow, NULL);
ASSERT_EXECUTE(res)
flow->is_queued = 1;
if (!m->sending_flow && !BPending_IsSet(&m->schedule_job)) {
schedule(m);
}
}
static void output_handler_done (PacketPassFairQueue *m)
{
ASSERT(m->sending_flow)
ASSERT(!m->previous_flow)
ASSERT(!BPending_IsSet(&m->schedule_job))
ASSERT(!m->freeing)
ASSERT(!m->sending_flow->is_queued)
PacketPassFairQueueFlow *flow = m->sending_flow;
// sending finished
m->sending_flow = NULL;
// remember this flow so the schedule job can remove its time if it didn's send
m->previous_flow = flow;
// update flow time by packet size
increment_sent_flow(flow, (uint64_t)m->packet_weight + m->sending_len);
// schedule schedule
BPending_Set(&m->schedule_job);
// finish flow packet
PacketPassInterface_Done(&flow->input);
// call busy handler if set
if (flow->handler_busy) {
// handler is one-shot, unset it before calling
PacketPassFairQueue_handler_busy handler = flow->handler_busy;
flow->handler_busy = NULL;
// call handler
handler(flow->user);
return;
}
}
int PacketPassFairQueue_Init (PacketPassFairQueue *m, PacketPassInterface *output, BPendingGroup *pg, int use_cancel, int packet_weight)
{
ASSERT(packet_weight > 0)
ASSERT(use_cancel == 0 || use_cancel == 1)
ASSERT(!use_cancel || PacketPassInterface_HasCancel(output))
// init arguments
m->output = output;
m->pg = pg;
m->use_cancel = use_cancel;
m->packet_weight = packet_weight;
// make sure that (output MTU + packet_weight <= FAIRQUEUE_MAX_TIME)
if (!(
(PacketPassInterface_GetMTU(output) <= FAIRQUEUE_MAX_TIME) &&
(packet_weight <= FAIRQUEUE_MAX_TIME - PacketPassInterface_GetMTU(output))
)) {
goto fail0;
}
// init output
PacketPassInterface_Sender_Init(m->output, (PacketPassInterface_handler_done)output_handler_done, m);
// not sending
m->sending_flow = NULL;
// no previous flow
m->previous_flow = NULL;
// init queued tree
PacketPassFairQueue__Tree_Init(&m->queued_tree);
// init flows list
LinkedList1_Init(&m->flows_list);
// not freeing
m->freeing = 0;
// init schedule job
BPending_Init(&m->schedule_job, m->pg, (BPending_handler)schedule_job_handler, m);
DebugObject_Init(&m->d_obj);
DebugCounter_Init(&m->d_ctr);
return 1;
fail0:
return 0;
}
void PacketPassFairQueue_Free (PacketPassFairQueue *m)
{
ASSERT(LinkedList1_IsEmpty(&m->flows_list))
ASSERT(PacketPassFairQueue__Tree_IsEmpty(&m->queued_tree))
ASSERT(!m->previous_flow)
ASSERT(!m->sending_flow)
DebugCounter_Free(&m->d_ctr);
DebugObject_Free(&m->d_obj);
// free schedule job
BPending_Free(&m->schedule_job);
}
void PacketPassFairQueue_PrepareFree (PacketPassFairQueue *m)
{
DebugObject_Access(&m->d_obj);
// set freeing
m->freeing = 1;
}
int PacketPassFairQueue_GetMTU (PacketPassFairQueue *m)
{
DebugObject_Access(&m->d_obj);
return PacketPassInterface_GetMTU(m->output);
}
void PacketPassFairQueueFlow_Init (PacketPassFairQueueFlow *flow, PacketPassFairQueue *m)
{
ASSERT(!m->freeing)
DebugObject_Access(&m->d_obj);
// init arguments
flow->m = m;
// have no canfree handler
flow->handler_busy = NULL;
// init input
PacketPassInterface_Init(&flow->input, PacketPassInterface_GetMTU(flow->m->output), (PacketPassInterface_handler_send)input_handler_send, flow, m->pg);
// set time
flow->time = 0;
// add to flows list
LinkedList1_Append(&m->flows_list, &flow->list_node);
// is not queued
flow->is_queued = 0;
DebugObject_Init(&flow->d_obj);
DebugCounter_Increment(&m->d_ctr);
}
void PacketPassFairQueueFlow_Free (PacketPassFairQueueFlow *flow)
{
PacketPassFairQueue *m = flow->m;
ASSERT(m->freeing || flow != m->sending_flow)
DebugCounter_Decrement(&m->d_ctr);
DebugObject_Free(&flow->d_obj);
// remove from current flow
if (flow == m->sending_flow) {
m->sending_flow = NULL;
}
// remove from previous flow
if (flow == m->previous_flow) {
m->previous_flow = NULL;
}
// remove from queue
if (flow->is_queued) {
PacketPassFairQueue__Tree_Remove(&m->queued_tree, 0, flow);
}
// remove from flows list
LinkedList1_Remove(&m->flows_list, &flow->list_node);
// free input
PacketPassInterface_Free(&flow->input);
}
void PacketPassFairQueueFlow_AssertFree (PacketPassFairQueueFlow *flow)
{
PacketPassFairQueue *m = flow->m;
B_USE(m)
ASSERT(m->freeing || flow != m->sending_flow)
DebugObject_Access(&flow->d_obj);
}
int PacketPassFairQueueFlow_IsBusy (PacketPassFairQueueFlow *flow)
{
PacketPassFairQueue *m = flow->m;
ASSERT(!m->freeing)
DebugObject_Access(&flow->d_obj);
return (flow == m->sending_flow);
}
void PacketPassFairQueueFlow_RequestCancel (PacketPassFairQueueFlow *flow)
{
PacketPassFairQueue *m = flow->m;
ASSERT(flow == m->sending_flow)
ASSERT(m->use_cancel)
ASSERT(!m->freeing)
ASSERT(!BPending_IsSet(&m->schedule_job))
DebugObject_Access(&flow->d_obj);
// request cancel
PacketPassInterface_Sender_RequestCancel(m->output);
}
void PacketPassFairQueueFlow_SetBusyHandler (PacketPassFairQueueFlow *flow, PacketPassFairQueue_handler_busy handler, void *user)
{
PacketPassFairQueue *m = flow->m;
B_USE(m)
ASSERT(flow == m->sending_flow)
ASSERT(!m->freeing)
DebugObject_Access(&flow->d_obj);
// set handler
flow->handler_busy = handler;
flow->user = user;
}
PacketPassInterface * PacketPassFairQueueFlow_GetInput (PacketPassFairQueueFlow *flow)
{
DebugObject_Access(&flow->d_obj);
return &flow->input;
}

View File

@@ -0,0 +1,204 @@
/**
* @file PacketPassFairQueue.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Fair queue using {@link PacketPassInterface}.
*/
#ifndef BADVPN_FLOW_PACKETPASSFAIRQUEUE_H
#define BADVPN_FLOW_PACKETPASSFAIRQUEUE_H
#include <stdint.h>
#include "misc/debug.h"
#include "misc/debugcounter.h"
#include "structure/SAvl.h"
#include "structure/LinkedList1.h"
#include "base/DebugObject.h"
#include "base/BPending.h"
#include "flow/PacketPassInterface.h"
// reduce this to test time overflow handling
#define FAIRQUEUE_MAX_TIME UINT64_MAX
typedef void (*PacketPassFairQueue_handler_busy) (void *user);
struct PacketPassFairQueueFlow_s;
#include "PacketPassFairQueue_tree.h"
#include "structure/SAvl_decl.h"
typedef struct PacketPassFairQueueFlow_s {
struct PacketPassFairQueue_s *m;
PacketPassFairQueue_handler_busy handler_busy;
void *user;
PacketPassInterface input;
uint64_t time;
LinkedList1Node list_node;
int is_queued;
struct {
PacketPassFairQueue__TreeNode tree_node;
uint8_t *data;
int data_len;
} queued;
DebugObject d_obj;
} PacketPassFairQueueFlow;
/**
* Fair queue using {@link PacketPassInterface}.
*/
typedef struct PacketPassFairQueue_s {
PacketPassInterface *output;
BPendingGroup *pg;
int use_cancel;
int packet_weight;
struct PacketPassFairQueueFlow_s *sending_flow;
int sending_len;
struct PacketPassFairQueueFlow_s *previous_flow;
PacketPassFairQueue__Tree queued_tree;
LinkedList1 flows_list;
int freeing;
BPending schedule_job;
DebugObject d_obj;
DebugCounter d_ctr;
} PacketPassFairQueue;
/**
* Initializes the queue.
*
* @param m the object
* @param output output interface
* @param pg pending group
* @param use_cancel whether cancel functionality is required. Must be 0 or 1.
* If 1, output must support cancel functionality.
* @param packet_weight additional weight a packet bears. Must be >0, to keep
* the queue fair for zero size packets.
* @return 1 on success, 0 on failure (because output MTU is too large)
*/
int PacketPassFairQueue_Init (PacketPassFairQueue *m, PacketPassInterface *output, BPendingGroup *pg, int use_cancel, int packet_weight) WARN_UNUSED;
/**
* Frees the queue.
* All flows must have been freed.
*
* @param m the object
*/
void PacketPassFairQueue_Free (PacketPassFairQueue *m);
/**
* Prepares for freeing the entire queue. Must be called to allow freeing
* the flows in the process of freeing the entire queue.
* After this function is called, flows and the queue must be freed
* before any further I/O.
* May be called multiple times.
* The queue enters freeing state.
*
* @param m the object
*/
void PacketPassFairQueue_PrepareFree (PacketPassFairQueue *m);
/**
* Returns the MTU of the queue.
*
* @param m the object
*/
int PacketPassFairQueue_GetMTU (PacketPassFairQueue *m);
/**
* Initializes a queue flow.
* Queue must not be in freeing state.
* Must not be called from queue calls to output.
*
* @param flow the object
* @param m queue to attach to
*/
void PacketPassFairQueueFlow_Init (PacketPassFairQueueFlow *flow, PacketPassFairQueue *m);
/**
* Frees a queue flow.
* Unless the queue is in freeing state:
* - The flow must not be busy as indicated by {@link PacketPassFairQueueFlow_IsBusy}.
* - Must not be called from queue calls to output.
*
* @param flow the object
*/
void PacketPassFairQueueFlow_Free (PacketPassFairQueueFlow *flow);
/**
* Does nothing.
* It must be possible to free the flow (see {@link PacketPassFairQueueFlow_Free}).
*
* @param flow the object
*/
void PacketPassFairQueueFlow_AssertFree (PacketPassFairQueueFlow *flow);
/**
* Determines if the flow is busy. If the flow is considered busy, it must not
* be freed. At any given time, at most one flow will be indicated as busy.
* Queue must not be in freeing state.
* Must not be called from queue calls to output.
*
* @param flow the object
* @return 0 if not busy, 1 is busy
*/
int PacketPassFairQueueFlow_IsBusy (PacketPassFairQueueFlow *flow);
/**
* Requests the output to stop processing the current packet as soon as possible.
* Cancel functionality must be enabled for the queue.
* The flow must be busy as indicated by {@link PacketPassFairQueueFlow_IsBusy}.
* Queue must not be in freeing state.
*
* @param flow the object
*/
void PacketPassFairQueueFlow_RequestCancel (PacketPassFairQueueFlow *flow);
/**
* Sets up a callback to be called when the flow is no longer busy.
* The handler will be called as soon as the flow is no longer busy, i.e. it is not
* possible that this flow is no longer busy before the handler is called.
* The flow must be busy as indicated by {@link PacketPassFairQueueFlow_IsBusy}.
* Queue must not be in freeing state.
* Must not be called from queue calls to output.
*
* @param flow the object
* @param handler callback function. NULL to disable.
* @param user value passed to callback function. Ignored if handler is NULL.
*/
void PacketPassFairQueueFlow_SetBusyHandler (PacketPassFairQueueFlow *flow, PacketPassFairQueue_handler_busy handler, void *user);
/**
* Returns the input interface of the flow.
*
* @param flow the object
* @return input interface
*/
PacketPassInterface * PacketPassFairQueueFlow_GetInput (PacketPassFairQueueFlow *flow);
#endif

View File

@@ -0,0 +1,7 @@
#define SAVL_PARAM_NAME PacketPassFairQueue__Tree
#define SAVL_PARAM_FEATURE_COUNTS 0
#define SAVL_PARAM_FEATURE_NOKEYS 1
#define SAVL_PARAM_TYPE_ENTRY struct PacketPassFairQueueFlow_s
#define SAVL_PARAM_TYPE_ARG int
#define SAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) compare_flows((entry1), (entry2))
#define SAVL_PARAM_MEMBER_NODE queued.tree_node

View File

@@ -0,0 +1,68 @@
/**
* @file PacketPassInterface.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "flow/PacketPassInterface.h"
void _PacketPassInterface_job_operation (PacketPassInterface *i)
{
ASSERT(i->state == PPI_STATE_OPERATION_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = PPI_STATE_BUSY;
// call handler
i->handler_operation(i->user_provider, i->job_operation_data, i->job_operation_len);
return;
}
void _PacketPassInterface_job_requestcancel (PacketPassInterface *i)
{
ASSERT(i->state == PPI_STATE_BUSY)
ASSERT(i->cancel_requested)
ASSERT(i->handler_requestcancel)
DebugObject_Access(&i->d_obj);
// call handler
i->handler_requestcancel(i->user_provider);
return;
}
void _PacketPassInterface_job_done (PacketPassInterface *i)
{
ASSERT(i->state == PPI_STATE_DONE_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = PPI_STATE_NONE;
// call handler
i->handler_done(i->user_user);
return;
}

View File

@@ -0,0 +1,236 @@
/**
* @file PacketPassInterface.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Interface allowing a packet sender to pass data packets to a packet receiver.
*/
#ifndef BADVPN_FLOW_PACKETPASSINTERFACE_H
#define BADVPN_FLOW_PACKETPASSINTERFACE_H
#include <stdint.h>
#include <stddef.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "base/BPending.h"
#define PPI_STATE_NONE 1
#define PPI_STATE_OPERATION_PENDING 2
#define PPI_STATE_BUSY 3
#define PPI_STATE_DONE_PENDING 4
typedef void (*PacketPassInterface_handler_send) (void *user, uint8_t *data, int data_len);
typedef void (*PacketPassInterface_handler_requestcancel) (void *user);
typedef void (*PacketPassInterface_handler_done) (void *user);
typedef struct {
// provider data
int mtu;
PacketPassInterface_handler_send handler_operation;
PacketPassInterface_handler_requestcancel handler_requestcancel;
void *user_provider;
// user data
PacketPassInterface_handler_done handler_done;
void *user_user;
// operation job
BPending job_operation;
uint8_t *job_operation_data;
int job_operation_len;
// requestcancel job
BPending job_requestcancel;
// done job
BPending job_done;
// state
int state;
int cancel_requested;
DebugObject d_obj;
} PacketPassInterface;
static void PacketPassInterface_Init (PacketPassInterface *i, int mtu, PacketPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg);
static void PacketPassInterface_Free (PacketPassInterface *i);
static void PacketPassInterface_EnableCancel (PacketPassInterface *i, PacketPassInterface_handler_requestcancel handler_requestcancel);
static void PacketPassInterface_Done (PacketPassInterface *i);
static int PacketPassInterface_GetMTU (PacketPassInterface *i);
static void PacketPassInterface_Sender_Init (PacketPassInterface *i, PacketPassInterface_handler_done handler_done, void *user);
static void PacketPassInterface_Sender_Send (PacketPassInterface *i, uint8_t *data, int data_len);
static void PacketPassInterface_Sender_RequestCancel (PacketPassInterface *i);
static int PacketPassInterface_HasCancel (PacketPassInterface *i);
void _PacketPassInterface_job_operation (PacketPassInterface *i);
void _PacketPassInterface_job_requestcancel (PacketPassInterface *i);
void _PacketPassInterface_job_done (PacketPassInterface *i);
void PacketPassInterface_Init (PacketPassInterface *i, int mtu, PacketPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg)
{
ASSERT(mtu >= 0)
// init arguments
i->mtu = mtu;
i->handler_operation = handler_operation;
i->handler_requestcancel = NULL;
i->user_provider = user;
// set no user
i->handler_done = NULL;
// init jobs
BPending_Init(&i->job_operation, pg, (BPending_handler)_PacketPassInterface_job_operation, i);
BPending_Init(&i->job_requestcancel, pg, (BPending_handler)_PacketPassInterface_job_requestcancel, i);
BPending_Init(&i->job_done, pg, (BPending_handler)_PacketPassInterface_job_done, i);
// set state
i->state = PPI_STATE_NONE;
DebugObject_Init(&i->d_obj);
}
void PacketPassInterface_Free (PacketPassInterface *i)
{
DebugObject_Free(&i->d_obj);
// free jobs
BPending_Free(&i->job_done);
BPending_Free(&i->job_requestcancel);
BPending_Free(&i->job_operation);
}
void PacketPassInterface_EnableCancel (PacketPassInterface *i, PacketPassInterface_handler_requestcancel handler_requestcancel)
{
ASSERT(!i->handler_requestcancel)
ASSERT(!i->handler_done)
ASSERT(handler_requestcancel)
i->handler_requestcancel = handler_requestcancel;
}
void PacketPassInterface_Done (PacketPassInterface *i)
{
ASSERT(i->state == PPI_STATE_BUSY)
DebugObject_Access(&i->d_obj);
// unset requestcancel job
BPending_Unset(&i->job_requestcancel);
// schedule done
BPending_Set(&i->job_done);
// set state
i->state = PPI_STATE_DONE_PENDING;
}
int PacketPassInterface_GetMTU (PacketPassInterface *i)
{
DebugObject_Access(&i->d_obj);
return i->mtu;
}
void PacketPassInterface_Sender_Init (PacketPassInterface *i, PacketPassInterface_handler_done handler_done, void *user)
{
ASSERT(handler_done)
ASSERT(!i->handler_done)
DebugObject_Access(&i->d_obj);
i->handler_done = handler_done;
i->user_user = user;
}
void PacketPassInterface_Sender_Send (PacketPassInterface *i, uint8_t *data, int data_len)
{
ASSERT(data_len >= 0)
ASSERT(data_len <= i->mtu)
ASSERT(!(data_len > 0) || data)
ASSERT(i->state == PPI_STATE_NONE)
ASSERT(i->handler_done)
DebugObject_Access(&i->d_obj);
// schedule operation
i->job_operation_data = data;
i->job_operation_len = data_len;
BPending_Set(&i->job_operation);
// set state
i->state = PPI_STATE_OPERATION_PENDING;
i->cancel_requested = 0;
}
void PacketPassInterface_Sender_RequestCancel (PacketPassInterface *i)
{
ASSERT(i->state == PPI_STATE_OPERATION_PENDING || i->state == PPI_STATE_BUSY || i->state == PPI_STATE_DONE_PENDING)
ASSERT(i->handler_requestcancel)
DebugObject_Access(&i->d_obj);
// ignore multiple cancel requests
if (i->cancel_requested) {
return;
}
// remember we requested cancel
i->cancel_requested = 1;
if (i->state == PPI_STATE_OPERATION_PENDING) {
// unset operation job
BPending_Unset(&i->job_operation);
// set done job
BPending_Set(&i->job_done);
// set state
i->state = PPI_STATE_DONE_PENDING;
} else if (i->state == PPI_STATE_BUSY) {
// set requestcancel job
BPending_Set(&i->job_requestcancel);
}
}
int PacketPassInterface_HasCancel (PacketPassInterface *i)
{
DebugObject_Access(&i->d_obj);
return !!i->handler_requestcancel;
}
#endif

View File

@@ -0,0 +1,182 @@
/**
* @file PacketProtoDecoder.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <string.h>
#include "misc/debug.h"
#include "misc/byteorder.h"
#include "misc/minmax.h"
#include "base/BLog.h"
#include "flow/PacketProtoDecoder.h"
#include "generated/blog_channel_PacketProtoDecoder.h"
static void process_data (PacketProtoDecoder *enc);
static void input_handler_done (PacketProtoDecoder *enc, int data_len);
static void output_handler_done (PacketProtoDecoder *enc);
void process_data (PacketProtoDecoder *enc)
{
int was_error = 0;
do {
uint8_t *data = enc->buf + enc->buf_start;
int left = enc->buf_used;
// check if header was received
if (left < sizeof(struct packetproto_header)) {
break;
}
struct packetproto_header header;
memcpy(&header, data, sizeof(header));
data += sizeof(struct packetproto_header);
left -= sizeof(struct packetproto_header);
int data_len = ltoh16(header.len);
// check data length
if (data_len > enc->output_mtu) {
BLog(BLOG_NOTICE, "error: packet too large");
was_error = 1;
break;
}
// check if whole packet was received
if (left < data_len) {
break;
}
// update buffer
enc->buf_start += sizeof(struct packetproto_header) + data_len;
enc->buf_used -= sizeof(struct packetproto_header) + data_len;
// submit packet
PacketPassInterface_Sender_Send(enc->output, data, data_len);
return;
} while (0);
if (was_error) {
// reset buffer
enc->buf_start = 0;
enc->buf_used = 0;
} else {
// if we reached the end of the buffer, wrap around to allow more data to be received
if (enc->buf_start + enc->buf_used == enc->buf_size) {
memmove(enc->buf, enc->buf + enc->buf_start, enc->buf_used);
enc->buf_start = 0;
}
}
// receive data
StreamRecvInterface_Receiver_Recv(enc->input, enc->buf + (enc->buf_start + enc->buf_used), enc->buf_size - (enc->buf_start + enc->buf_used));
// if we had error, report it
if (was_error) {
enc->handler_error(enc->user);
return;
}
}
static void input_handler_done (PacketProtoDecoder *enc, int data_len)
{
ASSERT(data_len > 0)
ASSERT(data_len <= enc->buf_size - (enc->buf_start + enc->buf_used))
DebugObject_Access(&enc->d_obj);
// update buffer
enc->buf_used += data_len;
// process data
process_data(enc);
return;
}
void output_handler_done (PacketProtoDecoder *enc)
{
DebugObject_Access(&enc->d_obj);
// process data
process_data(enc);
return;
}
int PacketProtoDecoder_Init (PacketProtoDecoder *enc, StreamRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg, void *user, PacketProtoDecoder_handler_error handler_error)
{
// init arguments
enc->input = input;
enc->output = output;
enc->user = user;
enc->handler_error = handler_error;
// init input
StreamRecvInterface_Receiver_Init(enc->input, (StreamRecvInterface_handler_done)input_handler_done, enc);
// init output
PacketPassInterface_Sender_Init(enc->output, (PacketPassInterface_handler_done)output_handler_done, enc);
// set output MTU, limit by maximum payload size
enc->output_mtu = bmin_int(PacketPassInterface_GetMTU(enc->output), PACKETPROTO_MAXPAYLOAD);
// init buffer state
enc->buf_size = PACKETPROTO_ENCLEN(enc->output_mtu);
enc->buf_start = 0;
enc->buf_used = 0;
// allocate buffer
if (!(enc->buf = (uint8_t *)malloc(enc->buf_size))) {
goto fail0;
}
// start receiving
StreamRecvInterface_Receiver_Recv(enc->input, enc->buf, enc->buf_size);
DebugObject_Init(&enc->d_obj);
return 1;
fail0:
return 0;
}
void PacketProtoDecoder_Free (PacketProtoDecoder *enc)
{
DebugObject_Free(&enc->d_obj);
// free buffer
free(enc->buf);
}
void PacketProtoDecoder_Reset (PacketProtoDecoder *enc)
{
DebugObject_Access(&enc->d_obj);
enc->buf_start += enc->buf_used;
enc->buf_used = 0;
}

View File

@@ -0,0 +1,96 @@
/**
* @file PacketProtoDecoder.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Object which decodes a stream according to PacketProto.
*/
#ifndef BADVPN_FLOW_PACKETPROTODECODER_H
#define BADVPN_FLOW_PACKETPROTODECODER_H
#include <stdint.h>
#include "protocol/packetproto.h"
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "flow/StreamRecvInterface.h"
#include "flow/PacketPassInterface.h"
/**
* Handler called when a protocol error occurs.
* When an error occurs, the decoder is reset to the initial state.
*
* @param user as in {@link PacketProtoDecoder_Init}
*/
typedef void (*PacketProtoDecoder_handler_error) (void *user);
typedef struct {
StreamRecvInterface *input;
PacketPassInterface *output;
void *user;
PacketProtoDecoder_handler_error handler_error;
int output_mtu;
int buf_size;
int buf_start;
int buf_used;
uint8_t *buf;
DebugObject d_obj;
} PacketProtoDecoder;
/**
* Initializes the object.
*
* @param enc the object
* @param input input interface. The decoder will accept packets with payload size up to its MTU
* (but the payload can never be more than PACKETPROTO_MAXPAYLOAD).
* @param output output interface
* @param pg pending group
* @param user argument to handlers
* @param handler_error error handler
* @return 1 on success, 0 on failure
*/
int PacketProtoDecoder_Init (PacketProtoDecoder *enc, StreamRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg, void *user, PacketProtoDecoder_handler_error handler_error) WARN_UNUSED;
/**
* Frees the object.
*
* @param enc the object
*/
void PacketProtoDecoder_Free (PacketProtoDecoder *enc);
/**
* Clears the internal buffer.
* The next data received from the input will be treated as a new
* PacketProto stream.
*
* @param enc the object
*/
void PacketProtoDecoder_Reset (PacketProtoDecoder *enc);
#endif

View File

@@ -0,0 +1,101 @@
/**
* @file PacketProtoEncoder.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stddef.h>
#include <string.h>
#include "protocol/packetproto.h"
#include "misc/balign.h"
#include "misc/debug.h"
#include "misc/byteorder.h"
#include "flow/PacketProtoEncoder.h"
static void output_handler_recv (PacketProtoEncoder *enc, uint8_t *data)
{
ASSERT(!enc->output_packet)
ASSERT(data)
DebugObject_Access(&enc->d_obj);
// schedule receive
enc->output_packet = data;
PacketRecvInterface_Receiver_Recv(enc->input, enc->output_packet + sizeof(struct packetproto_header));
}
static void input_handler_done (PacketProtoEncoder *enc, int in_len)
{
ASSERT(enc->output_packet)
DebugObject_Access(&enc->d_obj);
// write length
struct packetproto_header pp;
pp.len = htol16(in_len);
memcpy(enc->output_packet, &pp, sizeof(pp));
// finish output packet
enc->output_packet = NULL;
PacketRecvInterface_Done(&enc->output, PACKETPROTO_ENCLEN(in_len));
}
void PacketProtoEncoder_Init (PacketProtoEncoder *enc, PacketRecvInterface *input, BPendingGroup *pg)
{
ASSERT(PacketRecvInterface_GetMTU(input) <= PACKETPROTO_MAXPAYLOAD)
// init arguments
enc->input = input;
// init input
PacketRecvInterface_Receiver_Init(enc->input, (PacketRecvInterface_handler_done)input_handler_done, enc);
// init output
PacketRecvInterface_Init(
&enc->output, PACKETPROTO_ENCLEN(PacketRecvInterface_GetMTU(enc->input)),
(PacketRecvInterface_handler_recv)output_handler_recv, enc, pg
);
// set no output packet
enc->output_packet = NULL;
DebugObject_Init(&enc->d_obj);
}
void PacketProtoEncoder_Free (PacketProtoEncoder *enc)
{
DebugObject_Free(&enc->d_obj);
// free input
PacketRecvInterface_Free(&enc->output);
}
PacketRecvInterface * PacketProtoEncoder_GetOutput (PacketProtoEncoder *enc)
{
DebugObject_Access(&enc->d_obj);
return &enc->output;
}

View File

@@ -0,0 +1,80 @@
/**
* @file PacketProtoEncoder.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Object which encodes packets according to PacketProto.
*/
#ifndef BADVPN_FLOW_PACKETPROTOENCODER_H
#define BADVPN_FLOW_PACKETPROTOENCODER_H
#include <stdint.h>
#include "base/DebugObject.h"
#include "flow/PacketRecvInterface.h"
/**
* Object which encodes packets according to PacketProto.
*
* Input is with {@link PacketRecvInterface}.
* Output is with {@link PacketRecvInterface}.
*/
typedef struct {
PacketRecvInterface *input;
PacketRecvInterface output;
uint8_t *output_packet;
DebugObject d_obj;
} PacketProtoEncoder;
/**
* Initializes the object.
*
* @param enc the object
* @param input input interface. Its MTU must be <=PACKETPROTO_MAXPAYLOAD.
* @param pg pending group
*/
void PacketProtoEncoder_Init (PacketProtoEncoder *enc, PacketRecvInterface *input, BPendingGroup *pg);
/**
* Frees the object.
*
* @param enc the object
*/
void PacketProtoEncoder_Free (PacketProtoEncoder *enc);
/**
* Returns the output interface.
* The MTU of the output interface is PACKETPROTO_ENCLEN(MTU of input interface).
*
* @param enc the object
* @return output interface
*/
PacketRecvInterface * PacketProtoEncoder_GetOutput (PacketProtoEncoder *enc);
#endif

View File

@@ -0,0 +1,82 @@
/**
* @file PacketProtoFlow.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "protocol/packetproto.h"
#include "misc/debug.h"
#include "flow/PacketProtoFlow.h"
int PacketProtoFlow_Init (PacketProtoFlow *o, int input_mtu, int num_packets, PacketPassInterface *output, BPendingGroup *pg)
{
ASSERT(input_mtu >= 0)
ASSERT(input_mtu <= PACKETPROTO_MAXPAYLOAD)
ASSERT(num_packets > 0)
ASSERT(PacketPassInterface_GetMTU(output) >= PACKETPROTO_ENCLEN(input_mtu))
// init async input
BufferWriter_Init(&o->ainput, input_mtu, pg);
// init encoder
PacketProtoEncoder_Init(&o->encoder, BufferWriter_GetOutput(&o->ainput), pg);
// init buffer
if (!PacketBuffer_Init(&o->buffer, PacketProtoEncoder_GetOutput(&o->encoder), output, num_packets, pg)) {
goto fail0;
}
DebugObject_Init(&o->d_obj);
return 1;
fail0:
PacketProtoEncoder_Free(&o->encoder);
BufferWriter_Free(&o->ainput);
return 0;
}
void PacketProtoFlow_Free (PacketProtoFlow *o)
{
DebugObject_Free(&o->d_obj);
// free buffer
PacketBuffer_Free(&o->buffer);
// free encoder
PacketProtoEncoder_Free(&o->encoder);
// free async input
BufferWriter_Free(&o->ainput);
}
BufferWriter * PacketProtoFlow_GetInput (PacketProtoFlow *o)
{
DebugObject_Access(&o->d_obj);
return &o->ainput;
}

View File

@@ -0,0 +1,83 @@
/**
* @file PacketProtoFlow.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Buffer which encodes packets with PacketProto, with {@link BufferWriter}
* input and {@link PacketPassInterface} output.
*/
#ifndef BADVPN_FLOW_PACKETPROTOFLOW_H
#define BADVPN_FLOW_PACKETPROTOFLOW_H
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "flow/BufferWriter.h"
#include "flow/PacketProtoEncoder.h"
#include "flow/PacketBuffer.h"
/**
* Buffer which encodes packets with PacketProto, with {@link BufferWriter}
* input and {@link PacketPassInterface} output.
*/
typedef struct {
BufferWriter ainput;
PacketProtoEncoder encoder;
PacketBuffer buffer;
DebugObject d_obj;
} PacketProtoFlow;
/**
* Initializes the object.
*
* @param o the object
* @param input_mtu maximum input packet size. Must be >=0 and <=PACKETPROTO_MAXPAYLOAD.
* @param num_packets minimum number of packets the buffer should hold. Must be >0.
* @param output output interface. Its MTU must be >=PACKETPROTO_ENCLEN(input_mtu).
* @param pg pending group
* @return 1 on success, 0 on failure
*/
int PacketProtoFlow_Init (PacketProtoFlow *o, int input_mtu, int num_packets, PacketPassInterface *output, BPendingGroup *pg) WARN_UNUSED;
/**
* Frees the object.
*
* @param o the object
*/
void PacketProtoFlow_Free (PacketProtoFlow *o);
/**
* Returns the input interface.
*
* @param o the object
* @return input interface
*/
BufferWriter * PacketProtoFlow_GetInput (PacketProtoFlow *o);
#endif

View File

@@ -0,0 +1,56 @@
/**
* @file PacketRecvInterface.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "flow/PacketRecvInterface.h"
void _PacketRecvInterface_job_operation (PacketRecvInterface *i)
{
ASSERT(i->state == PRI_STATE_OPERATION_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = PRI_STATE_BUSY;
// call handler
i->handler_operation(i->user_provider, i->job_operation_data);
return;
}
void _PacketRecvInterface_job_done (PacketRecvInterface *i)
{
ASSERT(i->state == PRI_STATE_DONE_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = PRI_STATE_NONE;
// call handler
i->handler_done(i->user_user, i->job_done_len);
return;
}

View File

@@ -0,0 +1,170 @@
/**
* @file PacketRecvInterface.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Interface allowing a packet receiver to receive data packets from a packet sender.
*/
#ifndef BADVPN_FLOW_PACKETRECVINTERFACE_H
#define BADVPN_FLOW_PACKETRECVINTERFACE_H
#include <stdint.h>
#include <stddef.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "base/BPending.h"
#define PRI_STATE_NONE 1
#define PRI_STATE_OPERATION_PENDING 2
#define PRI_STATE_BUSY 3
#define PRI_STATE_DONE_PENDING 4
typedef void (*PacketRecvInterface_handler_recv) (void *user, uint8_t *data);
typedef void (*PacketRecvInterface_handler_done) (void *user, int data_len);
typedef struct {
// provider data
int mtu;
PacketRecvInterface_handler_recv handler_operation;
void *user_provider;
// user data
PacketRecvInterface_handler_done handler_done;
void *user_user;
// operation job
BPending job_operation;
uint8_t *job_operation_data;
// done job
BPending job_done;
int job_done_len;
// state
int state;
DebugObject d_obj;
} PacketRecvInterface;
static void PacketRecvInterface_Init (PacketRecvInterface *i, int mtu, PacketRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg);
static void PacketRecvInterface_Free (PacketRecvInterface *i);
static void PacketRecvInterface_Done (PacketRecvInterface *i, int data_len);
static int PacketRecvInterface_GetMTU (PacketRecvInterface *i);
static void PacketRecvInterface_Receiver_Init (PacketRecvInterface *i, PacketRecvInterface_handler_done handler_done, void *user);
static void PacketRecvInterface_Receiver_Recv (PacketRecvInterface *i, uint8_t *data);
void _PacketRecvInterface_job_operation (PacketRecvInterface *i);
void _PacketRecvInterface_job_done (PacketRecvInterface *i);
void PacketRecvInterface_Init (PacketRecvInterface *i, int mtu, PacketRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg)
{
ASSERT(mtu >= 0)
// init arguments
i->mtu = mtu;
i->handler_operation = handler_operation;
i->user_provider = user;
// set no user
i->handler_done = NULL;
// init jobs
BPending_Init(&i->job_operation, pg, (BPending_handler)_PacketRecvInterface_job_operation, i);
BPending_Init(&i->job_done, pg, (BPending_handler)_PacketRecvInterface_job_done, i);
// set state
i->state = PRI_STATE_NONE;
DebugObject_Init(&i->d_obj);
}
void PacketRecvInterface_Free (PacketRecvInterface *i)
{
DebugObject_Free(&i->d_obj);
// free jobs
BPending_Free(&i->job_done);
BPending_Free(&i->job_operation);
}
void PacketRecvInterface_Done (PacketRecvInterface *i, int data_len)
{
ASSERT(data_len >= 0)
ASSERT(data_len <= i->mtu)
ASSERT(i->state == PRI_STATE_BUSY)
DebugObject_Access(&i->d_obj);
// schedule done
i->job_done_len = data_len;
BPending_Set(&i->job_done);
// set state
i->state = PRI_STATE_DONE_PENDING;
}
int PacketRecvInterface_GetMTU (PacketRecvInterface *i)
{
DebugObject_Access(&i->d_obj);
return i->mtu;
}
void PacketRecvInterface_Receiver_Init (PacketRecvInterface *i, PacketRecvInterface_handler_done handler_done, void *user)
{
ASSERT(handler_done)
ASSERT(!i->handler_done)
DebugObject_Access(&i->d_obj);
i->handler_done = handler_done;
i->user_user = user;
}
void PacketRecvInterface_Receiver_Recv (PacketRecvInterface *i, uint8_t *data)
{
ASSERT(!(i->mtu > 0) || data)
ASSERT(i->state == PRI_STATE_NONE)
ASSERT(i->handler_done)
DebugObject_Access(&i->d_obj);
// schedule operation
i->job_operation_data = data;
BPending_Set(&i->job_operation);
// set state
i->state = PRI_STATE_OPERATION_PENDING;
}
#endif

View File

@@ -0,0 +1,111 @@
/**
* @file PacketStreamSender.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "misc/debug.h"
#include "flow/PacketStreamSender.h"
static void send_data (PacketStreamSender *s)
{
ASSERT(s->in_len >= 0)
if (s->in_used < s->in_len) {
// send more data
StreamPassInterface_Sender_Send(s->output, s->in + s->in_used, s->in_len - s->in_used);
} else {
// finish input packet
s->in_len = -1;
PacketPassInterface_Done(&s->input);
}
}
static void input_handler_send (PacketStreamSender *s, uint8_t *data, int data_len)
{
ASSERT(s->in_len == -1)
ASSERT(data_len >= 0)
DebugObject_Access(&s->d_obj);
// set input packet
s->in_len = data_len;
s->in = data;
s->in_used = 0;
// send
send_data(s);
}
static void output_handler_done (PacketStreamSender *s, int data_len)
{
ASSERT(s->in_len >= 0)
ASSERT(data_len > 0)
ASSERT(data_len <= s->in_len - s->in_used)
DebugObject_Access(&s->d_obj);
// update number of bytes sent
s->in_used += data_len;
// send
send_data(s);
}
void PacketStreamSender_Init (PacketStreamSender *s, StreamPassInterface *output, int mtu, BPendingGroup *pg)
{
ASSERT(mtu >= 0)
// init arguments
s->output = output;
// init input
PacketPassInterface_Init(&s->input, mtu, (PacketPassInterface_handler_send)input_handler_send, s, pg);
// init output
StreamPassInterface_Sender_Init(s->output, (StreamPassInterface_handler_done)output_handler_done, s);
// have no input packet
s->in_len = -1;
DebugObject_Init(&s->d_obj);
}
void PacketStreamSender_Free (PacketStreamSender *s)
{
DebugObject_Free(&s->d_obj);
// free input
PacketPassInterface_Free(&s->input);
}
PacketPassInterface * PacketStreamSender_GetInput (PacketStreamSender *s)
{
DebugObject_Access(&s->d_obj);
return &s->input;
}

View File

@@ -0,0 +1,83 @@
/**
* @file PacketStreamSender.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Object which forwards packets obtained with {@link PacketPassInterface}
* as a stream with {@link StreamPassInterface} (i.e. it concatenates them).
*/
#ifndef BADVPN_FLOW_PACKETSTREAMSENDER_H
#define BADVPN_FLOW_PACKETSTREAMSENDER_H
#include <stdint.h>
#include "base/DebugObject.h"
#include "flow/PacketPassInterface.h"
#include "flow/StreamPassInterface.h"
/**
* Object which forwards packets obtained with {@link PacketPassInterface}
* as a stream with {@link StreamPassInterface} (i.e. it concatenates them).
*/
typedef struct {
DebugObject d_obj;
PacketPassInterface input;
StreamPassInterface *output;
int in_len;
uint8_t *in;
int in_used;
} PacketStreamSender;
/**
* Initializes the object.
*
* @param s the object
* @param output output interface
* @param mtu input MTU. Must be >=0.
* @param pg pending group
*/
void PacketStreamSender_Init (PacketStreamSender *s, StreamPassInterface *output, int mtu, BPendingGroup *pg);
/**
* Frees the object.
*
* @param s the object
*/
void PacketStreamSender_Free (PacketStreamSender *s);
/**
* Returns the input interface.
* Its MTU will be as in {@link PacketStreamSender_Init}.
*
* @param s the object
* @return input interface
*/
PacketPassInterface * PacketStreamSender_GetInput (PacketStreamSender *s);
#endif

View File

@@ -0,0 +1,87 @@
/**
* @file SinglePacketBuffer.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "misc/debug.h"
#include "misc/balloc.h"
#include "flow/SinglePacketBuffer.h"
static void input_handler_done (SinglePacketBuffer *o, int in_len)
{
DebugObject_Access(&o->d_obj);
PacketPassInterface_Sender_Send(o->output, o->buf, in_len);
}
static void output_handler_done (SinglePacketBuffer *o)
{
DebugObject_Access(&o->d_obj);
PacketRecvInterface_Receiver_Recv(o->input, o->buf);
}
int SinglePacketBuffer_Init (SinglePacketBuffer *o, PacketRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg)
{
ASSERT(PacketPassInterface_GetMTU(output) >= PacketRecvInterface_GetMTU(input))
// init arguments
o->input = input;
o->output = output;
// init input
PacketRecvInterface_Receiver_Init(o->input, (PacketRecvInterface_handler_done)input_handler_done, o);
// init output
PacketPassInterface_Sender_Init(o->output, (PacketPassInterface_handler_done)output_handler_done, o);
// init buffer
if (!(o->buf = (uint8_t *)BAlloc(PacketRecvInterface_GetMTU(o->input)))) {
goto fail1;
}
// schedule receive
PacketRecvInterface_Receiver_Recv(o->input, o->buf);
DebugObject_Init(&o->d_obj);
return 1;
fail1:
return 0;
}
void SinglePacketBuffer_Free (SinglePacketBuffer *o)
{
DebugObject_Free(&o->d_obj);
// free buffer
BFree(o->buf);
}

View File

@@ -0,0 +1,75 @@
/**
* @file SinglePacketBuffer.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output
* than can store only a single packet.
*/
#ifndef BADVPN_FLOW_SINGLEPACKETBUFFER_H
#define BADVPN_FLOW_SINGLEPACKETBUFFER_H
#include <stdint.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "flow/PacketRecvInterface.h"
#include "flow/PacketPassInterface.h"
/**
* Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output
* than can store only a single packet.
*/
typedef struct {
DebugObject d_obj;
PacketRecvInterface *input;
PacketPassInterface *output;
uint8_t *buf;
} SinglePacketBuffer;
/**
* Initializes the object.
* Output MTU must be >= input MTU.
*
* @param o the object
* @param input input interface
* @param output output interface
* @param pg pending group
* @return 1 on success, 0 on failure
*/
int SinglePacketBuffer_Init (SinglePacketBuffer *o, PacketRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg) WARN_UNUSED;
/**
* Frees the object
*
* @param o the object
*/
void SinglePacketBuffer_Free (SinglePacketBuffer *o);
#endif

View File

@@ -0,0 +1,56 @@
/**
* @file StreamPassInterface.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "flow/StreamPassInterface.h"
void _StreamPassInterface_job_operation (StreamPassInterface *i)
{
ASSERT(i->state == SPI_STATE_OPERATION_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = SPI_STATE_BUSY;
// call handler
i->handler_operation(i->user_provider, i->job_operation_data, i->job_operation_len);
return;
}
void _StreamPassInterface_job_done (StreamPassInterface *i)
{
ASSERT(i->state == SPI_STATE_DONE_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = SPI_STATE_NONE;
// call handler
i->handler_done(i->user_user, i->job_done_len);
return;
}

View File

@@ -0,0 +1,165 @@
/**
* @file StreamPassInterface.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Interface allowing a stream sender to pass stream data to a stream receiver.
*
* Note that this interface behaves exactly the same and has the same code as
* {@link StreamRecvInterface} if names and its external semantics are disregarded.
* If you modify this file, you should probably modify {@link StreamRecvInterface}
* too.
*/
#ifndef BADVPN_FLOW_STREAMPASSINTERFACE_H
#define BADVPN_FLOW_STREAMPASSINTERFACE_H
#include <stdint.h>
#include <stddef.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "base/BPending.h"
#define SPI_STATE_NONE 1
#define SPI_STATE_OPERATION_PENDING 2
#define SPI_STATE_BUSY 3
#define SPI_STATE_DONE_PENDING 4
typedef void (*StreamPassInterface_handler_send) (void *user, uint8_t *data, int data_len);
typedef void (*StreamPassInterface_handler_done) (void *user, int data_len);
typedef struct {
// provider data
StreamPassInterface_handler_send handler_operation;
void *user_provider;
// user data
StreamPassInterface_handler_done handler_done;
void *user_user;
// operation job
BPending job_operation;
uint8_t *job_operation_data;
int job_operation_len;
// done job
BPending job_done;
int job_done_len;
// state
int state;
DebugObject d_obj;
} StreamPassInterface;
static void StreamPassInterface_Init (StreamPassInterface *i, StreamPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg);
static void StreamPassInterface_Free (StreamPassInterface *i);
static void StreamPassInterface_Done (StreamPassInterface *i, int data_len);
static void StreamPassInterface_Sender_Init (StreamPassInterface *i, StreamPassInterface_handler_done handler_done, void *user);
static void StreamPassInterface_Sender_Send (StreamPassInterface *i, uint8_t *data, int data_len);
void _StreamPassInterface_job_operation (StreamPassInterface *i);
void _StreamPassInterface_job_done (StreamPassInterface *i);
void StreamPassInterface_Init (StreamPassInterface *i, StreamPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg)
{
// init arguments
i->handler_operation = handler_operation;
i->user_provider = user;
// set no user
i->handler_done = NULL;
// init jobs
BPending_Init(&i->job_operation, pg, (BPending_handler)_StreamPassInterface_job_operation, i);
BPending_Init(&i->job_done, pg, (BPending_handler)_StreamPassInterface_job_done, i);
// set state
i->state = SPI_STATE_NONE;
DebugObject_Init(&i->d_obj);
}
void StreamPassInterface_Free (StreamPassInterface *i)
{
DebugObject_Free(&i->d_obj);
// free jobs
BPending_Free(&i->job_done);
BPending_Free(&i->job_operation);
}
void StreamPassInterface_Done (StreamPassInterface *i, int data_len)
{
ASSERT(i->state == SPI_STATE_BUSY)
ASSERT(data_len > 0)
ASSERT(data_len <= i->job_operation_len)
DebugObject_Access(&i->d_obj);
// schedule done
i->job_done_len = data_len;
BPending_Set(&i->job_done);
// set state
i->state = SPI_STATE_DONE_PENDING;
}
void StreamPassInterface_Sender_Init (StreamPassInterface *i, StreamPassInterface_handler_done handler_done, void *user)
{
ASSERT(handler_done)
ASSERT(!i->handler_done)
DebugObject_Access(&i->d_obj);
i->handler_done = handler_done;
i->user_user = user;
}
void StreamPassInterface_Sender_Send (StreamPassInterface *i, uint8_t *data, int data_len)
{
ASSERT(data_len > 0)
ASSERT(data)
ASSERT(i->state == SPI_STATE_NONE)
ASSERT(i->handler_done)
DebugObject_Access(&i->d_obj);
// schedule operation
i->job_operation_data = data;
i->job_operation_len = data_len;
BPending_Set(&i->job_operation);
// set state
i->state = SPI_STATE_OPERATION_PENDING;
}
#endif

View File

@@ -0,0 +1,56 @@
/**
* @file StreamRecvInterface.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "flow/StreamRecvInterface.h"
void _StreamRecvInterface_job_operation (StreamRecvInterface *i)
{
ASSERT(i->state == SRI_STATE_OPERATION_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = SRI_STATE_BUSY;
// call handler
i->handler_operation(i->user_provider, i->job_operation_data, i->job_operation_len);
return;
}
void _StreamRecvInterface_job_done (StreamRecvInterface *i)
{
ASSERT(i->state == SRI_STATE_DONE_PENDING)
DebugObject_Access(&i->d_obj);
// set state
i->state = SRI_STATE_NONE;
// call handler
i->handler_done(i->user_user, i->job_done_len);
return;
}

View File

@@ -0,0 +1,165 @@
/**
* @file StreamRecvInterface.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* Interface allowing a stream receiver to receive stream data from a stream sender.
*
* Note that this interface behaves exactly the same and has the same code as
* {@link StreamPassInterface} if names and its external semantics are disregarded.
* If you modify this file, you should probably modify {@link StreamPassInterface}
* too.
*/
#ifndef BADVPN_FLOW_STREAMRECVINTERFACE_H
#define BADVPN_FLOW_STREAMRECVINTERFACE_H
#include <stdint.h>
#include <stddef.h>
#include "misc/debug.h"
#include "base/DebugObject.h"
#include "base/BPending.h"
#define SRI_STATE_NONE 1
#define SRI_STATE_OPERATION_PENDING 2
#define SRI_STATE_BUSY 3
#define SRI_STATE_DONE_PENDING 4
typedef void (*StreamRecvInterface_handler_recv) (void *user, uint8_t *data, int data_len);
typedef void (*StreamRecvInterface_handler_done) (void *user, int data_len);
typedef struct {
// provider data
StreamRecvInterface_handler_recv handler_operation;
void *user_provider;
// user data
StreamRecvInterface_handler_done handler_done;
void *user_user;
// operation job
BPending job_operation;
uint8_t *job_operation_data;
int job_operation_len;
// done job
BPending job_done;
int job_done_len;
// state
int state;
DebugObject d_obj;
} StreamRecvInterface;
static void StreamRecvInterface_Init (StreamRecvInterface *i, StreamRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg);
static void StreamRecvInterface_Free (StreamRecvInterface *i);
static void StreamRecvInterface_Done (StreamRecvInterface *i, int data_len);
static void StreamRecvInterface_Receiver_Init (StreamRecvInterface *i, StreamRecvInterface_handler_done handler_done, void *user);
static void StreamRecvInterface_Receiver_Recv (StreamRecvInterface *i, uint8_t *data, int data_len);
void _StreamRecvInterface_job_operation (StreamRecvInterface *i);
void _StreamRecvInterface_job_done (StreamRecvInterface *i);
void StreamRecvInterface_Init (StreamRecvInterface *i, StreamRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg)
{
// init arguments
i->handler_operation = handler_operation;
i->user_provider = user;
// set no user
i->handler_done = NULL;
// init jobs
BPending_Init(&i->job_operation, pg, (BPending_handler)_StreamRecvInterface_job_operation, i);
BPending_Init(&i->job_done, pg, (BPending_handler)_StreamRecvInterface_job_done, i);
// set state
i->state = SRI_STATE_NONE;
DebugObject_Init(&i->d_obj);
}
void StreamRecvInterface_Free (StreamRecvInterface *i)
{
DebugObject_Free(&i->d_obj);
// free jobs
BPending_Free(&i->job_done);
BPending_Free(&i->job_operation);
}
void StreamRecvInterface_Done (StreamRecvInterface *i, int data_len)
{
ASSERT(i->state == SRI_STATE_BUSY)
ASSERT(data_len > 0)
ASSERT(data_len <= i->job_operation_len)
DebugObject_Access(&i->d_obj);
// schedule done
i->job_done_len = data_len;
BPending_Set(&i->job_done);
// set state
i->state = SRI_STATE_DONE_PENDING;
}
void StreamRecvInterface_Receiver_Init (StreamRecvInterface *i, StreamRecvInterface_handler_done handler_done, void *user)
{
ASSERT(handler_done)
ASSERT(!i->handler_done)
DebugObject_Access(&i->d_obj);
i->handler_done = handler_done;
i->user_user = user;
}
void StreamRecvInterface_Receiver_Recv (StreamRecvInterface *i, uint8_t *data, int data_len)
{
ASSERT(data_len > 0)
ASSERT(data)
ASSERT(i->state == SRI_STATE_NONE)
ASSERT(i->handler_done)
DebugObject_Access(&i->d_obj);
// schedule operation
i->job_operation_data = data;
i->job_operation_len = data_len;
BPending_Set(&i->job_operation);
// set state
i->state = SRI_STATE_OPERATION_PENDING;
}
#endif

View File

@@ -0,0 +1,131 @@
/**
* @file PacketPassInactivityMonitor.c
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "PacketPassInactivityMonitor.h"
static void input_handler_send (PacketPassInactivityMonitor *o, uint8_t *data, int data_len)
{
DebugObject_Access(&o->d_obj);
// schedule send
PacketPassInterface_Sender_Send(o->output, data, data_len);
// stop timer
BReactor_RemoveTimer(o->reactor, &o->timer);
}
static void input_handler_requestcancel (PacketPassInactivityMonitor *o)
{
DebugObject_Access(&o->d_obj);
// request cancel
PacketPassInterface_Sender_RequestCancel(o->output);
}
static void output_handler_done (PacketPassInactivityMonitor *o)
{
DebugObject_Access(&o->d_obj);
// output no longer busy, restart timer
BReactor_SetTimer(o->reactor, &o->timer);
// call done
PacketPassInterface_Done(&o->input);
}
static void timer_handler (PacketPassInactivityMonitor *o)
{
DebugObject_Access(&o->d_obj);
// restart timer
BReactor_SetTimer(o->reactor, &o->timer);
// call handler
if (o->handler) {
o->handler(o->user);
return;
}
}
void PacketPassInactivityMonitor_Init (PacketPassInactivityMonitor *o, PacketPassInterface *output, BReactor *reactor, btime_t interval, PacketPassInactivityMonitor_handler handler, void *user)
{
// init arguments
o->output = output;
o->reactor = reactor;
o->handler = handler;
o->user = user;
// init input
PacketPassInterface_Init(&o->input, PacketPassInterface_GetMTU(o->output), (PacketPassInterface_handler_send)input_handler_send, o, BReactor_PendingGroup(o->reactor));
if (PacketPassInterface_HasCancel(o->output)) {
PacketPassInterface_EnableCancel(&o->input, (PacketPassInterface_handler_requestcancel)input_handler_requestcancel);
}
// init output
PacketPassInterface_Sender_Init(o->output, (PacketPassInterface_handler_done)output_handler_done, o);
// init timer
BTimer_Init(&o->timer, interval, (BTimer_handler)timer_handler, o);
BReactor_SetTimer(o->reactor, &o->timer);
DebugObject_Init(&o->d_obj);
}
void PacketPassInactivityMonitor_Free (PacketPassInactivityMonitor *o)
{
DebugObject_Free(&o->d_obj);
// free timer
BReactor_RemoveTimer(o->reactor, &o->timer);
// free input
PacketPassInterface_Free(&o->input);
}
PacketPassInterface * PacketPassInactivityMonitor_GetInput (PacketPassInactivityMonitor *o)
{
DebugObject_Access(&o->d_obj);
return &o->input;
}
void PacketPassInactivityMonitor_SetHandler (PacketPassInactivityMonitor *o, PacketPassInactivityMonitor_handler handler, void *user)
{
DebugObject_Access(&o->d_obj);
o->handler = handler;
o->user = user;
}
void PacketPassInactivityMonitor_Force (PacketPassInactivityMonitor *o)
{
DebugObject_Access(&o->d_obj);
BReactor_SetTimerAfter(o->reactor, &o->timer, 0);
}

View File

@@ -0,0 +1,124 @@
/**
* @file PacketPassInactivityMonitor.h
* @author Ambroz Bizjak <ambrop7@gmail.com>
*
* @section LICENSE
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @section DESCRIPTION
*
* A {@link PacketPassInterface} layer for detecting inactivity.
*/
#ifndef BADVPN_PACKETPASSINACTIVITYMONITOR_H
#define BADVPN_PACKETPASSINACTIVITYMONITOR_H
#include "base/DebugObject.h"
#include "system/BReactor.h"
#include "flow/PacketPassInterface.h"
/**
* Handler function invoked when inactivity is detected.
* It is guaranteed that the interfaces are in not sending state.
*
* @param user value given to {@link PacketPassInactivityMonitor_Init}
*/
typedef void (*PacketPassInactivityMonitor_handler) (void *user);
/**
* A {@link PacketPassInterface} layer for detecting inactivity.
* It reports inactivity to a user provided handler function.
*
* The object behaves like that:
* ("timer set" means started with the given timeout whether if was running or not,
* "timer unset" means stopped if it was running)
* - There is a timer.
* - The timer is set when the object is initialized.
* - When the input calls Send, the call is passed on to the output.
* If the output accepted the packet, the timer is set. If the output
* blocked the packet, the timer is unset.
* - When the output calls Done, the timer is set, and the call is
* passed on to the input.
* - When the input calls Cancel, the timer is set, and the call is
* passed on to the output.
* - When the timer expires, the timer is set, ant the user's handler
* function is invoked.
*/
typedef struct {
DebugObject d_obj;
PacketPassInterface *output;
BReactor *reactor;
PacketPassInactivityMonitor_handler handler;
void *user;
PacketPassInterface input;
BTimer timer;
} PacketPassInactivityMonitor;
/**
* Initializes the object.
* See {@link PacketPassInactivityMonitor} for details.
*
* @param o the object
* @param output output interface
* @param reactor reactor we live in
* @param interval timer value in milliseconds
* @param handler handler function for reporting inactivity, or NULL to disable
* @param user value passed to handler functions
*/
void PacketPassInactivityMonitor_Init (PacketPassInactivityMonitor *o, PacketPassInterface *output, BReactor *reactor, btime_t interval, PacketPassInactivityMonitor_handler handler, void *user);
/**
* Frees the object.
*
* @param o the object
*/
void PacketPassInactivityMonitor_Free (PacketPassInactivityMonitor *o);
/**
* Returns the input interface.
* The MTU of the interface will be the same as of the output interface.
* The interface supports cancel functionality if the output interface supports it.
*
* @param o the object
* @return input interface
*/
PacketPassInterface * PacketPassInactivityMonitor_GetInput (PacketPassInactivityMonitor *o);
/**
* Sets or removes the inactivity handler.
*
* @param o the object
* @param handler handler function for reporting inactivity, or NULL to disable
* @param user value passed to handler functions
*/
void PacketPassInactivityMonitor_SetHandler (PacketPassInactivityMonitor *o, PacketPassInactivityMonitor_handler handler, void *user);
/**
* Sets the timer to expire immediately in order to force an inactivity report.
*
* @param o the object
*/
void PacketPassInactivityMonitor_Force (PacketPassInactivityMonitor *o);
#endif

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BArpProbe

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BConnection

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BDHCPClient

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BDHCPClientCore

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BDatagram

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BEncryption

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BInputProcess

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BLockReactor

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BNetwork

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BPredicate

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BProcess

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BReactor

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BSSLConnection

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BSignal

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BSocksClient

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BTap

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BThreadSignal

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BThreadWork

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BTime

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BUnixSignal

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DPReceive

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DPRelay

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DataProto

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DatagramPeerIO

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_FragmentProtoAssembler

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_FrameDecider

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_LineBuffer

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_Listener

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDBuildProgram

View File

@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDConfigParser

Some files were not shown because too many files have changed in this diff Show More