Compare commits

...

16 Commits

Author SHA1 Message Date
Ian VanSchooten 755908a189
Merge 71e6734865 into 494f071ed5 2024-10-16 14:36:33 -04:00
Ian VanSchooten 494f071ed5
Move print logs to OSLogger (#179)
This aids in debugging in console.app, since print statements from the PacketTunnelProvider are not shown in xcode's console.
2024-10-16 14:28:07 -04:00
Ian VanSchooten 71e6734865 Remove checkBuild lane 2024-10-16 09:02:50 -04:00
Ian VanSchooten 5c0f98ad8a Just manually xcodebuild 2024-10-16 09:02:50 -04:00
Ian VanSchooten a88c845850 Remove setup_ci 2024-10-16 09:02:50 -04:00
Ian VanSchooten b82ef08fd1 Skip signing 2024-10-16 09:02:50 -04:00
Ian VanSchooten 0e9dae0a9c Build ios debug app, do not sign 2024-10-16 09:02:50 -04:00
Ian VanSchooten 9d5cda7810 Fix rebase error 2024-10-16 09:02:50 -04:00
Ian VanSchooten c886cfcf5b Rename workflow 2024-10-16 09:02:50 -04:00
Ian VanSchooten 8111303d91 Avoid incrementing version number 2024-10-16 09:02:50 -04:00
Ian VanSchooten da64471751 Use fastlane to build 2024-10-16 09:02:50 -04:00
Ian VanSchooten 3e58c41a0e Add fastlane match token 2024-10-16 09:02:50 -04:00
Ian VanSchooten a4703d1403 Add ios build step to ci 2024-10-16 09:02:50 -04:00
Ian VanSchooten 3cb7d84a7b Specify androidapi for gomobile 2024-10-16 09:02:50 -04:00
Ian VanSchooten c91f622e4e Add build workflow 2024-10-16 09:02:50 -04:00
Ian VanSchooten b8bcf32af4 Simplify/fix dart formatting in CI 2024-10-16 09:02:50 -04:00
6 changed files with 89 additions and 10 deletions

View File

@ -24,4 +24,4 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Check formating - name: Check formating
run: dart format -l120 lib/ --set-exit-if-changed --suppress-analytics --output none run: dart format -l120 lib/ --set-exit-if-changed --suppress-analytics --output none

74
.github/workflows/smoke.yml vendored Normal file
View File

@ -0,0 +1,74 @@
# This workflow builds the iOS and Android apps, just to check they build without error
name: Smoke build
on:
push:
branches:
- main
pull_request:
jobs:
build-android:
name: Android
runs-on: macos-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.22"
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
- name: Install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.1'
- name: Check out code
uses: actions/checkout@v3
- name: install dependencies
env:
TOKEN: ${{ secrets.MACHINE_USER_PAT }}
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
flutter pub get
touch env.sh
- name: Build Android debug
run: flutter build appbundle --debug
build-ios:
name: iOS
runs-on: macos-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.22"
- name: Install flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.24.1'
- name: Check out code
uses: actions/checkout@v3
- name: install dependencies
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
flutter pub get
touch env.sh
- name: Build iOS
run: |
cd ios
pod install
xcodebuild -workspace Runner.xcworkspace -scheme Runner -configuration Release clean archive CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO -archivePath "build/MobileNebula.xcarchive"

View File

@ -7,7 +7,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
private var networkMonitor: NWPathMonitor? private var networkMonitor: NWPathMonitor?
private var site: Site? private var site: Site?
private var log = Logger(subsystem: "net.defined.mobileNebula", category: "PacketTunnelProvider") private let log = Logger(subsystem: "net.defined.mobileNebula", category: "PacketTunnelProvider")
private var nebula: MobileNebulaNebula? private var nebula: MobileNebulaNebula?
private var dnUpdater = DNUpdater() private var dnUpdater = DNUpdater()
private var didSleep = false private var didSleep = false
@ -106,7 +106,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
try self.nebula?.reload(String(data: newSite.getConfig(), encoding: .utf8), key: newSite.getKey()) try self.nebula?.reload(String(data: newSite.getConfig(), encoding: .utf8), key: newSite.getKey())
} catch { } catch {
self.log.error("Got an error while updating nebula \(error.localizedDescription, privacy: .public)") log.error("Got an error while updating nebula \(error.localizedDescription, privacy: .public)")
} }
} }

View File

@ -1,6 +1,9 @@
import NetworkExtension import NetworkExtension
import MobileNebula import MobileNebula
import SwiftyJSON import SwiftyJSON
import os.log
let log = Logger(subsystem: "net.defined.mobileNebula", category: "Site")
extension String: Error {} extension String: Error {}
@ -430,7 +433,7 @@ struct IncomingSite: Codable {
return return
} }
print("Saving to \(configPath)") log.notice("Saving to \(configPath, privacy: .public)")
do { do {
if (self.key != nil) { if (self.key != nil) {
let data = self.key!.data(using: .utf8) let data = self.key!.data(using: .utf8)

View File

@ -1,8 +1,10 @@
import Foundation import Foundation
import os.log
class DNUpdater { class DNUpdater {
private let apiClient = APIClient() private let apiClient = APIClient()
private let timer = RepeatingTimer(timeInterval: 15 * 60) // 15 * 60 is 15 minutes private let timer = RepeatingTimer(timeInterval: 30) // 15 * 60 is 15 minutes
private let log = Logger(subsystem: "net.defined.mobileNebula", category: "DNUpdater")
func updateAll(onUpdate: @escaping (Site) -> ()) { func updateAll(onUpdate: @escaping (Site) -> ()) {
_ = SiteList{ (sites, _) -> () in _ = SiteList{ (sites, _) -> () in
@ -55,7 +57,7 @@ class DNUpdater {
} catch (APIClientError.invalidCredentials) { } catch (APIClientError.invalidCredentials) {
if (!credentials.invalid) { if (!credentials.invalid) {
try site.invalidateDNCredentials() try site.invalidateDNCredentials()
print("Invalidated credentials in site \(site.name)") log.notice("Invalidated credentials in site: \(site.name, privacy: .public)")
} }
return return
@ -63,7 +65,7 @@ class DNUpdater {
newSite?.save(manager: nil) { error in newSite?.save(manager: nil) { error in
if (error != nil) { if (error != nil) {
print("failed to save update: \(error!.localizedDescription)") self.log.error("failed to save update: \(error!.localizedDescription, privacy: .public)")
} else { } else {
onUpdate(Site(incoming: newSite!)) onUpdate(Site(incoming: newSite!))
} }
@ -71,11 +73,11 @@ class DNUpdater {
if (credentials.invalid) { if (credentials.invalid) {
try site.validateDNCredentials() try site.validateDNCredentials()
print("Revalidated credentials in site \(site.name)") log.notice("Revalidated credentials in site \(site.name, privacy: .public)")
} }
} catch { } catch {
print("Error while updating \(site.name): \(error.localizedDescription)") log.error("Error while updating \(site.name, privacy: .public): \(error.localizedDescription, privacy: .public)")
} }
} }
} }

View File

@ -9,7 +9,7 @@ clean:
mobileNebula.aar: *.go go.sum mobileNebula.aar: *.go go.sum
go get -d golang.org/x/mobile/cmd/gomobile go get -d golang.org/x/mobile/cmd/gomobile
gomobile bind -trimpath -v --target=android -androidapi 26 gomobile bind -trimpath -v --target=android -androidapi=26
MobileNebula.xcframework: *.go go.sum MobileNebula.xcframework: *.go go.sum
go get -d golang.org/x/mobile/cmd/gomobile go get -d golang.org/x/mobile/cmd/gomobile