Skip to content

Commit 2d4f200

Browse files
committed
Stable version 0.7.0
1 parent 1faf195 commit 2d4f200

File tree

9 files changed

+85
-53
lines changed

9 files changed

+85
-53
lines changed

docs/Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22
0.6.3 → 0.7.0
33
- Re-added option to start the server upon app launch
4-
- Server auto-restarts itself without de-authenticating any clients automatically when the host device's network changes
4+
- Added option to automatically restart server without de-authenticating any clients automatically when the host device's network changes
55
- Added security improvements to prevent brute-forcing of password
66
- Added significantly more error checking for private API functions
77
- Added API Documentation & Donation link in Settings

make.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ fi
117117

118118
if [ "$deb" = true ] || [ "$ipa" = true ]
119119
then
120+
pn "\033[34m==>\033[0m Checking LLVM Version..."
121+
llvm_vers=$(llvm-gcc --version | grep -oE "clang\-[0-9]{4,}" | sed 's/clang\-//g')
122+
[ ${llvm_vers} -lt 1200 ] && err "Please use llvm >= 12.0.0 to compile"
123+
120124
rm -rf ${ROOTDIR}/package/SMServer.xcarchive
121125
pn "\033[34m==>\033[0m Cleaning and archiving package..."
122126
xcodebuild clean archive -workspace ${ROOTDIR}/src/SMServer.xcworkspace -scheme SMServer -archivePath ${ROOTDIR}/package/SMServer.xcarchive -destination generic/platform=iOS
Binary file not shown.

src/SMServer/html/chats.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,9 @@
883883
case "typing":
884884
setChatAsTyping(content);
885885
break;
886+
case "idle":
887+
setChatAsIdle(content);
888+
break;
886889
default:
887890
console.log(`cannot handle request: '${msg}'`);
888891
break;
@@ -1178,6 +1181,13 @@
11781181
}
11791182
}
11801183

1184+
function setChatAsIdle(chat) {
1185+
if (debug) console.log(`setting ${chat} as idle`);
1186+
var current = document.getElementById("typingIndicator");
1187+
if (chat !== current_chat_id || current === null || current === undefined) return;
1188+
current.outerHTML = "";
1189+
}
1190+
11811191
function enableSubject() {
11821192
if (debug) console.log("enabling subject");
11831193
var tbox = document.getElementById("sendbox");

src/SMServer/ios/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ struct ContentView: View {
260260
}
261261
}) {
262262
Image(systemName: "trash")
263-
.padding(12)
263+
.padding(8)
264264
.background(Color.blue)
265265
.cornerRadius(40)
266266
.foregroundColor(Color.white)

src/SMServer/ios/SettingsView.swift

Lines changed: 60 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,19 @@ struct SettingsView: View {
152152
self.settings.start_on_load = $0
153153
UserDefaults.standard.setValue($0, forKey: "start_on_load")
154154
})
155+
156+
let reload_binding = Binding<Bool>(get: {
157+
self.settings.reload_on_network_change
158+
}, set: {
159+
self.settings.reload_on_network_change = $0
160+
UserDefaults.standard.setValue($0, forKey: "reload_on_network_change")
161+
})
155162

156163
return ScrollView {
157164
VStack(alignment: .leading, spacing: 16) {
158165
Text("Settings")
159166
.font(.largeTitle)
160167

161-
Spacer().frame(height: 8)
162-
163168
Text("Load values")
164169
.font(.headline)
165170

@@ -236,12 +241,10 @@ struct SettingsView: View {
236241
Toggle("WebSocket Proxy Compatibility", isOn: socket_subdir_enabled_binding)
237242

238243
if socket_subdir_enabled {
239-
HStack {
240-
Text("Socket subdirectory")
241-
Spacer()
244+
VStack(alignment: .leading) {
245+
Text("WebSocket subdirectory")
242246
TextField("e.g. /sms/socket", text: socket_subdir_binding)
243247
.textFieldStyle(RoundedBorderTextFieldStyle())
244-
.frame(width: 180)
245248
.disableAutocorrection(true)
246249
}
247250
}
@@ -260,11 +263,12 @@ struct SettingsView: View {
260263
Section {
261264
VStack(spacing: 8) {
262265

263-
Toggle("Toggle debug", isOn: debug_binding)
266+
Toggle("Enable debug", isOn: debug_binding)
264267
Toggle("Enable backgrounding", isOn: background_binding)
265268
Toggle("Enable SSL", isOn: secure_binding)
266269
Toggle("Allow operation off of Wifi", isOn: override_binding)
267270
Toggle("Start server on app launch", isOn: load_binding)
271+
Toggle("Restart server on network change", isOn: reload_binding)
268272

269273
}
270274
}.padding(10)
@@ -281,68 +285,79 @@ struct SettingsView: View {
281285
Alert(title: Text("Settings Reset"), message: Text("Your settings were reset to default"))
282286
})
283287

288+
/// ok so this VStack still has an absurd amount of padding on the top and bottom when you have a large text size, for some reason.
289+
/// I'll fix that eventually
284290
VStack(alignment: .leading) {
285-
GeometryReader { proxy in
286-
LinearGradient(
287-
gradient: Gradient(
288-
colors: [
289-
Color.init(red: cl_red, green: (Double(proxy.frame(in: .named("frameLayer")).minY) - 240) / 400, blue: cl_blu),
290-
Color.init(red: cl_red, green: (Double(proxy.frame(in: .named("frameLayer")).minY) - 310) / 400, blue: cl_blu)
291-
]
292-
),
293-
startPoint: .topLeading, endPoint: .bottomTrailing
294-
).mask(
295-
VStack {
296-
Button(action: {
297-
let github_url = URL.init(string: "https://github.com/iandwelker/smserver/blob/master/docs/API.md")
298-
guard let url = github_url, UIApplication.shared.canOpenURL(url) else { return }
299-
UIApplication.shared.open(url)
300-
}) {
291+
ZStack {
292+
GeometryReader { proxy in
293+
/// makes vibrant, shiny text thing. Very nice. Padding is :( tho
294+
LinearGradient(
295+
gradient: Gradient(
296+
colors: [
297+
Color.init(red: self.cl_red, green: (Double(proxy.frame(in: .named("frameLayer")).minY) - 240) / 400, blue: self.cl_blu),
298+
Color.init(red: self.cl_red, green: (Double(proxy.frame(in: .named("frameLayer")).minY) - 310) / 400, blue: self.cl_blu)
299+
]
300+
),
301+
startPoint: .topLeading, endPoint: .bottomTrailing
302+
).mask(
303+
VStack {
301304
HStack {
302305
Text("View API Documentation")
303306
.aspectRatio(contentMode: .fill)
304307
Spacer()
305308
Image(systemName: "doc.text")
306309
}
307-
}
308310

309-
Spacer().frame(height: 20)
311+
Spacer().frame(height: 20)
310312

311-
Button(action: {
312-
let url = URL.init(string: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=K3A6WVKT54PH4&item_name=Tweak%2FApplication+Development&currency_code=USD")
313-
guard let github_url = url, UIApplication.shared.canOpenURL(github_url) else { return }
314-
UIApplication.shared.open(github_url)
315-
}) {
316313
HStack {
317314
Text("Donate to support SMServer")
318315
Spacer()
319316
Image(systemName: "link")
320317
}
321-
}
322318

323-
Spacer().frame(height: 20)
319+
Spacer().frame(height: 20)
324320

325-
Button(action: {
326-
self.resetDefaults()
327-
}) {
328321
HStack {
329322
Text("Reset Settings to Default")
330323
Spacer()
331324
Image(systemName: "arrow.clockwise")
332325
}
333326
}
334-
}
335-
)
336-
}.padding(10)
337-
.background(grey_box)
338-
.cornerRadius(8)
339-
.frame(height: 120) /// yeah don't like this but I think it may be the only thing
327+
)
328+
}
340329

341-
Text("Compatible with libSMServer 0.6.0")
342-
.font(.callout)
343-
.foregroundColor(.gray)
330+
VStack {
331+
Button(action: {
332+
let github_url = URL.init(string: "https://github.com/iandwelker/smserver/blob/master/docs/API.md")
333+
guard let url = github_url, UIApplication.shared.canOpenURL(url) else { return }
334+
UIApplication.shared.open(url)
335+
}) {
336+
Text("").foregroundColor(Color.clear)
337+
}.padding(.bottom, 10)
338+
339+
Button(action: {
340+
let paypal_url = URL.init(string: "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=K3A6WVKT54PH4&item_name=Tweak%2FApplication+Development&currency_code=USD")
341+
guard let url = paypal_url, UIApplication.shared.canOpenURL(url) else { return }
342+
UIApplication.shared.open(url)
343+
}) {
344+
Text("").foregroundColor(Color.clear)
345+
}.padding(.init(top: 10, leading: 0, bottom: 10, trailing: 0))
346+
347+
Button(action: {
348+
self.resetDefaults()
349+
}) {
350+
Text("").foregroundColor(Color.clear)
351+
}.padding(.top, 10)
352+
}
353+
}
354+
}.padding(10)
355+
.background(grey_box)
356+
.cornerRadius(8)
344357

345-
}
358+
Text("Compatible with libSMServer 0.6.0")
359+
.font(.callout)
360+
.foregroundColor(.gray)
346361

347362
}.padding()
348363
.animation(.easeInOut(duration: 0.2))

src/SMServer/shared/ChatDelegate.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,18 @@ final class ChatDelegate {
317317
/// check if it's a group chat
318318
let is_group = num.prefix(4) == "chat" && !num.contains("@") && num.count >= 20
319319
var from_string: String = ""
320-
var fixed_num = num
320+
var fixed_num = "?"
321321

322322
if num.contains(",") {
323323
/// So that you can merge multiple conversations
324-
fixed_num = num.split(separator: ",").joined(separator: "\" or chat_identifier is \"")
324+
fixed_num = [String](repeating: "?", count: num.split(separator: ",").count).joined(separator: " or chat_identifier is ")
325325
}
326326

327327
if from != 0 {
328-
from_string = " and \(is_group ? "m." : "")is_from_me is \(from == 1 ? 1 : 0)"
328+
from_string = " and m.is_from_me is \(from == 1 ? 1 : 0)"
329329
}
330-
331-
var messages: [[String:Any]] = selectFromSql(db: db, columns: ["m.ROWID", "m.guid", "m.text", "m.subject", "m.is_from_me", "m.date", "m.service", "m.cache_has_attachments", "m.balloon_bundle_id", "m.payload_data", "m.associated_message_guid", "m.associated_message_type", "h.id"], table: "message m", condition: "left join handle h on h.ROWID = m.handle_id where m.ROWID in (select message_id from chat_message_join where chat_id in (select ROWID from chat where chat_identifier is ?\(from_string))) order by m.date desc", args: [fixed_num], num_items: num_items, offset: offset, split_ids: true)
330+
331+
var messages: [[String:Any]] = selectFromSql(db: db, columns: ["m.ROWID", "m.guid", "m.text", "m.subject", "m.is_from_me", "m.date", "m.service", "m.cache_has_attachments", "m.balloon_bundle_id", "m.payload_data", "m.associated_message_guid", "m.associated_message_type", "h.id"], table: "message m", condition: "left join handle h on h.ROWID = m.handle_id where m.ROWID in (select message_id from chat_message_join where chat_id in (select ROWID from chat where chat_identifier is \(fixed_num)\(from_string))) order by m.date desc", args: num.split(separator: ",").map({String($0)}), num_items: num_items, offset: offset, split_ids: true)
332332

333333
parseTexts(&messages, db: db, contact_db: contact_db, is_group: is_group)
334334

src/SMServer/shared/ServerDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class ServerDelegate {
6262
/// This is kinda a hacky way sending the notification into a `CFNotificationCallback`, which then posts a notification in the `NSNotificationCenter`), but
6363
/// it is necessary. The `CFNotificationCallback` can't capture context, but the `NSNotificationCenter` callback can. We need to capture context for our purposes,
6464
/// so this seemed like the most efficient solution to accomplish that.
65+
66+
/// However, it does post the notification like 10 times in 5 seconds, so that's why we have to have the special checks in the `reloadServer(_:)` function
6567

6668
let callback: CFNotificationCallback = { (nc, observer, name, object, info) in
6769
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ianwelker.smserver.system.config.network_change"), object: nil)
@@ -74,7 +76,7 @@ class ServerDelegate {
7476
}
7577

7678
@objc func reloadServer(_: Notification) {
77-
if restarted_recently { return }
79+
if restarted_recently || !settings.reload_on_network_change { return }
7880

7981
Const.log("Disconnected from wifi, restarting server with current auth list...", debug: self.debug)
8082

src/SMServer/shared/Settings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Settings {
2424
var send_typing: Bool = UserDefaults.standard.object(forKey: "send_typing") as? Bool ?? true
2525
var combine_contacts: Bool = UserDefaults.standard.object(forKey: "combine_contacts") as? Bool ?? false
2626
var start_on_load: Bool = UserDefaults.standard.object(forKey: "start_on_load") as? Bool ?? false
27+
var reload_on_network_change: Bool = UserDefaults.standard.object(forKey: "reload_on_network_change") as? Bool ?? true
2728

2829
#if os(macOS)
2930
var config_file_url: String = Const.config_file_url.path

0 commit comments

Comments
 (0)